Changeset 320


Ignore:
Timestamp:
Feb 7, 2012, 2:03:20 PM (13 years ago)
Author:
chronos
Message:
Location:
Generics/NativeGenerics
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • Generics/NativeGenerics/Demo

    • Property svn:ignore
      •  

        old new  
        11lib
         2backup
         3Demo.exe
         4heaptrclog.trc
  • Generics/NativeGenerics/Demo/Demo.lpi

    r313 r320  
    3838      </Item2>
    3939    </RequiredPackages>
    40     <Units Count="53">
     40    <Units Count="59">
    4141      <Unit0>
    4242        <Filename Value="Demo.lpr"/>
     
    5757        <EditorIndex Value="0"/>
    5858        <WindowIndex Value="0"/>
    59         <TopLine Value="694"/>
    60         <CursorPos X="36" Y="719"/>
     59        <TopLine Value="127"/>
     60        <CursorPos X="15" Y="47"/>
    6161        <UsageCount Value="233"/>
    6262        <Bookmarks Count="1">
    63           <Item0 X="65" Y="235" ID="2"/>
     63          <Item0 X="65" Y="234" ID="2"/>
    6464        </Bookmarks>
    6565        <Loaded Value="True"/>
     
    437437        <Filename Value="../Units/GenericList.pas"/>
    438438        <UnitName Value="GenericList"/>
    439         <EditorIndex Value="6"/>
    440         <WindowIndex Value="0"/>
    441         <TopLine Value="361"/>
    442         <CursorPos X="7" Y="374"/>
    443         <UsageCount Value="32"/>
     439        <EditorIndex Value="11"/>
     440        <WindowIndex Value="0"/>
     441        <TopLine Value="66"/>
     442        <CursorPos X="7" Y="21"/>
     443        <UsageCount Value="34"/>
    444444        <Loaded Value="True"/>
    445445      </Unit46>
     
    447447        <Filename Value="../Units/GenericMatrix.pas"/>
    448448        <UnitName Value="GenericMatrix"/>
    449         <EditorIndex Value="4"/>
    450         <WindowIndex Value="0"/>
    451         <TopLine Value="352"/>
    452         <CursorPos X="44" Y="365"/>
    453         <UsageCount Value="12"/>
    454         <Loaded Value="True"/>
     449        <WindowIndex Value="0"/>
     450        <TopLine Value="4"/>
     451        <CursorPos X="12" Y="11"/>
     452        <UsageCount Value="12"/>
    455453      </Unit47>
    456454      <Unit48>
    457455        <Filename Value="../Units/GenericStream.pas"/>
    458456        <UnitName Value="GenericStream"/>
    459         <EditorIndex Value="5"/>
    460         <WindowIndex Value="0"/>
    461         <TopLine Value="1"/>
    462         <CursorPos X="5" Y="12"/>
    463         <UsageCount Value="12"/>
     457        <IsVisibleTab Value="True"/>
     458        <EditorIndex Value="9"/>
     459        <WindowIndex Value="0"/>
     460        <TopLine Value="59"/>
     461        <CursorPos X="29" Y="67"/>
     462        <UsageCount Value="14"/>
    464463        <Loaded Value="True"/>
    465464      </Unit48>
     
    467466        <Filename Value="../Units/GenericQueue.pas"/>
    468467        <UnitName Value="GenericQueue"/>
    469         <EditorIndex Value="3"/>
    470         <WindowIndex Value="0"/>
    471         <TopLine Value="1"/>
    472         <CursorPos X="3" Y="11"/>
    473         <UsageCount Value="10"/>
     468        <EditorIndex Value="6"/>
     469        <WindowIndex Value="0"/>
     470        <TopLine Value="18"/>
     471        <CursorPos X="24" Y="28"/>
     472        <UsageCount Value="12"/>
    474473        <Loaded Value="True"/>
    475474      </Unit49>
     
    477476        <Filename Value="../Units/GenericDictionary.pas"/>
    478477        <UnitName Value="GenericDictionary"/>
    479         <EditorIndex Value="2"/>
    480         <WindowIndex Value="0"/>
    481         <TopLine Value="1"/>
    482         <CursorPos X="17" Y="16"/>
    483         <UsageCount Value="10"/>
     478        <EditorIndex Value="4"/>
     479        <WindowIndex Value="0"/>
     480        <TopLine Value="1"/>
     481        <CursorPos X="1" Y="1"/>
     482        <UsageCount Value="12"/>
    484483        <Loaded Value="True"/>
    485484      </Unit50>
    486485      <Unit51>
    487486        <Filename Value="../../../../../Lazarus/0.9.31_2.6.0/fpc/2.6.0/source/rtl/objpas/sysutils/sysunih.inc"/>
    488         <EditorIndex Value="1"/>
     487        <EditorIndex Value="3"/>
    489488        <WindowIndex Value="0"/>
    490489        <TopLine Value="9"/>
    491490        <CursorPos X="10" Y="22"/>
    492         <UsageCount Value="10"/>
    493         <Loaded Value="True"/>
     491        <UsageCount Value="12"/>
     492        <Loaded Value="True"/>
     493        <DefaultSyntaxHighlighter Value="Delphi"/>
    494494      </Unit51>
    495495      <Unit52>
    496496        <Filename Value="../Units/SpecializedList.pas"/>
    497497        <UnitName Value="SpecializedList"/>
    498         <IsVisibleTab Value="True"/>
     498        <EditorIndex Value="12"/>
     499        <WindowIndex Value="0"/>
     500        <TopLine Value="1"/>
     501        <CursorPos X="23" Y="11"/>
     502        <UsageCount Value="12"/>
     503        <Loaded Value="True"/>
     504      </Unit52>
     505      <Unit53>
     506        <Filename Value="../../../../../Lazarus/0.9.31_2.7.1/fpc/2.7.1/source/rtl/objpas/classes/classesh.inc"/>
     507        <EditorIndex Value="5"/>
     508        <WindowIndex Value="0"/>
     509        <TopLine Value="52"/>
     510        <CursorPos X="49" Y="65"/>
     511        <UsageCount Value="12"/>
     512        <Loaded Value="True"/>
     513      </Unit53>
     514      <Unit54>
     515        <Filename Value="../Units/GenericSet.pas"/>
     516        <UnitName Value="GenericSet"/>
    499517        <EditorIndex Value="7"/>
    500518        <WindowIndex Value="0"/>
    501         <TopLine Value="45"/>
    502         <CursorPos X="7" Y="60"/>
    503         <UsageCount Value="10"/>
    504         <Loaded Value="True"/>
    505       </Unit52>
     519        <TopLine Value="17"/>
     520        <CursorPos X="14" Y="33"/>
     521        <UsageCount Value="12"/>
     522        <Loaded Value="True"/>
     523      </Unit54>
     524      <Unit55>
     525        <Filename Value="../Units/GenericStack.pas"/>
     526        <UnitName Value="GenericStack"/>
     527        <EditorIndex Value="8"/>
     528        <WindowIndex Value="0"/>
     529        <TopLine Value="22"/>
     530        <CursorPos X="14" Y="38"/>
     531        <UsageCount Value="12"/>
     532        <Loaded Value="True"/>
     533      </Unit55>
     534      <Unit56>
     535        <Filename Value="../Units/GenericRange.pas"/>
     536        <UnitName Value="GenericRange"/>
     537        <EditorIndex Value="1"/>
     538        <WindowIndex Value="0"/>
     539        <TopLine Value="4"/>
     540        <CursorPos X="33" Y="8"/>
     541        <UsageCount Value="12"/>
     542        <Loaded Value="True"/>
     543      </Unit56>
     544      <Unit57>
     545        <Filename Value="../../../../../Lazarus/0.9.31_2.7.1/fpc/2.7.1/source/rtl/inc/systemh.inc"/>
     546        <EditorIndex Value="10"/>
     547        <WindowIndex Value="0"/>
     548        <TopLine Value="958"/>
     549        <CursorPos X="11" Y="971"/>
     550        <UsageCount Value="12"/>
     551        <Loaded Value="True"/>
     552      </Unit57>
     553      <Unit58>
     554        <Filename Value="../Units/GenericTree.pas"/>
     555        <UnitName Value="GenericTree"/>
     556        <EditorIndex Value="2"/>
     557        <WindowIndex Value="0"/>
     558        <TopLine Value="1"/>
     559        <CursorPos X="33" Y="8"/>
     560        <UsageCount Value="12"/>
     561        <Loaded Value="True"/>
     562      </Unit58>
    506563    </Units>
    507     <JumpHistory Count="30" HistoryIndex="29">
     564    <JumpHistory Count="30" HistoryIndex="28">
    508565      <Position1>
    509         <Filename Value="../Units/GenericList.pas"/>
    510         <Caret Line="423" Column="16" TopLine="402"/>
     566        <Filename Value="../Units/GenericStream.pas"/>
     567        <Caret Line="29" Column="42" TopLine="11"/>
    511568      </Position1>
    512569      <Position2>
    513         <Filename Value="../Units/GenericList.pas"/>
    514         <Caret Line="425" Column="7" TopLine="404"/>
     570        <Filename Value="../Units/GenericStream.pas"/>
     571        <Caret Line="39" Column="57" TopLine="26"/>
    515572      </Position2>
    516573      <Position3>
    517         <Filename Value="../Units/GenericList.pas"/>
    518         <Caret Line="437" Column="17" TopLine="416"/>
     574        <Filename Value="../Units/GenericStream.pas"/>
     575        <Caret Line="29" Column="19" TopLine="16"/>
    519576      </Position3>
    520577      <Position4>
    521         <Filename Value="../Units/GenericList.pas"/>
    522         <Caret Line="448" Column="43" TopLine="427"/>
     578        <Filename Value="../Units/GenericStream.pas"/>
     579        <Caret Line="16" Column="53" TopLine="7"/>
    523580      </Position4>
    524581      <Position5>
    525         <Filename Value="../Units/GenericList.pas"/>
    526         <Caret Line="455" Column="45" TopLine="434"/>
     582        <Filename Value="../Units/GenericStream.pas"/>
     583        <Caret Line="46" Column="19" TopLine="33"/>
    527584      </Position5>
    528585      <Position6>
    529         <Filename Value="../Units/GenericList.pas"/>
    530         <Caret Line="457" Column="7" TopLine="436"/>
     586        <Filename Value="../Units/GenericStream.pas"/>
     587        <Caret Line="34" Column="8" TopLine="24"/>
    531588      </Position6>
    532589      <Position7>
    533         <Filename Value="../Units/GenericList.pas"/>
    534         <Caret Line="466" Column="17" TopLine="445"/>
     590        <Filename Value="../Units/GenericStream.pas"/>
     591        <Caret Line="30" Column="19" TopLine="20"/>
    535592      </Position7>
    536593      <Position8>
    537         <Filename Value="../Units/GenericList.pas"/>
    538         <Caret Line="472" Column="40" TopLine="451"/>
     594        <Filename Value="../Units/GenericStream.pas"/>
     595        <Caret Line="41" Column="1" TopLine="33"/>
    539596      </Position8>
    540597      <Position9>
    541         <Filename Value="../Units/GenericList.pas"/>
    542         <Caret Line="481" Column="52" TopLine="460"/>
     598        <Filename Value="../Units/GenericStream.pas"/>
     599        <Caret Line="8" Column="13" TopLine="1"/>
    543600      </Position9>
    544601      <Position10>
    545         <Filename Value="../Units/GenericList.pas"/>
    546         <Caret Line="483" Column="7" TopLine="462"/>
     602        <Filename Value="../Units/GenericStream.pas"/>
     603        <Caret Line="29" Column="58" TopLine="14"/>
    547604      </Position10>
    548605      <Position11>
    549         <Filename Value="../Units/GenericList.pas"/>
    550         <Caret Line="492" Column="45" TopLine="471"/>
     606        <Filename Value="../Units/GenericStream.pas"/>
     607        <Caret Line="39" Column="1" TopLine="27"/>
    551608      </Position11>
    552609      <Position12>
    553         <Filename Value="../Units/GenericList.pas"/>
    554         <Caret Line="494" Column="7" TopLine="473"/>
     610        <Filename Value="../Units/GenericStream.pas"/>
     611        <Caret Line="29" Column="18" TopLine="6"/>
    555612      </Position12>
    556613      <Position13>
    557         <Filename Value="../Units/GenericList.pas"/>
    558         <Caret Line="503" Column="51" TopLine="482"/>
     614        <Filename Value="../Units/GenericStream.pas"/>
     615        <Caret Line="46" Column="23" TopLine="33"/>
    559616      </Position13>
    560617      <Position14>
    561         <Filename Value="../Units/GenericList.pas"/>
    562         <Caret Line="516" Column="9" TopLine="495"/>
     618        <Filename Value="../Units/GenericStream.pas"/>
     619        <Caret Line="66" Column="25" TopLine="53"/>
    563620      </Position14>
    564621      <Position15>
    565         <Filename Value="../Units/GenericList.pas"/>
    566         <Caret Line="518" Column="52" TopLine="504"/>
     622        <Filename Value="../Units/GenericStream.pas"/>
     623        <Caret Line="62" Column="29" TopLine="49"/>
    567624      </Position15>
    568625      <Position16>
    569         <Filename Value="../Units/GenericList.pas"/>
    570         <Caret Line="525" Column="17" TopLine="504"/>
     626        <Filename Value="../Units/GenericRange.pas"/>
     627        <Caret Line="1" Column="1" TopLine="1"/>
    571628      </Position16>
    572629      <Position17>
    573         <Filename Value="../Units/GenericList.pas"/>
    574         <Caret Line="531" Column="17" TopLine="510"/>
     630        <Filename Value="../Units/GenericTree.pas"/>
     631        <Caret Line="1" Column="1" TopLine="1"/>
    575632      </Position17>
    576633      <Position18>
    577         <Filename Value="../Units/GenericList.pas"/>
    578         <Caret Line="537" Column="17" TopLine="516"/>
     634        <Filename Value="../Units/GenericTree.pas"/>
     635        <Caret Line="8" Column="33" TopLine="1"/>
    579636      </Position18>
    580637      <Position19>
    581         <Filename Value="../Units/GenericList.pas"/>
    582         <Caret Line="551" Column="19" TopLine="530"/>
     638        <Filename Value="../Units/GenericRange.pas"/>
     639        <Caret Line="8" Column="33" TopLine="1"/>
    583640      </Position19>
    584641      <Position20>
    585         <Filename Value="../Units/GenericList.pas"/>
    586         <Caret Line="557" Column="18" TopLine="536"/>
     642        <Filename Value="../Units/GenericTree.pas"/>
     643        <Caret Line="8" Column="33" TopLine="1"/>
    587644      </Position20>
    588645      <Position21>
    589         <Filename Value="../Units/GenericList.pas"/>
    590         <Caret Line="563" Column="9" TopLine="542"/>
     646        <Filename Value="../Units/GenericStream.pas"/>
     647        <Caret Line="46" Column="23" TopLine="33"/>
    591648      </Position21>
    592649      <Position22>
    593         <Filename Value="../Units/GenericList.pas"/>
    594         <Caret Line="565" Column="52" TopLine="544"/>
     650        <Filename Value="../Units/GenericStream.pas"/>
     651        <Caret Line="86" Column="1" TopLine="61"/>
    595652      </Position22>
    596653      <Position23>
    597         <Filename Value="../Units/GenericList.pas"/>
    598         <Caret Line="571" Column="17" TopLine="550"/>
     654        <Filename Value="../Units/GenericStream.pas"/>
     655        <Caret Line="66" Column="18" TopLine="42"/>
    599656      </Position23>
    600657      <Position24>
    601         <Filename Value="../Units/GenericList.pas"/>
    602         <Caret Line="211" Column="7" TopLine="198"/>
     658        <Filename Value="../Units/GenericStream.pas"/>
     659        <Caret Line="46" Column="19" TopLine="33"/>
    603660      </Position24>
    604661      <Position25>
    605         <Filename Value="../Units/GenericList.pas"/>
    606         <Caret Line="221" Column="62" TopLine="200"/>
     662        <Filename Value="../Units/GenericStream.pas"/>
     663        <Caret Line="16" Column="53" TopLine="5"/>
    607664      </Position25>
    608665      <Position26>
    609         <Filename Value="../Units/GenericList.pas"/>
    610         <Caret Line="357" Column="7" TopLine="344"/>
     666        <Filename Value="../Units/GenericStream.pas"/>
     667        <Caret Line="45" Column="15" TopLine="34"/>
    611668      </Position26>
    612669      <Position27>
    613         <Filename Value="../Units/SpecializedList.pas"/>
    614         <Caret Line="1" Column="1" TopLine="1"/>
     670        <Filename Value="../Units/GenericStream.pas"/>
     671        <Caret Line="47" Column="18" TopLine="34"/>
    615672      </Position27>
    616673      <Position28>
    617         <Filename Value="../Units/SpecializedList.pas"/>
    618         <Caret Line="25" Column="7" TopLine="12"/>
     674        <Filename Value="../Units/GenericStream.pas"/>
     675        <Caret Line="20" Column="15" TopLine="7"/>
    619676      </Position28>
    620677      <Position29>
    621         <Filename Value="../Units/SpecializedList.pas"/>
    622         <Caret Line="34" Column="7" TopLine="21"/>
     678        <Filename Value="../Units/GenericStream.pas"/>
     679        <Caret Line="48" Column="18" TopLine="35"/>
    623680      </Position29>
    624681      <Position30>
    625         <Filename Value="../Units/SpecializedList.pas"/>
    626         <Caret Line="49" Column="7" TopLine="36"/>
     682        <Filename Value="../../../../../Lazarus/0.9.31_2.7.1/fpc/2.7.1/source/rtl/objpas/classes/classesh.inc"/>
     683        <Caret Line="65" Column="49" TopLine="52"/>
    627684      </Position30>
    628685    </JumpHistory>
  • Generics/NativeGenerics/Demo/UMainForm.pas

    r313 r320  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, GenericList, GenericDictionary, GenericQueue, GenericMatrix,
     9  ComCtrls, GenericList, GenericDictionary, GenericQueue,
    1010  DateUtils, SpecializedList;
    1111
     
    101101
    102102procedure TMainForm.ButtonMatrixIntegerClick(Sender: TObject);
    103 var
    104   Matrix: TGMatrix<Integer, Integer, Integer>;
    105   I: Integer;
    106 begin
    107   ListViewOutput.Clear;
     103//var
     104//  Matrix: TGMatrix<Integer, Integer, Integer>;
     105begin
     106  (*  ListViewOutput.Clear;
    108107  LabelTestName.Caption := 'TMatrixInteger test';
    109108  Matrix := TGMatrix<Integer, Integer, Integer>.Create;
     
    121120  finally
    122121    Free;
    123   end;
     122  end; *)
    124123end;
    125124
     
    130129
    131130procedure TMainForm.ButtonListObjectClick(Sender: TObject);
    132 var
    133   List: TGListObject<TObject>;
    134   I: Integer;
     131//var
     132  //List: TListObject<TObject>;
     133  //I: Integer;
    135134begin
    136135  (*ListViewOutput.Clear;
     
    182181
    183182procedure TMainForm.ButtonDictionaryStringClick(Sender: TObject);
    184 type
    185   TPairStringString = TGPair<String, String>;
    186 var
    187   Dictionary: TGDictionary<TPairStringString>;
     183//type
     184//  TPairStringString = TGPair<string, string>;
     185var
     186  Dictionary: TGDictionary<string, string>;
    188187begin
    189188  ListViewOutput.Clear;
    190189  LabelTestName.Caption := 'TDictionaryString test';
    191   Dictionary := TGDictionary<TPairStringString>.Create;
     190  Dictionary := TGDictionary<string, string>.Create;
    192191  with Dictionary do try
    193192    Add('Key1', 'Value1');
    194193    Add('Key2', 'Value2');
    195194    Add('Key3', 'Value3');
    196     WriteOutput('Add(''Key1'', ''Value1''),Add(''Key1'', ''Value1''),Add(''Key1'', ''Value1'')', Implode(',', StringPairToStr));
     195    WriteOutput('Add(''Key1'', ''Value1''),Add(''Key1'', ''Value1''),Add(''Key1'', ''Value1'')', List.Implode(',', StringPairToStr));
    197196    WriteOutput('Values[Key2]', Values['Key2']);
    198197    WriteOutput('Values[Key2] = None');
     
    392391
    393392procedure TMainForm.ButtonBenchmarkDictionaryClick(Sender: TObject);
    394 type
    395   TPairStringString = TGPair<String, String>;
    396 var
    397   Dictionary: TGDictionary<TPairStringString>;
     393//type
     394//  TPairStringString = TGPair<String, String>;
     395var
     396  Dictionary: TGDictionary<string, string>;
    398397  Dictionary2: TStringList;
    399398  StartTime: TDateTime;
     
    405404  try
    406405    UpdateButtonState(False);
    407     Dictionary := TGDictionary<TPairStringString>.Create;
     406    Dictionary := TGDictionary<string, string>.Create;
    408407    Dictionary2 := TStringList.Create;
    409408    Dictionary2.NameValueSeparator := '|';
     
    415414      I := I + 1;
    416415    until (Now - StartTime) > MeasureDuration;
    417     WriteOutput('TDictionaryStringString.Add', IntToStr(Dictionary.Count) + ' ops');
     416    WriteOutput('TDictionaryStringString.Add', IntToStr(Dictionary.List.Count) + ' ops');
    418417    Application.ProcessMessages;
    419418
     
    430429    StartTime := Now;
    431430    repeat
    432       R := Dictionary.Values[IntToStr(I mod Dictionary.Count)];
     431      R := Dictionary.Values[IntToStr(I mod Dictionary.List.Count)];
    433432      I := I + 1;
    434433    until (Now - StartTime) > MeasureDuration;
     
    448447    StartTime := Now;
    449448    repeat
    450       R := Dictionary.Keys[I mod Dictionary.Count];
     449      R := Dictionary.Keys[I mod Dictionary.List.Count];
    451450      I := I + 1;
    452451    until (Now - StartTime) > MeasureDuration;
     
    466465    StartTime := Now;
    467466    repeat
    468       R := Dictionary.Items[I mod Dictionary.Count].Value;
     467      R := Dictionary.List.Items[I mod Dictionary.List.Count].Value;
    469468      I := I + 1;
    470469    until (Now - StartTime) > MeasureDuration;
  • Generics/NativeGenerics/NativeGenerics.lpk

    r313 r320  
    2828    <License Value="GNU/GPL"/>
    2929    <Version Minor="1"/>
    30     <Files Count="11">
     30    <Files Count="10">
    3131      <Item1>
    3232        <Filename Value="ReadMe.txt"/>
     
    6262      </Item8>
    6363      <Item9>
    64         <Filename Value="Units\GenericMatrix.pas"/>
    65         <UnitName Value="GenericMatrix"/>
     64        <Filename Value="Units\GenericStream.pas"/>
     65        <UnitName Value="GenericStream"/>
    6666      </Item9>
    6767      <Item10>
    68         <Filename Value="Units\GenericStream.pas"/>
    69         <UnitName Value="GenericStream"/>
    70       </Item10>
    71       <Item11>
    7268        <Filename Value="Units\SpecializedList.pas"/>
    7369        <UnitName Value="SpecializedList"/>
    74       </Item11>
     70      </Item10>
    7571    </Files>
    7672    <Type Value="RunAndDesignTime"/>
  • Generics/NativeGenerics/NativeGenerics.pas

    r313 r320  
    33 }
    44
    5 unit NativeGenerics; 
     5unit NativeGenerics;
    66
    77interface
     
    99uses
    1010  GenericList, GenericTree, GenericDictionary, GenericQueue, GenericRange,
    11   GenericSet, GenericStack, GenericMatrix, GenericStream, SpecializedList,
    12   LazarusPackageIntf;
     11  GenericSet, GenericStack, GenericStream, SpecializedList, LazarusPackageIntf;
    1312
    1413implementation
    1514
    16 procedure Register; 
     15procedure Register;
    1716begin
    18 end; 
     17end;
    1918
    2019initialization
    21   RegisterPackage('NativeGenerics', @Register); 
     20  RegisterPackage('NativeGenerics', @Register);
    2221end.
  • Generics/NativeGenerics/Units/GenericDictionary.pas

    r132 r320  
    1414  end;
    1515
    16   TGDictionary<TPair> = class(TGList<TPair>)
     16  TGDictionary<TKey, TValue> = class
    1717  private
    1818  type
    19     TGDictionaryIndex = Integer;
     19    TIndex = NativeInt;
     20    TDictionaryPair = TGPair<TKey, TValue>;
    2021  var
    21     function GetKey(Index: TGDictionaryIndex): TPair.TKey;
    22     function GetValue(Key: TPair.TKey): TPair.TValue;
    23     procedure PutKey(Index: TGDictionaryIndex; const AValue: TPair.TKey);
    24     procedure PutValue(Key: TPair.TKey; const AValue: TPair.TValue);
     22    FList: TGList<TDictionaryPair>;
     23    function GetKey(Index: TIndex): TKey;
     24    function GetValue(Key: TKey): TValue;
     25    procedure PutKey(Index: TIndex; const AValue: TKey);
     26    procedure PutValue(Key: TKey; const AValue: TValue);
    2527  public
    26     function SearchKey(Key: TPair.TKey): TGDictionaryIndex;
    27     procedure Add(Key: TPair.TKey; Value: TPair.TValue);
    28     property Values[Index: TPair.TKey]: TPair.TValue
     28    constructor Create;
     29    destructor Destroy; override;
     30    function SearchKey(Key: TKey): TIndex;
     31    procedure Add(Key: TKey; Value: TValue);
     32    property Values[Index: TKey]: TValue
    2933      read GetValue write PutValue;
    30     property Keys[Index: TGDictionaryIndex]: TPair.TKey
     34    property Keys[Index: TIndex]: TKey
    3135      read GetKey write PutKey;
     36    property List: TGList<TDictionaryPair> read FList;
    3237  end;
    3338
     
    3540
    3641
    37 function TGDictionary<TPair>.GetKey(Index: TGDictionaryIndex): TPair.TKey;
     42constructor TGDictionary<TKey, TValue>.Create;
    3843begin
    39   Result := Items[Index].Key;
     44  FList := TGList<TDictionaryPair>.Create;
    4045end;
    4146
    42 function TGDictionary<TPair>.GetValue(Key: TPair.TKey): TPair.TValue;
     47destructor TGDictionary<TKey, TValue>.Destroy;
    4348begin
    44   Result := Items[SearchKey(Key)].Value;
     49  FList.Free;
    4550end;
    4651
    47 procedure TGDictionary<TPair>.PutKey(Index: TGDictionaryIndex;
    48   const AValue: TPair.TKey);
     52function TGDictionary<TKey, TValue>.GetKey(Index: TIndex): TKey;
     53begin
     54  Result := FList.Items[Index].Key;
     55end;
     56
     57function TGDictionary<TKey, TValue>.GetValue(Key: TKey): TValue;
     58begin
     59  Result := FList.Items[SearchKey(Key)].Value;
     60end;
     61
     62procedure TGDictionary<TKey, TValue>.PutKey(Index: TIndex;
     63  const AValue: TKey);
    4964var
    50   Item: TPair;
     65  Item: TDictionaryPair;
    5166begin
    5267  //Items[Index].Key := AValue;
    53   Item := Items[Index];
     68  Item := FList.Items[Index];
    5469  Item.Key := AValue;
    55   Items[Index] := Item;
     70  FList.Items[Index] := Item;
    5671end;
    5772
    58 procedure TGDictionary<TPair>.PutValue(Key: TPair.TKey;
    59   const AValue: TPair.TValue);
     73procedure TGDictionary<TKey, TValue>.PutValue(Key: TKey;
     74  const AValue: TValue);
    6075var
    61   Item: TPair;
    62   Index: TGDictionaryIndex;
     76  Item: TDictionaryPair;
     77  Index: TIndex;
    6378begin
    6479  //Items[SearchKey(Index)].Value := AValue;
    6580  Index := SearchKey(Key);
    66   Item := Items[Index];
     81  Item := FList.Items[Index];
    6782  Item.Value := AValue;
    68   Items[Index] := Item;
     83  FList.Items[Index] := Item;
    6984end;
    7085
    71 function TGDictionary<TPair>.SearchKey(Key: TPair.TKey): TGDictionaryIndex;
     86function TGDictionary<TKey, TValue>.SearchKey(Key: TKey): TIndex;
    7287begin
    7388  Result := 0;
    74   while Result < Count do begin
    75     if Items[Result].Key = Key then begin
     89  while Result < FList.Count do begin
     90    if FList.Items[Result].Key = Key then begin
    7691      Break;
    7792    end;
     
    8095end;
    8196
    82 procedure TGDictionary<TPair>.Add(Key: TPair.TKey; Value: TPair.TValue);
     97procedure TGDictionary<TKey, TValue>.Add(Key: TKey; Value: TValue);
    8398var
    84   NewPair: TPair;
     99  NewPair: TDictionaryPair;
    85100begin
    86101  NewPair.Key := Key;
    87102  NewPair.Value := Value;
    88   inherited Add(NewPair);
     103  FList.Add(NewPair);
    89104end;
    90105
  • Generics/NativeGenerics/Units/GenericList.pas

    r313 r320  
    3434    function Add(Item: TItem): TIndex;
    3535    procedure AddArray(Values: array of TItem);
    36     procedure AddList(List: TGList);
    37     procedure Assign(Source: TGList); virtual;
     36    procedure AddList(List: TGList<TItem>);
     37    procedure Assign(Source: TGList<TItem>); virtual;
    3838    procedure Clear; virtual;
    3939    procedure Delete(Index: TIndex); virtual;
    4040    procedure DeleteItems(Index, Count: TIndex);
    41     function EqualTo(List: TGList): Boolean;
     41    function EqualTo(List: TGList<TItem>): Boolean;
    4242    procedure Exchange(Index1, Index2: TIndex);
    4343    procedure Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1);
     
    4848    function Implode(Separator: string; Converter: TToStringConverter): string;
    4949    function IndexOf(Item: TItem; Start: TIndex = 0): TIndex;
    50     function IndexOfList(List: TGList; Start: TIndex = 0): TIndex;
     50    function IndexOfList(List: TGList<TItem>; Start: TIndex = 0): TIndex;
    5151    procedure Insert(Index: TIndex; Item: TItem);
    52     procedure InsertList(Index: TIndex; List: TGList);
     52    procedure InsertList(Index: TIndex; List: TGList<TItem>);
    5353    procedure InsertArray(Index: TIndex; Values: array of TItem);
    5454    procedure Move(CurIndex, NewIndex: TIndex);
     
    6464  end;
    6565
    66   TGListObject<TItem> = class(TGList<TItem>)
     66  TListObject<TItem> = class(TGList<TItem>)
    6767  private
    6868    procedure Put(Index: Integer; const AValue: TItem); override;
     
    7676  end;
    7777
    78   TGListString<TItem> = class(TGList<TItem>)
     78  TListString<TItem> = class(TGList<TItem>)
    7979  private
    8080  public
     
    9393  RtlConsts;
    9494
    95 { TGList }
     95{ TGList<TItem> }
    9696
    9797function TGList<TItem>.GetCapacity: TIndex;
     
    195195end;
    196196
    197 procedure TGList<TItem>.Assign(Source: TGList);
     197procedure TGList<TItem>.Assign(Source: TGList<TItem>);
    198198var
    199199  I: TIndex;
     
    239239end;
    240240
    241 procedure TGList<TItem>.InsertList(Index: TIndex; List: TGList);
     241procedure TGList<TItem>.InsertList(Index: TIndex; List: TGList<TItem>);
    242242var
    243243  I: TIndex;
     
    250250end;
    251251
    252 function TGList<TItem>.IndexOfList(List: TGList; Start: TIndex): TIndex;
     252function TGList<TItem>.IndexOfList(List: TGList<TItem>; Start: TIndex): TIndex;
    253253var
    254254  I: TIndex;
     
    353353end;
    354354
    355 function TGList<TItem>.EqualTo(List: TGList): Boolean;
     355function TGList<TItem>.EqualTo(List: TGList<TItem>): Boolean;
    356356var
    357357  I: TIndex;
     
    453453end;
    454454
    455 procedure TGList<TItem>.AddList(List: TGList);
     455procedure TGList<TItem>.AddList(List: TGList<TItem>);
    456456var
    457457  I: TIndex;
     
    514514end;
    515515
    516 { TGListObject }
    517 
    518 procedure TGListObject<TItem>.Assign(Source: TGList<TItem>);
     516{ TListObject }
     517
     518procedure TListObject<TItem>.Assign(Source: TGList<TItem>);
    519519begin
    520520  Clear;
     
    523523end;
    524524
    525 procedure TGListObject<TItem>.Put(Index: Integer; const AValue: TItem);
     525procedure TListObject<TItem>.Put(Index: Integer; const AValue: TItem);
    526526begin
    527527  if OwnsObjects then FItems[Index].Free;
     
    529529end;
    530530
    531 procedure TGListObject<TItem>.Delete(Index: Integer);
     531procedure TListObject<TItem>.Delete(Index: Integer);
    532532begin
    533533  if OwnsObjects then FItems[Index].Free;
     
    535535end;
    536536
    537 procedure TGListObject<TItem>.Clear;
     537procedure TListObject<TItem>.Clear;
    538538var
    539539  I: Integer;
     
    549549end;
    550550
    551 constructor TGListObject<TItem>.Create;
     551constructor TListObject<TItem>.Create;
    552552begin
    553553  inherited;
     
    555555end;
    556556
    557 destructor TGListObject<TItem>.Destroy;
     557destructor TListObject<TItem>.Destroy;
    558558begin
    559559  Clear;
     
    561561end;
    562562
    563 { TGListString }
    564 
    565 procedure TGListString<TItem>.Assign(Source: TGList<TItem>);
     563{ TListString }
     564
     565procedure TListString<TItem>.Assign(Source: TGList<TItem>);
    566566begin
    567567  Clear;
     
    569569end;
    570570
    571 procedure TGListString<TItem>.Delete(Index: Integer);
     571procedure TListString<TItem>.Delete(Index: Integer);
    572572begin
    573573  FItems[Index] := '';
     
    575575end;
    576576
    577 procedure TGListString<TItem>.Clear;
     577procedure TListString<TItem>.Clear;
    578578var
    579579  I: Integer;
     
    587587end;
    588588
    589 constructor TGListString<TItem>.Create;
     589constructor TListString<TItem>.Create;
    590590begin
    591591  inherited;
    592592end;
    593593
    594 destructor TGListString<TItem>.Destroy;
     594destructor TListString<TItem>.Destroy;
    595595begin
    596596  Clear;
  • Generics/NativeGenerics/Units/GenericQueue.pas

    r132 r320  
    1111  TGQueue<TItem> = class
    1212  private
    13   type
    14     TGQueueList = TGList<TItem>;
    1513  var
    16     FList: TGQueueList;
     14    FList: TGList<TItem>;
    1715  public
    1816    procedure Enqueue(Value: TItem);
     
    2119    constructor Create;
    2220    destructor Destroy; override;
    23     property List: TGQueueList read FList;
     21    property List: TGList<TItem> read FList;
    2422  end;
    2523
     
    4038constructor TGQueue<TItem>.Create;
    4139begin
    42   FList := TGList.Create;
     40  FList := TGList<TItem>.Create;
    4341end;
    4442
  • Generics/NativeGenerics/Units/GenericSet.pas

    r132 r320  
    1111  TGSet<TItem> = class
    1212  private
    13   type
    14     TGSetList = TGList<TItem>;
    1513  var
    16     FList: TGSetList;
     14    FList: TGList<TItem>;
    1715  public
    1816    function IsIn(Item: TItem): Boolean;
    1917    constructor Create;
    2018    destructor Destroy; override;
    21     property List: TGSetList read FList;
     19    property List: TGList<TItem> read FList;
    2220  end;
    2321
     
    3331constructor TGSet<TItem>.Create;
    3432begin
    35   FList := TGList.Create;
     33  FList := TGList<TItem>.Create;
    3634end;
    3735
  • Generics/NativeGenerics/Units/GenericStack.pas

    r132 r320  
    1111  TGStack<TItem> = class
    1212  private
    13   type
    14     TGStackList = TGList<TItem>;
    1513  var
    16     FList: TGStackList;
     14    FList: TGList<TItem>;
    1715  public
    1816    procedure Push(Value: TItem);
     
    2018    constructor Create;
    2119    destructor Destroy; override;
    22     property List: TGStackList read FList;
     20    property List: TGList<TItem> read FList;
    2321  end;
    2422
     
    3836constructor TGStack<TItem>.Create;
    3937begin
    40   FList := TGList.Create;
     38  FList := TGList<TItem>.Create;
    4139end;
    4240
  • Generics/NativeGenerics/Units/GenericStream.pas

    r313 r320  
    11unit GenericStream;
    22
    3 {$mode Delphi}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils;
     8  SysUtils, Classes, GenericList;
    99
    1010type
    1111  TGStream<TItem> = class
     12  public
     13    type
     14      TIndex = NativeInt;
     15      TItemArray = array of TItem;
     16      TSeekOrigin = (soBeginning, soCurrent, soEnd);
     17  private
     18    procedure SetSize(AValue: TIndex);
     19    function GetSize: TIndex;
     20    procedure SetPosition(AValue: TIndex);
     21    function GetPosition: TIndex;
     22  public
     23    procedure Assign(Source: TGStream<TItem>); virtual;
     24    procedure Write(Item: TItem); virtual; abstract;
     25    procedure WriteArray(Item: array of TItem); virtual; abstract;
     26    function Read: TItem; virtual; abstract;
     27    function ReadArray(Count: TIndex): TItemArray; virtual; abstract;
     28    function Insert(Count: TIndex): TIndex; virtual; abstract;
     29    function Remove(Count: TIndex): TIndex; virtual; abstract;
     30    function Seek(Offset: TIndex; Origin: TSeekOrigin = soCurrent):
     31      TIndex; virtual; abstract;
     32    constructor Create; virtual;
     33    property Position: TIndex read GetPosition write SetPosition;
     34    property Size: TIndex read GetSize write SetSize;
     35  end;
    1236
    13   end;
    1437
    1538implementation
    1639
     40
     41procedure TGStream<TItem>.Assign(Source: TGStream<TItem>);
     42begin
     43end;
     44
     45procedure TGStream<TItem>.SetPosition(AValue: TIndex);
     46begin
     47  Seek(AValue, soBeginning);
     48end;
     49
     50function TGStream<TItem>.GetPosition: TIndex;
     51begin
     52  Result := Seek(0, soCurrent);
     53end;
     54
     55procedure TGStream<TItem>.SetSize(AValue: TIndex);
     56var
     57  StreamSize: TIndex;
     58  OldPosition: TIndex;
     59begin
     60  OldPosition := Seek(0, soCurrent);
     61  StreamSize := Size;
     62  if AValue > StreamSize then begin
     63    Seek(StreamSize, soBeginning);
     64    Insert(AValue - StreamSize);
     65  end else
     66  if AValue < StreamSize then begin
     67    Seek(AValue, soBeginning);
     68    Remove(StreamSize - AValue);
     69  end;
     70  Position := OldPosition;
     71end;
     72
     73function TGStream<TItem>.GetSize: TIndex;
     74var
     75  OldPosition: Integer;
     76begin
     77  OldPosition := Position;
     78  Result := Seek(0, soEnd);
     79  Position := OldPosition;
     80end;
     81
     82constructor TGStream<TItem>.Create;
     83begin
     84  inherited;
     85end;
     86
    1787end.
    18 
Note: See TracChangeset for help on using the changeset viewer.