unit ZXIng.ByteSegments;
interface
type
///
/// implements the ByteSegments (which was declared as a TList>
/// throughout the code as reference-counted interface object)
///
IByteSegments = Interface
['{0994FC90-E8F5-40D8-8A48-9B05DFFF2635}']
function Count:integer;
procedure Clear;
function GetCapacity: integer;
procedure SetCapacity(const Value: integer);
property Capacity:integer read GetCapacity write SetCapacity;
function Add(const item:TArray):integer;
function Get(index: integer):TArray;
end;
function ByteSegmentsCreate:IByteSegments;
implementation
uses system.SysUtils,
Generics.Collections;
type
TByteSegments = class(TInterfacedObject,IByteSegments)
private
FList: TList>;
function Count:integer;
procedure Clear;
constructor Create;
function GetCapacity: integer;
procedure SetCapacity(const Value: integer);
function Add(const item:TArray):integer;
function Get(index: integer):TArray;
public
destructor Destroy; override;
end;
function ByteSegmentsCreate:IByteSegments;
begin
result := TByteSegments.Create;
end;
{ TByteSegments }
function TByteSegments.Add(const item: TArray): integer;
begin
result := FList.Add(item);
end;
procedure TByteSegments.Clear;
begin
FList.Clear;
end;
function TByteSegments.Count: integer;
begin
result := FList.Count;
end;
constructor TByteSegments.Create;
begin
FList := TList>.Create;
inherited Create;
end;
destructor TByteSegments.Destroy;
begin
FList.Free;
inherited;
end;
function TByteSegments.GetCapacity: integer;
begin
result := FList.Capacity;
end;
procedure TByteSegments.SetCapacity(const Value: integer);
begin
FList.Capacity := value;
end;
function TByteSegments.Get(index: Integer) : TArray;
begin
Result := FList[index];
end;
end.