License  Example  Documentation  Downloads
GContnrs is a generic container collection for Lazarus and Free Pascal. It implements : doubly linked lists, dequeues, hash maps, hash sets, priority queues, queues, stacks, tree maps, tree sets, vectors and bitsets.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules,and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>.
program VectorDemo;
{$mode objfpc}{$H+}
uses Classes, SysUtils, GContnrs;
type
TMyVector = class(specialize TGenVector<Integer>)
function DefaultItemToString(const Item: Integer) : String; override; { }
function DefaultCompareItems(const A, B: Integer) : Integer; override; { }
end;
function TMyVector.DefaultItemToString(const Item: Integer) : String;
begin
WriteStr(Result, Item);
end;
function TMyVector.DefaultCompareItems(const A, B: Integer) : Integer;
begin
Result := A  B;
end;
var
Vect : TMyVector;
I, J : Integer;
begin
Randomize;
Vect := TMyVector.Create;
for I := 1 to 10 do
begin
J := Random(20);
Vect.Append(J);
end;
WriteLn('Vect=', Vect.ToString);
Vect.Sort;
WriteLn('Vect=', Vect.ToString);
Vect.Shuffle;
WriteLn('Vect=', Vect.ToString);
for J in Vect do
Write(J, ' ');
WriteLn;
Vect.Free;
end.
DefaultItemToString is used by the ToString method to convert a vector item to a string.  
DefaultCompareItems is used to compare 2 items (A and B). The returned value should be negative if A < B, 0 if A = B and positive if A > B. 
To run this program use :
user$ fpc vectordemo user$ ./vectordemo
The result should be something like :
Vect=[9, 12, 15, 5, 7, 15, 9, 10, 14, 0] Vect=[0, 5, 7, 9, 9, 10, 12, 14, 15, 15] Vect=[12, 5, 15, 9, 7, 9, 0, 10, 14, 15] 12 5 15 9 7 9 0 10 14 15
Documentation for the latest version is available here.
The documentation can also be downloaded from the downloads section.
Version 0.2.8 for FPC 2.6.4
Source distribution 

Documentation 
Version 0.2.6 for FPC 2.6.4
Source distribution 

Documentation 
Version 0.2.4 for FPC 2.6.2 and 2.6.4
Source distribution 

Documentation 