diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 43bdc8f015faa59bc00523c1eac0b583ad9c996b..d8b6e85c266dcf6fb2142759b53e8b5e35e913aa 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
procedure clear (); inline;
procedure append (constref it: ItemT); inline;
procedure clear (); inline;
procedure append (constref it: ItemT); inline;
+ procedure delete (idx: Integer); inline;
+ function remove (idx: Integer): ItemT; inline;
public
property count: Integer read mCount;
public
property count: Integer read mCount;
procedure TSimpleList.append (constref it: ItemT); inline;
procedure TSimpleList.append (constref it: ItemT); inline;
+var
+ newsz: Integer;
begin
begin
- if (mCount = Length(mItems)) then
+ if (mCount >= Length(mItems)) then
begin
begin
- if (mCount = 0) then SetLength(mItems, 128) else SetLength(mItems, mCount*2);
+ newsz := mCount+(mCount div 3)+128;
+ SetLength(mItems, newsz);
end;
mItems[mCount] := it;
Inc(mCount);
end;
end;
mItems[mCount] := it;
Inc(mCount);
end;
+procedure TSimpleList.delete (idx: Integer); inline;
+var
+ f: Integer;
+begin
+ if (idx >= 0) and (idx < mCount) then
+ begin
+ for f := idx+1 to mCount-1 do mItems[f-1] := mItems[f];
+ end;
+end;
+
+
+function TSimpleList.remove (idx: Integer): ItemT; inline;
+var
+ f: Integer;
+begin
+ if (idx >= 0) and (idx < mCount) then
+ begin
+ result := mItems[idx];
+ for f := idx+1 to mCount-1 do mItems[f-1] := mItems[f];
+ end
+ else
+ begin
+ result := Default(ItemT);
+ end;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
var
wc2shitmap: array[0..65535] of AnsiChar;
// ////////////////////////////////////////////////////////////////////////// //
var
wc2shitmap: array[0..65535] of AnsiChar;