Changeset 76


Ignore:
Timestamp:
Oct 29, 2010, 7:49:29 AM (14 years ago)
Author:
george
Message:
  • Added: Partial generic set implementation.
  • Modified: TGStack, TGQueue and TGSet owns TGList instead of inherits.
  • Added: TList and TListPointer benchmark comparasion.
Location:
Generics/TemplateGenerics
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Demo

    • Property svn:ignore
      •  

        old new  
        11lib
         2Demo.exe
  • Generics/TemplateGenerics/Demo/Demo.lpi

    r74 r76  
    3838      </Item2>
    3939    </RequiredPackages>
    40     <Units Count="47">
     40    <Units Count="53">
    4141      <Unit0>
    4242        <Filename Value="Demo.lpr"/>
    4343        <IsPartOfProject Value="True"/>
    4444        <UnitName Value="Demo"/>
    45         <UsageCount Value="37"/>
     45        <EditorIndex Value="4"/>
     46        <WindowIndex Value="0"/>
     47        <TopLine Value="1"/>
     48        <CursorPos X="34" Y="7"/>
     49        <UsageCount Value="39"/>
     50        <Loaded Value="True"/>
    4651        <DefaultSyntaxHighlighter Value="Delphi"/>
    4752      </Unit0>
     
    5459        <EditorIndex Value="0"/>
    5560        <WindowIndex Value="0"/>
    56         <TopLine Value="132"/>
    57         <CursorPos X="11" Y="150"/>
    58         <UsageCount Value="37"/>
     61        <TopLine Value="257"/>
     62        <CursorPos X="38" Y="10"/>
     63        <UsageCount Value="39"/>
    5964        <Loaded Value="True"/>
    6065        <LoadedDesigner Value="True"/>
     
    201206        <Filename Value="../Specialized/ListDouble.pas"/>
    202207        <UnitName Value="ListDouble"/>
    203         <EditorIndex Value="1"/>
     208        <EditorIndex Value="8"/>
    204209        <WindowIndex Value="0"/>
    205210        <TopLine Value="1"/>
    206211        <CursorPos X="12" Y="21"/>
    207         <UsageCount Value="17"/>
     212        <UsageCount Value="18"/>
    208213        <Loaded Value="True"/>
    209214      </Unit19>
     
    211216        <Filename Value="../Specialized/ListInteger.pas"/>
    212217        <UnitName Value="ListInteger"/>
    213         <EditorIndex Value="2"/>
     218        <EditorIndex Value="9"/>
    214219        <WindowIndex Value="0"/>
    215220        <TopLine Value="1"/>
    216221        <CursorPos X="23" Y="21"/>
    217         <UsageCount Value="17"/>
     222        <UsageCount Value="18"/>
    218223        <Loaded Value="True"/>
    219224      </Unit20>
     
    221226        <Filename Value="../Specialized/ListObject.pas"/>
    222227        <UnitName Value="ListObject"/>
    223         <EditorIndex Value="3"/>
     228        <EditorIndex Value="10"/>
    224229        <WindowIndex Value="0"/>
    225230        <TopLine Value="2"/>
    226231        <CursorPos X="1" Y="33"/>
    227         <UsageCount Value="17"/>
     232        <UsageCount Value="18"/>
    228233        <Loaded Value="True"/>
    229234      </Unit21>
     
    231236        <Filename Value="../Specialized/ListPointer.pas"/>
    232237        <UnitName Value="ListPointer"/>
    233         <EditorIndex Value="4"/>
     238        <EditorIndex Value="11"/>
    234239        <WindowIndex Value="0"/>
    235240        <TopLine Value="1"/>
    236241        <CursorPos X="23" Y="21"/>
    237         <UsageCount Value="17"/>
     242        <UsageCount Value="18"/>
    238243        <Loaded Value="True"/>
    239244      </Unit22>
     
    241246        <Filename Value="../Specialized/TreeString.pas"/>
    242247        <UnitName Value="TreeString"/>
    243         <EditorIndex Value="5"/>
     248        <EditorIndex Value="12"/>
    244249        <WindowIndex Value="0"/>
    245250        <TopLine Value="1"/>
    246251        <CursorPos X="23" Y="24"/>
    247         <UsageCount Value="17"/>
     252        <UsageCount Value="18"/>
    248253        <Loaded Value="True"/>
    249254      </Unit23>
     
    251256        <Filename Value="../Specialized/TreePointer.pas"/>
    252257        <UnitName Value="TreePointer"/>
    253         <EditorIndex Value="6"/>
     258        <EditorIndex Value="13"/>
    254259        <WindowIndex Value="0"/>
    255260        <TopLine Value="1"/>
    256261        <CursorPos X="23" Y="13"/>
    257         <UsageCount Value="17"/>
     262        <UsageCount Value="18"/>
    258263        <Loaded Value="True"/>
    259264      </Unit24>
     
    261266        <Filename Value="../Specialized/TreeObject.pas"/>
    262267        <UnitName Value="TreeObject"/>
    263         <EditorIndex Value="7"/>
     268        <EditorIndex Value="14"/>
    264269        <WindowIndex Value="0"/>
    265270        <TopLine Value="1"/>
    266271        <CursorPos X="23" Y="24"/>
    267         <UsageCount Value="17"/>
     272        <UsageCount Value="18"/>
    268273        <Loaded Value="True"/>
    269274      </Unit25>
     
    271276        <Filename Value="../Specialized/TreeInteger.pas"/>
    272277        <UnitName Value="TreeInteger"/>
    273         <EditorIndex Value="8"/>
     278        <EditorIndex Value="15"/>
    274279        <WindowIndex Value="0"/>
    275280        <TopLine Value="1"/>
    276281        <CursorPos X="1" Y="27"/>
    277         <UsageCount Value="17"/>
     282        <UsageCount Value="18"/>
    278283        <Loaded Value="True"/>
    279284      </Unit26>
     
    281286        <Filename Value="../Specialized/ListString.pas"/>
    282287        <UnitName Value="ListString"/>
    283         <EditorIndex Value="17"/>
     288        <EditorIndex Value="24"/>
    284289        <WindowIndex Value="0"/>
    285290        <TopLine Value="1"/>
    286291        <CursorPos X="29" Y="17"/>
    287         <UsageCount Value="17"/>
     292        <UsageCount Value="18"/>
    288293        <Loaded Value="True"/>
    289294      </Unit27>
    290295      <Unit28>
    291296        <Filename Value="../Generic/TreeImplementation.tpl"/>
    292         <EditorIndex Value="9"/>
     297        <EditorIndex Value="16"/>
    293298        <WindowIndex Value="0"/>
    294299        <TopLine Value="1"/>
    295300        <CursorPos X="1" Y="2"/>
    296         <UsageCount Value="17"/>
     301        <UsageCount Value="18"/>
    297302        <Loaded Value="True"/>
    298303        <DefaultSyntaxHighlighter Value="None"/>
     
    300305      <Unit29>
    301306        <Filename Value="../Generic/TreeInterface.tpl"/>
    302         <EditorIndex Value="16"/>
     307        <EditorIndex Value="23"/>
    303308        <WindowIndex Value="0"/>
    304309        <TopLine Value="1"/>
    305310        <CursorPos X="40" Y="11"/>
    306         <UsageCount Value="17"/>
     311        <UsageCount Value="18"/>
    307312        <Loaded Value="True"/>
    308313        <DefaultSyntaxHighlighter Value="None"/>
     
    310315      <Unit30>
    311316        <Filename Value="../Generic/ListInterface.tpl"/>
    312         <EditorIndex Value="19"/>
    313         <WindowIndex Value="0"/>
    314         <TopLine Value="16"/>
    315         <CursorPos X="1" Y="28"/>
    316         <UsageCount Value="17"/>
     317        <EditorIndex Value="25"/>
     318        <WindowIndex Value="0"/>
     319        <TopLine Value="22"/>
     320        <CursorPos X="14" Y="35"/>
     321        <UsageCount Value="18"/>
    317322        <Loaded Value="True"/>
    318323        <DefaultSyntaxHighlighter Value="None"/>
     
    320325      <Unit31>
    321326        <Filename Value="../Generic/ListImplementation.tpl"/>
    322         <EditorIndex Value="23"/>
    323         <WindowIndex Value="0"/>
    324         <TopLine Value="288"/>
    325         <CursorPos X="17" Y="305"/>
    326         <UsageCount Value="17"/>
     327        <EditorIndex Value="27"/>
     328        <WindowIndex Value="0"/>
     329        <TopLine Value="111"/>
     330        <CursorPos X="3" Y="113"/>
     331        <UsageCount Value="18"/>
    327332        <Loaded Value="True"/>
    328333        <DefaultSyntaxHighlighter Value="None"/>
     
    330335      <Unit32>
    331336        <Filename Value="../Generic/DictionaryImplementation.tpl"/>
    332         <EditorIndex Value="10"/>
     337        <EditorIndex Value="17"/>
    333338        <WindowIndex Value="0"/>
    334339        <TopLine Value="23"/>
    335340        <CursorPos X="1" Y="2"/>
    336         <UsageCount Value="17"/>
     341        <UsageCount Value="18"/>
    337342        <Loaded Value="True"/>
    338343        <DefaultSyntaxHighlighter Value="None"/>
     
    340345      <Unit33>
    341346        <Filename Value="../Generic/DictionaryInterface.tpl"/>
    342         <EditorIndex Value="14"/>
     347        <EditorIndex Value="21"/>
    343348        <WindowIndex Value="0"/>
    344349        <TopLine Value="1"/>
    345350        <CursorPos X="1" Y="9"/>
    346         <UsageCount Value="17"/>
     351        <UsageCount Value="18"/>
    347352        <Loaded Value="True"/>
    348353        <DefaultSyntaxHighlighter Value="None"/>
     
    351356        <Filename Value="../Specialized/DictionaryString.pas"/>
    352357        <UnitName Value="DictionaryString"/>
    353         <EditorIndex Value="15"/>
     358        <EditorIndex Value="22"/>
    354359        <WindowIndex Value="0"/>
    355360        <TopLine Value="1"/>
    356361        <CursorPos X="32" Y="18"/>
    357         <UsageCount Value="17"/>
     362        <UsageCount Value="18"/>
    358363        <Loaded Value="True"/>
    359364      </Unit34>
    360365      <Unit35>
    361366        <Filename Value="../Generic/StackInterface.tpl"/>
    362         <EditorIndex Value="11"/>
    363         <WindowIndex Value="0"/>
    364         <TopLine Value="1"/>
    365         <CursorPos X="30" Y="11"/>
    366         <UsageCount Value="15"/>
     367        <EditorIndex Value="18"/>
     368        <WindowIndex Value="0"/>
     369        <TopLine Value="1"/>
     370        <CursorPos X="42" Y="15"/>
     371        <UsageCount Value="16"/>
    367372        <Loaded Value="True"/>
    368373        <DefaultSyntaxHighlighter Value="None"/>
     
    371376        <Filename Value="../Specialized/StackString.pas"/>
    372377        <UnitName Value="StackString"/>
    373         <EditorIndex Value="12"/>
     378        <EditorIndex Value="19"/>
    374379        <WindowIndex Value="0"/>
    375380        <TopLine Value="1"/>
    376381        <CursorPos X="1" Y="22"/>
    377         <UsageCount Value="15"/>
     382        <UsageCount Value="16"/>
    378383        <Loaded Value="True"/>
    379384      </Unit36>
    380385      <Unit37>
    381386        <Filename Value="../Generic/StackImplementation.tpl"/>
    382         <EditorIndex Value="13"/>
    383         <WindowIndex Value="0"/>
    384         <TopLine Value="1"/>
    385         <CursorPos X="16" Y="12"/>
    386         <UsageCount Value="15"/>
     387        <EditorIndex Value="20"/>
     388        <WindowIndex Value="0"/>
     389        <TopLine Value="1"/>
     390        <CursorPos X="32" Y="12"/>
     391        <UsageCount Value="16"/>
    387392        <Loaded Value="True"/>
    388393        <DefaultSyntaxHighlighter Value="None"/>
     
    390395      <Unit38>
    391396        <Filename Value="../Generic/QueueImplementation.tpl"/>
    392         <EditorIndex Value="27"/>
    393         <WindowIndex Value="0"/>
    394         <TopLine Value="1"/>
    395         <CursorPos X="1" Y="17"/>
    396         <UsageCount Value="15"/>
     397        <EditorIndex Value="28"/>
     398        <WindowIndex Value="0"/>
     399        <TopLine Value="1"/>
     400        <CursorPos X="33" Y="28"/>
     401        <UsageCount Value="16"/>
    397402        <Loaded Value="True"/>
    398403        <DefaultSyntaxHighlighter Value="None"/>
     
    400405      <Unit39>
    401406        <Filename Value="../Generic/QueueInterface.tpl"/>
    402         <EditorIndex Value="28"/>
    403         <WindowIndex Value="0"/>
    404         <TopLine Value="1"/>
    405         <CursorPos X="14" Y="11"/>
    406         <UsageCount Value="15"/>
     407        <EditorIndex Value="29"/>
     408        <WindowIndex Value="0"/>
     409        <TopLine Value="1"/>
     410        <CursorPos X="18" Y="14"/>
     411        <UsageCount Value="16"/>
    407412        <Loaded Value="True"/>
    408413        <DefaultSyntaxHighlighter Value="None"/>
     
    410415      <Unit40>
    411416        <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysstrh.inc"/>
    412         <EditorIndex Value="24"/>
    413417        <WindowIndex Value="0"/>
    414418        <TopLine Value="60"/>
    415419        <CursorPos X="10" Y="77"/>
    416420        <UsageCount Value="14"/>
    417         <Loaded Value="True"/>
    418421        <DefaultSyntaxHighlighter Value="Delphi"/>
    419422      </Unit40>
    420423      <Unit41>
    421424        <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysstr.inc"/>
    422         <EditorIndex Value="25"/>
    423425        <WindowIndex Value="0"/>
    424426        <TopLine Value="89"/>
    425427        <CursorPos X="62" Y="98"/>
    426428        <UsageCount Value="11"/>
    427         <Loaded Value="True"/>
    428429        <DefaultSyntaxHighlighter Value="Delphi"/>
    429430      </Unit41>
     
    431432        <Filename Value="../Specialized/ListChar.pas"/>
    432433        <UnitName Value="ListChar"/>
    433         <IsVisibleTab Value="True"/>
    434         <EditorIndex Value="20"/>
     434        <EditorIndex Value="26"/>
    435435        <WindowIndex Value="0"/>
    436436        <TopLine Value="49"/>
    437         <CursorPos X="10" Y="78"/>
    438         <UsageCount Value="14"/>
     437        <CursorPos X="24" Y="60"/>
     438        <UsageCount Value="15"/>
    439439        <Loaded Value="True"/>
    440440      </Unit42>
     
    442442        <Filename Value="/usr/share/fpcsrc/rtl/unix/sysutils.pp"/>
    443443        <UnitName Value="sysutils"/>
    444         <EditorIndex Value="18"/>
    445444        <WindowIndex Value="0"/>
    446445        <TopLine Value="1"/>
    447446        <CursorPos X="15" Y="8"/>
    448447        <UsageCount Value="11"/>
    449         <Loaded Value="True"/>
    450448        <DefaultSyntaxHighlighter Value="Delphi"/>
    451449      </Unit43>
    452450      <Unit44>
    453451        <Filename Value="/usr/share/fpcsrc/rtl/inc/systemh.inc"/>
    454         <EditorIndex Value="26"/>
    455452        <WindowIndex Value="0"/>
    456453        <TopLine Value="747"/>
    457454        <CursorPos X="11" Y="764"/>
    458455        <UsageCount Value="11"/>
    459         <Loaded Value="True"/>
    460456        <DefaultSyntaxHighlighter Value="Delphi"/>
    461457      </Unit44>
    462458      <Unit45>
    463459        <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysunih.inc"/>
    464         <EditorIndex Value="21"/>
    465460        <WindowIndex Value="0"/>
    466461        <TopLine Value="3"/>
    467462        <CursorPos X="10" Y="21"/>
    468463        <UsageCount Value="10"/>
    469         <Loaded Value="True"/>
    470464        <DefaultSyntaxHighlighter Value="Delphi"/>
    471465      </Unit45>
    472466      <Unit46>
    473467        <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysuni.inc"/>
    474         <EditorIndex Value="22"/>
    475468        <WindowIndex Value="0"/>
    476469        <TopLine Value="21"/>
    477470        <CursorPos X="5" Y="25"/>
    478471        <UsageCount Value="10"/>
    479         <Loaded Value="True"/>
    480472        <DefaultSyntaxHighlighter Value="Delphi"/>
    481473      </Unit46>
     474      <Unit47>
     475        <Filename Value="StopWatch.pas"/>
     476        <UnitName Value="StopWatch"/>
     477        <EditorIndex Value="7"/>
     478        <WindowIndex Value="0"/>
     479        <TopLine Value="12"/>
     480        <CursorPos X="67" Y="25"/>
     481        <UsageCount Value="11"/>
     482        <Loaded Value="True"/>
     483        <DefaultSyntaxHighlighter Value="Delphi"/>
     484      </Unit47>
     485      <Unit48>
     486        <Filename Value="../../../../../Programy/Lazarus/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/>
     487        <EditorIndex Value="5"/>
     488        <WindowIndex Value="0"/>
     489        <TopLine Value="203"/>
     490        <CursorPos X="15" Y="216"/>
     491        <UsageCount Value="11"/>
     492        <Loaded Value="True"/>
     493      </Unit48>
     494      <Unit49>
     495        <Filename Value="../../../../../Programy/Lazarus/fpc/2.4.3/source/rtl/objpas/classes/lists.inc"/>
     496        <EditorIndex Value="6"/>
     497        <WindowIndex Value="0"/>
     498        <TopLine Value="694"/>
     499        <CursorPos X="12" Y="696"/>
     500        <UsageCount Value="11"/>
     501        <Loaded Value="True"/>
     502      </Unit49>
     503      <Unit50>
     504        <Filename Value="../Generic/SetInterface.tpl"/>
     505        <EditorIndex Value="2"/>
     506        <WindowIndex Value="0"/>
     507        <TopLine Value="1"/>
     508        <CursorPos X="4" Y="12"/>
     509        <UsageCount Value="10"/>
     510        <Loaded Value="True"/>
     511        <DefaultSyntaxHighlighter Value="None"/>
     512      </Unit50>
     513      <Unit51>
     514        <Filename Value="../Specialized/SetChar.pas"/>
     515        <UnitName Value="SetChar"/>
     516        <IsVisibleTab Value="True"/>
     517        <EditorIndex Value="3"/>
     518        <WindowIndex Value="0"/>
     519        <TopLine Value="17"/>
     520        <CursorPos X="14" Y="39"/>
     521        <UsageCount Value="10"/>
     522        <Loaded Value="True"/>
     523      </Unit51>
     524      <Unit52>
     525        <Filename Value="../Generic/SetImplementation.tpl"/>
     526        <EditorIndex Value="1"/>
     527        <WindowIndex Value="0"/>
     528        <TopLine Value="1"/>
     529        <CursorPos X="1" Y="1"/>
     530        <UsageCount Value="10"/>
     531        <Loaded Value="True"/>
     532        <DefaultSyntaxHighlighter Value="None"/>
     533      </Unit52>
    482534    </Units>
    483     <JumpHistory Count="30" HistoryIndex="29">
     535    <JumpHistory Count="28" HistoryIndex="27">
    484536      <Position1>
    485         <Filename Value="../Specialized/ListChar.pas"/>
    486         <Caret Line="20" Column="15" TopLine="3"/>
     537        <Filename Value="UMainForm.pas"/>
     538        <Caret Line="34" Column="1" TopLine="21"/>
    487539      </Position1>
    488540      <Position2>
    489         <Filename Value="../Specialized/ListChar.pas"/>
    490         <Caret Line="32" Column="22" TopLine="14"/>
     541        <Filename Value="UMainForm.pas"/>
     542        <Caret Line="48" Column="1" TopLine="35"/>
    491543      </Position2>
    492544      <Position3>
    493         <Filename Value="../Specialized/ListChar.pas"/>
    494         <Caret Line="34" Column="20" TopLine="14"/>
     545        <Filename Value="UMainForm.pas"/>
     546        <Caret Line="185" Column="18" TopLine="161"/>
    495547      </Position3>
    496548      <Position4>
    497         <Filename Value="../Specialized/ListChar.pas"/>
    498         <Caret Line="8" Column="19" TopLine="1"/>
     549        <Filename Value="UMainForm.pas"/>
     550        <Caret Line="199" Column="17" TopLine="175"/>
    499551      </Position4>
    500552      <Position5>
    501         <Filename Value="../Specialized/ListChar.pas"/>
    502         <Caret Line="34" Column="24" TopLine="14"/>
     553        <Filename Value="../../../../../Programy/Lazarus/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/>
     554        <Caret Line="261" Column="16" TopLine="251"/>
    503555      </Position5>
    504556      <Position6>
    505         <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysstr.inc"/>
    506         <Caret Line="98" Column="11" TopLine="89"/>
     557        <Filename Value="../Generic/ListImplementation.tpl"/>
     558        <Caret Line="178" Column="9" TopLine="167"/>
    507559      </Position6>
    508560      <Position7>
    509         <Filename Value="../Specialized/ListChar.pas"/>
    510         <Caret Line="34" Column="17" TopLine="11"/>
     561        <Filename Value="UMainForm.pas"/>
     562        <Caret Line="216" Column="12" TopLine="196"/>
    511563      </Position7>
    512564      <Position8>
    513         <Filename Value="../Specialized/ListChar.pas"/>
    514         <Caret Line="32" Column="30" TopLine="15"/>
     565        <Filename Value="UMainForm.pas"/>
     566        <Caret Line="191" Column="15" TopLine="187"/>
    515567      </Position8>
    516568      <Position9>
    517         <Filename Value="../Specialized/ListChar.pas"/>
    518         <Caret Line="52" Column="16" TopLine="22"/>
     569        <Filename Value="UMainForm.pas"/>
     570        <Caret Line="223" Column="15" TopLine="208"/>
    519571      </Position9>
    520572      <Position10>
    521         <Filename Value="../Specialized/ListChar.pas"/>
    522         <Caret Line="23" Column="13" TopLine="8"/>
     573        <Filename Value="UMainForm.pas"/>
     574        <Caret Line="191" Column="15" TopLine="184"/>
    523575      </Position10>
    524576      <Position11>
    525         <Filename Value="../Generic/ListInterface.tpl"/>
    526         <Caret Line="28" Column="52" TopLine="11"/>
     577        <Filename Value="../Generic/ListImplementation.tpl"/>
     578        <Caret Line="166" Column="11" TopLine="156"/>
    527579      </Position11>
    528580      <Position12>
    529         <Filename Value="UMainForm.pas"/>
    530         <Caret Line="90" Column="1" TopLine="76"/>
     581        <Filename Value="../Generic/ListImplementation.tpl"/>
     582        <Caret Line="171" Column="12" TopLine="156"/>
    531583      </Position12>
    532584      <Position13>
    533         <Filename Value="UMainForm.pas"/>
    534         <Caret Line="92" Column="1" TopLine="78"/>
     585        <Filename Value="../Generic/ListImplementation.tpl"/>
     586        <Caret Line="160" Column="1" TopLine="155"/>
    535587      </Position13>
    536588      <Position14>
    537         <Filename Value="UMainForm.pas"/>
    538         <Caret Line="138" Column="1" TopLine="117"/>
     589        <Filename Value="../Generic/ListImplementation.tpl"/>
     590        <Caret Line="162" Column="1" TopLine="155"/>
    539591      </Position14>
    540592      <Position15>
    541         <Filename Value="UMainForm.pas"/>
    542         <Caret Line="9" Column="78" TopLine="1"/>
     593        <Filename Value="../Generic/ListImplementation.tpl"/>
     594        <Caret Line="164" Column="1" TopLine="155"/>
    543595      </Position15>
    544596      <Position16>
    545         <Filename Value="UMainForm.pas"/>
    546         <Caret Line="132" Column="1" TopLine="120"/>
     597        <Filename Value="../Generic/ListImplementation.tpl"/>
     598        <Caret Line="165" Column="1" TopLine="155"/>
    547599      </Position16>
    548600      <Position17>
    549         <Filename Value="UMainForm.pas"/>
    550         <Caret Line="145" Column="44" TopLine="125"/>
     601        <Filename Value="../Generic/ListImplementation.tpl"/>
     602        <Caret Line="166" Column="1" TopLine="155"/>
    551603      </Position17>
    552604      <Position18>
    553         <Filename Value="UMainForm.pas"/>
    554         <Caret Line="148" Column="23" TopLine="132"/>
     605        <Filename Value="../Generic/ListImplementation.tpl"/>
     606        <Caret Line="167" Column="1" TopLine="155"/>
    555607      </Position18>
    556608      <Position19>
    557609        <Filename Value="UMainForm.pas"/>
    558         <Caret Line="147" Column="11" TopLine="132"/>
     610        <Caret Line="193" Column="11" TopLine="163"/>
    559611      </Position19>
    560612      <Position20>
    561         <Filename Value="../Specialized/ListChar.pas"/>
    562         <Caret Line="64" Column="1" TopLine="47"/>
     613        <Filename Value="../Generic/ListImplementation.tpl"/>
     614        <Caret Line="166" Column="12" TopLine="155"/>
    563615      </Position20>
    564616      <Position21>
    565         <Filename Value="../Specialized/ListChar.pas"/>
    566         <Caret Line="65" Column="1" TopLine="47"/>
     617        <Filename Value="Demo.lpr"/>
     618        <Caret Line="1" Column="1" TopLine="1"/>
    567619      </Position21>
    568620      <Position22>
    569         <Filename Value="../Specialized/ListChar.pas"/>
    570         <Caret Line="59" Column="81" TopLine="47"/>
     621        <Filename Value="Demo.lpr"/>
     622        <Caret Line="18" Column="9" TopLine="1"/>
    571623      </Position22>
    572624      <Position23>
    573         <Filename Value="UMainForm.pas"/>
    574         <Caret Line="146" Column="13" TopLine="132"/>
     625        <Filename Value="../Generic/StackInterface.tpl"/>
     626        <Caret Line="14" Column="35" TopLine="1"/>
    575627      </Position23>
    576628      <Position24>
    577         <Filename Value="../Specialized/ListChar.pas"/>
    578         <Caret Line="64" Column="1" TopLine="47"/>
     629        <Filename Value="../Generic/StackImplementation.tpl"/>
     630        <Caret Line="12" Column="19" TopLine="1"/>
    579631      </Position24>
    580632      <Position25>
    581         <Filename Value="../Specialized/ListChar.pas"/>
    582         <Caret Line="65" Column="1" TopLine="47"/>
     633        <Filename Value="../Generic/QueueImplementation.tpl"/>
     634        <Caret Line="27" Column="1" TopLine="1"/>
    583635      </Position25>
    584636      <Position26>
    585         <Filename Value="../Specialized/ListChar.pas"/>
    586         <Caret Line="67" Column="1" TopLine="47"/>
     637        <Filename Value="UMainForm.pas"/>
     638        <Caret Line="250" Column="3" TopLine="225"/>
    587639      </Position26>
    588640      <Position27>
    589         <Filename Value="../Specialized/ListChar.pas"/>
    590         <Caret Line="68" Column="21" TopLine="47"/>
     641        <Filename Value="../Specialized/SetChar.pas"/>
     642        <Caret Line="1" Column="1" TopLine="1"/>
    591643      </Position27>
    592644      <Position28>
    593         <Filename Value="UMainForm.pas"/>
    594         <Caret Line="150" Column="11" TopLine="132"/>
     645        <Filename Value="../Specialized/SetChar.pas"/>
     646        <Caret Line="2" Column="1" TopLine="4"/>
    595647      </Position28>
    596       <Position29>
    597         <Filename Value="../Specialized/ListChar.pas"/>
    598         <Caret Line="68" Column="9" TopLine="49"/>
    599       </Position29>
    600       <Position30>
    601         <Filename Value="../Specialized/ListChar.pas"/>
    602         <Caret Line="78" Column="10" TopLine="49"/>
    603       </Position30>
    604648    </JumpHistory>
    605649  </ProjectOptions>
  • Generics/TemplateGenerics/Demo/UMainForm.lfm

    r74 r76  
    44  Top = 129
    55  Width = 478
    6   ActiveControl = ButtonIntegerList
    76  Caption = 'Template generics demo'
    87  ClientHeight = 397
     
    6665    TabOrder = 5
    6766  end
     67  object ButtonBenchmark: TButton
     68    Left = 10
     69    Height = 25
     70    Top = 350
     71    Width = 112
     72    Caption = 'Benchmark'
     73    OnClick = ButtonBenchmarkClick
     74    TabOrder = 6
     75  end
    6876end
  • Generics/TemplateGenerics/Demo/UMainForm.pas

    r74 r76  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, ListInteger, ListString, DictionaryString, QueueInteger, ListChar;
     9  ComCtrls, ListInteger, ListString, DictionaryString, QueueInteger, ListChar,
     10  ListPointer, DateUtils, ListVariant;
    1011
    1112type
     
    1415
    1516  TMainForm = class(TForm)
     17    ButtonBenchmark: TButton;
    1618    ButtonCharList: TButton;
    1719    ButtonQueueInteger: TButton;
     
    2022    ButtonStringList: TButton;
    2123    MemoOutput: TMemo;
     24    procedure ButtonBenchmarkClick(Sender: TObject);
    2225    procedure ButtonCharListClick(Sender: TObject);
    2326    procedure ButtonDictionaryStringClick(Sender: TObject);
     
    2831    procedure FormDestroy(Sender: TObject);
    2932  private
    30     { private declarations }
    3133  public
    3234    procedure WriteLn(Text: string);
     
    8688    Enqueue(2);
    8789    Enqueue(3);
    88     WriteLn('Implode: ' + Implode(',', IntToStr));
     90    WriteLn('Implode: ' + List.Implode(',', IntToStr));
    8991    WriteLn('Enqueue: 4');
    9092    Enqueue(4);
    91     WriteLn('Implode: ' + Implode(',', IntToStr));
     93    WriteLn('Implode: ' + List.Implode(',', IntToStr));
    9294    WriteLn('Dequeue: ' + IntToStr(Dequeue));
    93     WriteLn('Implode: ' + Implode(',', IntToStr));
     95    WriteLn('Implode: ' + List.Implode(',', IntToStr));
    9496  finally
    9597    Free;
     
    158160end;
    159161
     162procedure TMainForm.ButtonBenchmarkClick(Sender: TObject);
     163var
     164  List: TListPointer;
     165  List2: TList;
     166  StartTime: TDateTime;
     167  I: Integer;
     168begin
     169  MemoOutput.Clear;
     170  try
     171    List := TListPointer.Create;
     172    WriteLn('TListPointer...');
     173    StartTime := Now;
     174    repeat
     175      List.Add(1);
     176    until (Now - StartTime) > OneSecond;
     177    WriteLn('Add: ' + IntToStr(List.Count) + ' ops/sec');
     178    List.Clear;
     179
     180    StartTime := Now;
     181    repeat
     182      List.Insert(0, 1);
     183    until (Now - StartTime) > OneSecond;
     184    WriteLn('Insert: ' + IntToStr(List.Count) + ' ops/sec');
     185    List.Clear;
     186
     187    for I := 0 to 1000000 do
     188      List.Add(1);
     189    StartTime := Now;
     190    I := 0;
     191    repeat
     192      List.Delete(0);
     193      Inc(I);
     194    until (Now - StartTime) > OneSecond;
     195    WriteLn('Delete: ' + IntToStr(I) + ' ops/sec');
     196    List.Clear;
     197
     198    for I := 0 to 1000000 do
     199      List.Add(1);
     200    StartTime := Now;
     201    I := 0;
     202    repeat
     203      List.Move(300000, 700000);
     204      Inc(I);
     205    until (Now - StartTime) > OneSecond;
     206    WriteLn('Move: ' + IntToStr(I) + ' ops/sec');
     207    List.Clear;
     208
     209  finally
     210    List.Free;
     211  end;
     212
     213  try
     214    List2 := TList.Create;
     215    WriteLn('Test TList...');
     216    StartTime := Now;
     217    repeat
     218      List2.Add(1);
     219    until (Now - StartTime) > OneSecond;
     220    WriteLn('Add: ' + IntToStr(List2.Count) + ' ops/sec');
     221    List2.Clear;
     222
     223    StartTime := Now;
     224    repeat
     225      List2.Insert(0, 1);
     226    until (Now - StartTime) > OneSecond;
     227    WriteLn('Insert: ' + IntToStr(List2.Count) + ' ops/sec');
     228    List2.Clear;
     229
     230    for I := 0 to 1000000 do
     231      List2.Add(1);
     232    StartTime := Now;
     233    I := 0;
     234    repeat
     235      List2.Delete(0);
     236      Inc(I);
     237    until (Now - StartTime) > OneSecond;
     238    WriteLn('Delete: ' + IntToStr(I) + ' ops/sec');
     239
     240      for I := 0 to 1000000 do
     241      List2.Add(1);
     242    StartTime := Now;
     243    I := 0;
     244    repeat
     245      List2.Move(300000, 700000);
     246      Inc(I);
     247    until (Now - StartTime) > OneSecond;
     248    WriteLn('Move: ' + IntToStr(I) + ' ops/sec');
     249
     250  finally
     251    List2.Free;
     252  end;
     253end;
     254
    160255function StrToStr(Value: string): string;
    161256begin
  • Generics/TemplateGenerics/Generic/ListImplementation.tpl

    r74 r76  
    11uses
    22  RtlConsts;
    3 
    4 // Used instead of System.Move form because of error: Identifier "System" not found
    5 procedure SystemMove(const Source; var Dest; Count: SizeInt);
    6 begin
    7   Move(Source, Dest, Count);
    8 end;
    93
    104{ TGList }
     
    130124  if FCount = Capacity then Expand;
    131125  if Index < FCount then
    132     SystemMove(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TListItem));
     126    System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TListItem));
    133127  FItems[Index] := Item;
    134128  FCount := FCount + 1;
     
    163157    raise EListError.CreateFmt(SlistIndexError, [NewIndex]);
    164158  Temp := FItems[CurIndex];
    165   Delete(CurIndex);
    166   Insert(NewIndex, Temp);
     159  if NewIndex > CurIndex then begin
     160    System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(TListItem));
     161  end else
     162  if NewIndex < CurIndex then begin
     163    System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(TListItem));
     164  end;
     165  FItems[NewIndex] := Temp;
     166  //Delete(CurIndex);
     167  //Insert(NewIndex, Temp);
    167168end;
    168169
     
    289290    raise EListError.CreateFmt(SListIndexError, [Index]);
    290291  FCount := FCount - 1;
    291   SystemMove(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TListItem));
     292  System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TListItem));
    292293  // Shrink the list if appropriate
    293294  if (Capacity > 256) and (FCount < Capacity shr 2) then
  • Generics/TemplateGenerics/Generic/QueueImplementation.tpl

    r73 r76  
    55procedure TGQueue.Enqueue(Value: TQueueItem);
    66begin
    7   Add(Value);
     7  FList.Add(Value);
    88end;
    99
    1010function TGQueue.Peek: TQueueItem;
    1111begin
    12   Result := First;
     12  Result := FList.First;
     13end;
     14
     15constructor TGQueue.Create;
     16begin
     17  FList := TGList.Create;
     18end;
     19
     20destructor TGQueue.Destroy;
     21begin
     22  FList.Free;
     23  inherited Destroy;
    1324end;
    1425
    1526function TGQueue.Dequeue: TQueueItem;
    1627begin
    17   Result := Extract(First);
     28  Result := FList.Extract(FList.First);
    1829end;
    1930
  • Generics/TemplateGenerics/Generic/QueueInterface.tpl

    r73 r76  
    44  {$INCLUDE 'ListInterface.tpl'}
    55
    6   // TGQueue<TListIndex, TListItem> = class(TGList)
    7   TGQueue = class(TGList)
     6  // TGQueue<TSetIndex, TSetItem> = class(TGList)
     7  TGQueue = class
    88  private
     9    FList: TGList;
    910  public
    1011    procedure Enqueue(Value: TQueueItem);
    1112    function Dequeue: TQueueItem;
    1213    function Peek: TQueueItem;
     14    constructor Create;
     15    destructor Destroy; override;
     16    property List: TGList read FList;
    1317  end;
  • Generics/TemplateGenerics/Generic/StackImplementation.tpl

    r73 r76  
    55procedure TGStack.Push(Value: TStackItem);
    66begin
    7   Add(Value);
     7  FList.Add(Value);
    88end;
    99
    1010function TGStack.Pop: TStackItem;
    1111begin
    12   Result := Extract(Last);
     12  Result := FList.Extract(FList.Last);
    1313end;
    1414
     15constructor TGStack.Create;
     16begin
     17  FList := TGList.Create;
     18end;
     19
     20destructor TGStack.Destroy;
     21begin
     22  FList.Free;
     23  inherited Destroy;
     24end;
     25
  • Generics/TemplateGenerics/Generic/StackInterface.tpl

    r73 r76  
    44  {$INCLUDE 'ListInterface.tpl'}
    55
    6   // TGStack<TListIndex, TListItem> = class(TGList)
    7   TGStack = class(TGList)
     6  // TGStack<TStackIndex, TStackItem> = class(TGList)
     7  TGStack = class
    88  private
     9    FList: TGList;
    910  public
    1011    procedure Push(Value: TStackItem);
    1112    function Pop: TStackItem;
     13    constructor Create;
     14    destructor Destroy; override;
     15    property List: TGList read FList;
    1216  end;
  • Generics/TemplateGenerics/TemplateGenerics.lpk

    r74 r76  
    44    <PathDelim Value="\"/>
    55    <Name Value="TemplateGenerics"/>
     6    <Author Value="Chronos"/>
    67    <CompilerOptions>
    78      <Version Value="9"/>
     
    1516      </Other>
    1617    </CompilerOptions>
    17     <Files Count="31">
     18    <Version Minor="1"/>
     19    <Files Count="38">
    1820      <Item1>
    1921        <Filename Value="Generic\DictionaryImplementation.tpl"/>
     
    140142        <UnitName Value="ListChar"/>
    141143      </Item31>
     144      <Item32>
     145        <Filename Value="ReadMe.txt"/>
     146        <Type Value="Text"/>
     147      </Item32>
     148      <Item33>
     149        <Filename Value="Generic\SetImplementation.tpl"/>
     150        <Type Value="Text"/>
     151      </Item33>
     152      <Item34>
     153        <Filename Value="Generic\SetInterface.tpl"/>
     154        <Type Value="Text"/>
     155      </Item34>
     156      <Item35>
     157        <Filename Value="Specialized\ListVariant.pas"/>
     158        <UnitName Value="ListVariant"/>
     159      </Item35>
     160      <Item36>
     161        <Filename Value="Specialized\SetInteger.pas"/>
     162        <UnitName Value="SetInteger"/>
     163      </Item36>
     164      <Item37>
     165        <Filename Value="Specialized\SetString.pas"/>
     166        <UnitName Value="SetString"/>
     167      </Item37>
     168      <Item38>
     169        <Filename Value="Specialized\SetChar.pas"/>
     170        <UnitName Value="SetChar"/>
     171      </Item38>
    142172    </Files>
    143173    <Type Value="RunAndDesignTime"/>
  • Generics/TemplateGenerics/TemplateGenerics.pas

    r74 r76  
    1111  TreeObject, TreePointer, TreeString, DictionaryString, StackDouble,
    1212  StackInteger, StackObject, StackPointer, StackString, QueueDouble,
    13   QueueInteger, QueueObject, QueuePointer, QueueString, ListChar,
    14   LazarusPackageIntf;
     13  QueueInteger, QueueObject, QueuePointer, QueueString, ListChar, ListVariant,
     14  SetInteger, SetString, SetChar, LazarusPackageIntf;
    1515
    1616implementation
Note: See TracChangeset for help on using the changeset viewer.