- Timestamp:
- Oct 31, 2010, 3:14:23 PM (14 years ago)
- Location:
- Generics/TemplateGenerics
- Files:
-
- 6 added
- 26 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Demo/Demo.lpi
r83 r84 35 35 </Item2> 36 36 </RequiredPackages> 37 <Units Count=" 78">37 <Units Count="92"> 38 38 <Unit0> 39 39 <Filename Value="Demo.lpr"/> … … 43 43 <TopLine Value="1"/> 44 44 <CursorPos X="26" Y="8"/> 45 <UsageCount Value=" 56"/>45 <UsageCount Value="63"/> 46 46 <DefaultSyntaxHighlighter Value="Delphi"/> 47 47 </Unit0> … … 54 54 <EditorIndex Value="0"/> 55 55 <WindowIndex Value="0"/> 56 <TopLine Value=" 1"/>57 <CursorPos X=" 1" Y="12"/>58 <UsageCount Value=" 56"/>56 <TopLine Value="342"/> 57 <CursorPos X="51" Y="360"/> 58 <UsageCount Value="63"/> 59 59 <Loaded Value="True"/> 60 60 <LoadedDesigner Value="True"/> … … 201 201 <Filename Value="../Specialized/ListDouble.pas"/> 202 202 <UnitName Value="ListDouble"/> 203 <EditorIndex Value="2"/> 204 <WindowIndex Value="0"/> 205 <TopLine Value="1"/> 206 <CursorPos X="19" Y="13"/> 207 <UsageCount Value="25"/> 208 <Loaded Value="True"/> 203 <WindowIndex Value="0"/> 204 <TopLine Value="1"/> 205 <CursorPos X="1" Y="11"/> 206 <UsageCount Value="25"/> 209 207 </Unit19> 210 208 <Unit20> 211 <Filename Value="../Specialized/ ListInteger.pas"/>212 <UnitName Value=" ListInteger"/>213 <WindowIndex Value="0"/> 214 <TopLine Value=" 1"/>215 <CursorPos X=" 25" Y="17"/>209 <Filename Value="../Specialized/specializedlist.pas"/> 210 <UnitName Value="SpecializedList"/> 211 <WindowIndex Value="0"/> 212 <TopLine Value="3"/> 213 <CursorPos X="43" Y="13"/> 216 214 <UsageCount Value="25"/> 217 215 </Unit20> … … 615 613 <IsPartOfProject Value="True"/> 616 614 <UnitName Value="ListObject"/> 617 <EditorIndex Value=" 4"/>618 <WindowIndex Value="0"/> 619 <TopLine Value="1"/> 620 <CursorPos X=" 30" Y="23"/>621 <UsageCount Value="2 2"/>615 <EditorIndex Value="15"/> 616 <WindowIndex Value="0"/> 617 <TopLine Value="1"/> 618 <CursorPos X="15" Y="12"/> 619 <UsageCount Value="29"/> 622 620 <Loaded Value="True"/> 623 621 <DefaultSyntaxHighlighter Value="Delphi"/> … … 665 663 <Filename Value="../Specialized/StackDouble.pas"/> 666 664 <UnitName Value="StackDouble"/> 667 <EditorIndex Value="3"/>668 665 <WindowIndex Value="0"/> 669 666 <TopLine Value="1"/> 670 667 <CursorPos X="1" Y="1"/> 671 <UsageCount Value="10"/> 672 <Loaded Value="True"/> 668 <UsageCount Value="11"/> 673 669 </Unit76> 674 670 <Unit77> 675 671 <Filename Value="../Specialized/DictionaryStringString.pas"/> 676 672 <UnitName Value="DictionaryStringString"/> 673 <WindowIndex Value="0"/> 674 <TopLine Value="1"/> 675 <CursorPos X="2" Y="5"/> 676 <UsageCount Value="11"/> 677 </Unit77> 678 <Unit78> 679 <Filename Value="../Generic/GenericList.inc"/> 680 <EditorIndex Value="14"/> 681 <WindowIndex Value="0"/> 682 <TopLine Value="43"/> 683 <CursorPos X="32" Y="65"/> 684 <UsageCount Value="13"/> 685 <Loaded Value="True"/> 686 <DefaultSyntaxHighlighter Value="Delphi"/> 687 </Unit78> 688 <Unit79> 689 <Filename Value="../Specialized/SpecializedList.pas"/> 690 <UnitName Value="SpecializedList"/> 691 <EditorIndex Value="1"/> 692 <WindowIndex Value="0"/> 693 <TopLine Value="1"/> 694 <CursorPos X="1" Y="11"/> 695 <UsageCount Value="13"/> 696 <Loaded Value="True"/> 697 </Unit79> 698 <Unit80> 699 <Filename Value="../Generic/GenericDictionary.inc"/> 700 <EditorIndex Value="2"/> 701 <WindowIndex Value="0"/> 702 <TopLine Value="1"/> 703 <CursorPos X="1" Y="10"/> 704 <UsageCount Value="13"/> 705 <Loaded Value="True"/> 706 <DefaultSyntaxHighlighter Value="Delphi"/> 707 </Unit80> 708 <Unit81> 709 <Filename Value="../Generic/GenericObjectList.inc"/> 710 <EditorIndex Value="4"/> 711 <WindowIndex Value="0"/> 712 <TopLine Value="34"/> 713 <CursorPos X="8" Y="56"/> 714 <UsageCount Value="13"/> 715 <Loaded Value="True"/> 716 <DefaultSyntaxHighlighter Value="Delphi"/> 717 </Unit81> 718 <Unit82> 719 <Filename Value="../Generic/GenericQueue.inc"/> 720 <EditorIndex Value="7"/> 721 <WindowIndex Value="0"/> 722 <TopLine Value="1"/> 723 <CursorPos X="1" Y="3"/> 724 <UsageCount Value="13"/> 725 <Loaded Value="True"/> 726 <DefaultSyntaxHighlighter Value="Delphi"/> 727 </Unit82> 728 <Unit83> 729 <Filename Value="../Generic/GenericSet.inc"/> 730 <EditorIndex Value="12"/> 731 <WindowIndex Value="0"/> 732 <TopLine Value="1"/> 733 <CursorPos X="42" Y="11"/> 734 <UsageCount Value="13"/> 735 <Loaded Value="True"/> 736 <DefaultSyntaxHighlighter Value="Delphi"/> 737 </Unit83> 738 <Unit84> 739 <Filename Value="../Generic/GenericStack.inc"/> 740 <EditorIndex Value="11"/> 741 <WindowIndex Value="0"/> 742 <TopLine Value="1"/> 743 <CursorPos X="1" Y="3"/> 744 <UsageCount Value="13"/> 745 <Loaded Value="True"/> 746 <DefaultSyntaxHighlighter Value="Delphi"/> 747 </Unit84> 748 <Unit85> 749 <Filename Value="../Generic/GenericTree.inc"/> 750 <EditorIndex Value="13"/> 751 <WindowIndex Value="0"/> 752 <TopLine Value="1"/> 753 <CursorPos X="22" Y="30"/> 754 <UsageCount Value="13"/> 755 <Loaded Value="True"/> 756 <DefaultSyntaxHighlighter Value="Delphi"/> 757 </Unit85> 758 <Unit86> 759 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 760 <UnitName Value="SpecializedDictionary"/> 761 <EditorIndex Value="9"/> 762 <WindowIndex Value="0"/> 763 <TopLine Value="1"/> 764 <CursorPos X="1" Y="13"/> 765 <UsageCount Value="12"/> 766 <Loaded Value="True"/> 767 </Unit86> 768 <Unit87> 769 <Filename Value="../Specialized/SpecializedStack.pas"/> 770 <UnitName Value="SpecializedStack"/> 771 <EditorIndex Value="10"/> 772 <WindowIndex Value="0"/> 773 <TopLine Value="1"/> 774 <CursorPos X="1" Y="13"/> 775 <UsageCount Value="11"/> 776 <Loaded Value="True"/> 777 </Unit87> 778 <Unit88> 779 <Filename Value="../Specialized/SpecializedTree.pas"/> 780 <UnitName Value="SpecializedTree"/> 677 781 <IsVisibleTab Value="True"/> 678 <EditorIndex Value="1"/> 679 <WindowIndex Value="0"/> 680 <TopLine Value="1"/> 681 <CursorPos X="23" Y="26"/> 682 <UsageCount Value="10"/> 683 <Loaded Value="True"/> 684 </Unit77> 782 <EditorIndex Value="3"/> 783 <WindowIndex Value="0"/> 784 <TopLine Value="1"/> 785 <CursorPos X="1" Y="11"/> 786 <UsageCount Value="11"/> 787 <Loaded Value="True"/> 788 </Unit88> 789 <Unit89> 790 <Filename Value="../Generic/GenericRange.inc"/> 791 <EditorIndex Value="8"/> 792 <WindowIndex Value="0"/> 793 <TopLine Value="1"/> 794 <CursorPos X="1" Y="44"/> 795 <UsageCount Value="11"/> 796 <Loaded Value="True"/> 797 <DefaultSyntaxHighlighter Value="Delphi"/> 798 </Unit89> 799 <Unit90> 800 <Filename Value="../Specialized/SpecializedQueue.pas"/> 801 <UnitName Value="SpecializedQueue"/> 802 <EditorIndex Value="5"/> 803 <WindowIndex Value="0"/> 804 <TopLine Value="1"/> 805 <CursorPos X="1" Y="13"/> 806 <UsageCount Value="11"/> 807 <Loaded Value="True"/> 808 </Unit90> 809 <Unit91> 810 <Filename Value="../Specialized/SpecializedSet.pas"/> 811 <UnitName Value="SpecializedSet"/> 812 <EditorIndex Value="6"/> 813 <WindowIndex Value="0"/> 814 <TopLine Value="1"/> 815 <CursorPos X="1" Y="13"/> 816 <UsageCount Value="11"/> 817 <Loaded Value="True"/> 818 </Unit91> 685 819 </Units> 686 <JumpHistory Count=" 25" HistoryIndex="24">820 <JumpHistory Count="30" HistoryIndex="29"> 687 821 <Position1> 688 <Filename Value=" UMainForm.pas"/>689 <Caret Line=" 367" Column="1" TopLine="341"/>822 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 823 <Caret Line="22" Column="23" TopLine="1"/> 690 824 </Position1> 691 825 <Position2> 692 <Filename Value=" UMainForm.pas"/>693 <Caret Line=" 368" Column="1" TopLine="341"/>826 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 827 <Caret Line="19" Column="42" TopLine="1"/> 694 828 </Position2> 695 829 <Position3> 696 <Filename Value=" UMainForm.pas"/>697 <Caret Line=" 364" Column="18" TopLine="348"/>830 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 831 <Caret Line="18" Column="24" TopLine="1"/> 698 832 </Position3> 699 833 <Position4> 700 <Filename Value=" UMainForm.pas"/>701 <Caret Line=" 345" Column="5" TopLine="329"/>834 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 835 <Caret Line="19" Column="43" TopLine="1"/> 702 836 </Position4> 703 837 <Position5> 704 <Filename Value=" UMainForm.pas"/>705 <Caret Line="3 46" Column="14" TopLine="329"/>838 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 839 <Caret Line="39" Column="5" TopLine="3"/> 706 840 </Position5> 707 841 <Position6> 708 <Filename Value=" UMainForm.pas"/>709 <Caret Line=" 411" Column="23" TopLine="383"/>842 <Filename Value="../Specialized/SpecializedStack.pas"/> 843 <Caret Line="19" Column="36" TopLine="1"/> 710 844 </Position6> 711 845 <Position7> 712 <Filename Value=" UMainForm.pas"/>713 <Caret Line=" 407" Column="21" TopLine="383"/>846 <Filename Value="../Specialized/SpecializedStack.pas"/> 847 <Caret Line="5" Column="1" TopLine="1"/> 714 848 </Position7> 715 849 <Position8> 716 <Filename Value=" UMainForm.pas"/>717 <Caret Line=" 376" Column="19" TopLine="349"/>850 <Filename Value="../Generic/GenericStack.inc"/> 851 <Caret Line="28" Column="34" TopLine="13"/> 718 852 </Position8> 719 853 <Position9> 720 854 <Filename Value="UMainForm.pas"/> 721 <Caret Line=" 373" Column="8" TopLine="349"/>855 <Caret Line="9" Column="7" TopLine="1"/> 722 856 </Position9> 723 857 <Position10> 724 858 <Filename Value="UMainForm.pas"/> 725 <Caret Line=" 412" Column="1" TopLine="383"/>859 <Caret Line="10" Column="20" TopLine="1"/> 726 860 </Position10> 727 861 <Position11> 728 862 <Filename Value="UMainForm.pas"/> 729 <Caret Line=" 427" Column="24" TopLine="399"/>863 <Caret Line="20" Column="49" TopLine="1"/> 730 864 </Position11> 731 865 <Position12> 732 <Filename Value=" UMainForm.pas"/>733 <Caret Line=" 427" Column="58" TopLine="399"/>866 <Filename Value="ListObject.pas"/> 867 <Caret Line="23" Column="30" TopLine="1"/> 734 868 </Position12> 735 869 <Position13> 736 870 <Filename Value="UMainForm.pas"/> 737 <Caret Line=" 367" Column="12" TopLine="350"/>871 <Caret Line="22" Column="35" TopLine="1"/> 738 872 </Position13> 739 873 <Position14> 740 874 <Filename Value="UMainForm.pas"/> 741 <Caret Line=" 428" Column="7" TopLine="411"/>875 <Caret Line="110" Column="12" TopLine="81"/> 742 876 </Position14> 743 877 <Position15> 744 878 <Filename Value="UMainForm.pas"/> 745 <Caret Line=" 349" Column="3" TopLine="332"/>879 <Caret Line="133" Column="9" TopLine="103"/> 746 880 </Position15> 747 881 <Position16> 748 882 <Filename Value="UMainForm.pas"/> 749 <Caret Line=" 428" Column="35" TopLine="411"/>883 <Caret Line="162" Column="7" TopLine="136"/> 750 884 </Position16> 751 885 <Position17> 752 886 <Filename Value="UMainForm.pas"/> 753 <Caret Line=" 432" Column="47" TopLine="411"/>887 <Caret Line="171" Column="1" TopLine="152"/> 754 888 </Position17> 755 889 <Position18> 756 890 <Filename Value="UMainForm.pas"/> 757 <Caret Line="1 0" Column="25" TopLine="1"/>891 <Caret Line="190" Column="7" TopLine="165"/> 758 892 </Position18> 759 893 <Position19> 760 <Filename Value=" ListObject.pas"/>761 <Caret Line=" 27" Column="1" TopLine="1"/>894 <Filename Value="UMainForm.pas"/> 895 <Caret Line="188" Column="5" TopLine="168"/> 762 896 </Position19> 763 897 <Position20> 764 <Filename Value=" ListObject.pas"/>765 <Caret Line=" 19" Column="29" TopLine="1"/>898 <Filename Value="UMainForm.pas"/> 899 <Caret Line="393" Column="5" TopLine="364"/> 766 900 </Position20> 767 901 <Position21> 768 <Filename Value=" ListObject.pas"/>769 <Caret Line=" 24" Column="6" TopLine="1"/>902 <Filename Value="../Specialized/SpecializedQueue.pas"/> 903 <Caret Line="33" Column="32" TopLine="1"/> 770 904 </Position21> 771 905 <Position22> 772 <Filename Value=" ListObject.pas"/>773 <Caret Line=" 13" Column="24" TopLine="1"/>906 <Filename Value="../Specialized/SpecializedQueue.pas"/> 907 <Caret Line="20" Column="34" TopLine="1"/> 774 908 </Position22> 775 909 <Position23> 776 <Filename Value=" ListObject.pas"/>777 <Caret Line=" 4" Column="1" TopLine="1"/>910 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 911 <Caret Line="22" Column="36" TopLine="1"/> 778 912 </Position23> 779 913 <Position24> 780 <Filename Value=" ../Specialized/ListDouble.pas"/>781 <Caret Line=" 21" Column="12" TopLine="1"/>914 <Filename Value="UMainForm.pas"/> 915 <Caret Line="469" Column="3" TopLine="439"/> 782 916 </Position24> 783 917 <Position25> 784 <Filename Value=" ../Specialized/DictionaryStringString.pas"/>785 <Caret Line=" 1" Column="1" TopLine="1"/>918 <Filename Value="ListObject.pas"/> 919 <Caret Line="33" Column="39" TopLine="1"/> 786 920 </Position25> 921 <Position26> 922 <Filename Value="../Generic/GenericObjectList.inc"/> 923 <Caret Line="14" Column="55" TopLine="1"/> 924 </Position26> 925 <Position27> 926 <Filename Value="UMainForm.pas"/> 927 <Caret Line="89" Column="20" TopLine="70"/> 928 </Position27> 929 <Position28> 930 <Filename Value="../Specialized/SpecializedDictionary.pas"/> 931 <Caret Line="22" Column="36" TopLine="1"/> 932 </Position28> 933 <Position29> 934 <Filename Value="../Generic/GenericTree.inc"/> 935 <Caret Line="33" Column="25" TopLine="12"/> 936 </Position29> 937 <Position30> 938 <Filename Value="../Specialized/SpecializedTree.pas"/> 939 <Caret Line="82" Column="5" TopLine="47"/> 940 </Position30> 787 941 </JumpHistory> 788 942 </ProjectOptions> -
Generics/TemplateGenerics/Demo/ListObject.pas
r82 r84 2 2 3 3 {$mode delphi} 4 {$MACRO ON} 4 5 5 6 interface … … 9 10 10 11 type 11 TObjectListIndex = Integer; 12 TObjectListItem = TObject; 13 {$INCLUDE '..\Generic\ObjectListInterface.tpl'} 12 // TListObject<Integer, TObject> 13 {$DEFINE TGObjectListIndex := Integer} 14 {$DEFINE TGObjectListItem := TObject} 15 {$DEFINE TGObjectListList := TObjectListList} 16 {$DEFINE TGObjectList := TListObject} 17 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareInteger} 18 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterInteger} 19 {$DEFINE INTERFACE} 20 {$INCLUDE '..\Generic\GenericObjectList.inc'} 14 21 15 type16 17 { TListObject }18 19 TListObject = class(TGObjectList)20 end;21 22 22 23 implementation 23 24 24 {$INCLUDE '..\Generic\ObjectListImplementation.tpl'} 25 // TListObject<Integer, TObject> 26 {$DEFINE TGObjectListIndex := Integer} 27 {$DEFINE TGObjectListItem := TObject} 28 {$DEFINE TGObjectListList := TObjectListList} 29 {$DEFINE TGObjectList := TListObject} 30 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareInteger} 31 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterInteger} 32 {$DEFINE IMPLEMENTATION} 33 {$INCLUDE '..\Generic\GenericObjectList.inc'} 25 34 26 35 end. -
Generics/TemplateGenerics/Demo/UMainForm.pas
r80 r84 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ListInteger, ListString, DictionaryStringString, QueueInteger, ListChar,10 ListPointer,DateUtils, ListObject;9 ComCtrls, SpecializedList, SpecializedDictionary, SpecializedQueue, 10 DateUtils, ListObject; 11 11 12 12 type -
Generics/TemplateGenerics/Generic/GenericDictionary.inc
r83 r84 4 4 5 5 TGPair = record 6 Key: T DictionaryKey;7 Value: T DictionaryValue;6 Key: TGPairKey; 7 Value: TGPairValue; 8 8 end; 9 9 10 TListIndex = TDictionaryIndex; 11 TListItem = TGPair; 12 {$DEFINE INTERFACE} 13 {$INCLUDE 'GenericList.inc'} 10 {$DEFINE TGListIndex := TGDictionaryIndex} 11 {$DEFINE TGListItem := TGPair} 12 {$DEFINE TGList := TGDictionaryList} 13 {$DEFINE TGListSortCompare := TDictionarySortCompare} 14 {$DEFINE TGListStringConverter := TDictionaryStringConverter} 15 {$DEFINE INTERFACE} 16 {$INCLUDE 'GenericList.inc'} 14 17 15 // TGDictionary<T DictionaryIndex, TDictionaryKey, TDictionaryValue> = class(TGList)18 // TGDictionary<TGDictionaryIndex, TGPair<TGPairKey, TGPairValue>> = class(TGList) 16 19 TGDictionary = class(TGList) 17 20 private 18 function GetKey(Index: T DictionaryIndex): TDictionaryKey;19 function GetValue(Key: T DictionaryKey): TDictionaryValue;20 procedure PutKey(Index: T DictionaryIndex; const AValue: TDictionaryKey);21 procedure PutValue(Key: T DictionaryKey; const AValue: TDictionaryValue);21 function GetKey(Index: TGDictionaryIndex): TGPairKey; 22 function GetValue(Key: TGPairKey): TGPairValue; 23 procedure PutKey(Index: TGDictionaryIndex; const AValue: TGPairKey); 24 procedure PutValue(Key: TGPairKey; const AValue: TGPairValue); 22 25 public 23 function SearchKey(Key: T DictionaryKey): TDictionaryIndex;24 procedure Add(Key: T DictionaryKey; Value: TDictionaryValue);25 property Values[Index: T DictionaryKey]: TDictionaryValue26 function SearchKey(Key: TGPairKey): TGDictionaryIndex; 27 procedure Add(Key: TGPairKey; Value: TGPairValue); 28 property Values[Index: TGPairKey]: TGPairValue 26 29 read GetValue write PutValue; 27 property Keys[Index: T DictionaryIndex]: TDictionaryKey30 property Keys[Index: TGDictionaryIndex]: TGPairKey 28 31 read GetKey write PutKey; 29 32 end; … … 34 37 {$IFDEF IMPLEMENTATION} 35 38 39 {$UNDEF IMPLEMENTATION} 40 {$DEFINE IMPLEMENTATION_USES} 41 {$INCLUDE '..\Generic\GenericList.inc'} 36 42 43 {$DEFINE TGListIndex := TGDictionaryIndex} 44 {$DEFINE TGListItem := TGPair} 45 {$DEFINE TGList := TGDictionaryList} 46 {$DEFINE TGListSortCompare := TDictionarySortCompare} 47 {$DEFINE TGListStringConverter := TDictionaryStringConverter} 37 48 {$DEFINE IMPLEMENTATION} 38 49 {$INCLUDE 'GenericList.inc'} 39 50 40 function TGDictionary.GetKey(Index: T DictionaryIndex): TDictionaryKey;51 function TGDictionary.GetKey(Index: TGDictionaryIndex): TGPairKey; 41 52 begin 42 53 Result := Items[Index].Key; 43 54 end; 44 55 45 function TGDictionary.GetValue(Key: T DictionaryKey): TDictionaryValue;56 function TGDictionary.GetValue(Key: TGPairKey): TGPairValue; 46 57 begin 47 58 Result := Items[SearchKey(Key)].Value; 48 59 end; 49 60 50 procedure TGDictionary.PutKey(Index: T DictionaryIndex;51 const AValue: T DictionaryKey);61 procedure TGDictionary.PutKey(Index: TGDictionaryIndex; 62 const AValue: TGPairKey); 52 63 var 53 64 Item: TGPair; … … 59 70 end; 60 71 61 procedure TGDictionary.PutValue(Key: T DictionaryKey;62 const AValue: T DictionaryValue);72 procedure TGDictionary.PutValue(Key: TGPairKey; 73 const AValue: TGPairValue); 63 74 var 64 75 Item: TGPair; 65 Index: T DictionaryIndex;76 Index: TGDictionaryIndex; 66 77 begin 67 78 //Items[SearchKey(Index)].Value := AValue; … … 72 83 end; 73 84 74 function TGDictionary.SearchKey(Key: T DictionaryKey): TDictionaryIndex;85 function TGDictionary.SearchKey(Key: TGPairKey): TGDictionaryIndex; 75 86 begin 76 87 Result := 0; … … 83 94 end; 84 95 85 procedure TGDictionary.Add(Key: T DictionaryKey; Value: TDictionaryValue);96 procedure TGDictionary.Add(Key: TGPairKey; Value: TGPairValue); 86 97 var 87 98 NewPair: TGPair; … … 92 103 end; 93 104 105 {$UNDEF IMPLEMENTATION} 94 106 {$ENDIF} -
Generics/TemplateGenerics/Generic/GenericList.inc
r83 r84 1 1 {$IFDEF INTERFACE} 2 2 3 PGListItem = ^TListItem;4 3 TGList = class; 5 4 6 TGListSortCompare = function(const Item1, Item2: TListItem): Integer of object; 7 TGListStringConverter = function(Item: TListItem): string; 8 TGListOperation = procedure(List: TGList; Item: PGListItem); 5 TGListSortCompare = function(const Item1, Item2: TGListItem): Integer of object; 6 TGListStringConverter = function(Item: TGListItem): string; 9 7 //TGListNotification = (lnAdded, lnExtracted, lnDeleted); 10 8 11 // TGList<T ListIndex, TListItem> = class9 // TGList<TGListIndex, TGListItem> = class 12 10 TGList = class 13 11 private 14 FItems: array of T ListItem;15 FCount: T ListIndex;16 function Get(Index: T ListIndex): TListItem;17 function GetCapacity: T ListIndex;18 procedure SetCapacity(const AValue: T ListIndex);19 procedure Put(Index: T ListIndex; const AValue: TListItem); virtual;20 procedure SetCount(const AValue: T ListIndex);21 procedure QuickSort(L, R : T ListIndex; Compare: TGListSortCompare);12 FItems: array of TGListItem; 13 FCount: TGListIndex; 14 function Get(Index: TGListIndex): TGListItem; 15 function GetCapacity: TGListIndex; 16 procedure SetCapacity(const AValue: TGListIndex); 17 procedure Put(Index: TGListIndex; const AValue: TGListItem); virtual; 18 procedure SetCount(const AValue: TGListIndex); 19 procedure QuickSort(L, R : TGListIndex; Compare: TGListSortCompare); 22 20 public 23 21 // All items … … 28 26 procedure Sort(Compare: TGListSortCompare); 29 27 function Implode(Separator: string; Converter: TGListStringConverter): string; 30 procedure Perform(Operation: TGListOperation);31 28 // Many items 32 procedure MoveItems(CurIndex, NewIndex, Count: T ListIndex);33 procedure DeleteItems(Index, Count: T ListIndex);34 procedure Fill(Start, Count: T ListIndex; Value: TListItem);29 procedure MoveItems(CurIndex, NewIndex, Count: TGListIndex); 30 procedure DeleteItems(Index, Count: TGListIndex); 31 procedure Fill(Start, Count: TGListIndex; Value: TGListItem); 35 32 // One item 36 function Add(Item: T ListItem): TListIndex;37 procedure Delete(Index: T ListIndex); virtual;38 function Extract(Item: T ListItem): TListItem;39 procedure Exchange(Index1, Index2: T ListIndex);40 function First: T ListItem;41 function IndexOf(Item: T ListItem; Start: TListIndex = 0): TListIndex;42 procedure Insert(Index: T ListIndex; Item: TListItem);43 function Last: T ListItem;44 procedure Move(CurIndex, NewIndex: T ListIndex);45 function Remove(Item: T ListItem): TListIndex;46 property Items[Index: T ListIndex]: TListItem read Get write Put; default;33 function Add(Item: TGListItem): TGListIndex; 34 procedure Delete(Index: TGListIndex); virtual; 35 function Extract(Item: TGListItem): TGListItem; 36 procedure Exchange(Index1, Index2: TGListIndex); 37 function First: TGListItem; 38 function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex; 39 procedure Insert(Index: TGListIndex; Item: TGListItem); 40 function Last: TGListItem; 41 procedure Move(CurIndex, NewIndex: TGListIndex); 42 function Remove(Item: TGListItem): TGListIndex; 43 property Items[Index: TGListIndex]: TGListItem read Get write Put; default; 47 44 // List 48 45 procedure AddList(List: TGList); 49 46 procedure Assign(List: TGList); 50 47 function Equals(List: TGList): Boolean; 51 procedure InsertList(Index: T ListIndex; List: TGList);52 function IndexOfList(List: TGList; Start: T ListIndex = 0): TListIndex;48 procedure InsertList(Index: TGListIndex; List: TGList); 49 function IndexOfList(List: TGList; Start: TGListIndex = 0): TGListIndex; 53 50 // Other 54 property Count: T ListIndex read FCount write SetCount;55 property Capacity: T ListIndex read GetCapacity write SetCapacity;51 property Count: TGListIndex read FCount write SetCount; 52 property Capacity: TGListIndex read GetCapacity write SetCapacity; 56 53 // Array 57 procedure AddArray(Values: array of T ListItem);58 procedure SetArray(Values: array of T ListItem);59 procedure InsertArray(Index: T ListIndex; Values: array of TListItem);54 procedure AddArray(Values: array of TGListItem); 55 procedure SetArray(Values: array of TGListItem); 56 procedure InsertArray(Index: TGListIndex; Values: array of TGListItem); 60 57 end; 61 58 … … 63 60 {$ENDIF} 64 61 65 {$IFDEF IMPLEMENTATION }62 {$IFDEF IMPLEMENTATION_USES} 66 63 67 64 uses 68 65 RtlConsts; 69 66 67 {$UNDEF IMPLEMENTATION_USES} 68 {$ENDIF} 69 70 {$IFDEF IMPLEMENTATION} 71 70 72 { TGList } 71 73 72 function TGList.GetCapacity: T ListIndex;74 function TGList.GetCapacity: TGListIndex; 73 75 begin 74 76 Result := Length(FItems); 75 77 end; 76 78 77 procedure TGList.SetCapacity(const AValue: T ListIndex);79 procedure TGList.SetCapacity(const AValue: TGListIndex); 78 80 begin 79 81 SetLength(FItems, AValue); 80 82 end; 81 83 82 function TGList.Get(Index: T ListIndex): TListItem;84 function TGList.Get(Index: TGListIndex): TGListItem; 83 85 begin 84 86 Result := FItems[Index]; 85 87 end; 86 88 87 procedure TGList.Put(Index: T ListIndex; const AValue: TListItem);89 procedure TGList.Put(Index: TGListIndex; const AValue: TGListItem); 88 90 begin 89 91 FItems[Index] := AValue; 90 92 end; 91 93 92 procedure TGList.SetCount(const AValue: T ListIndex);94 procedure TGList.SetCount(const AValue: TGListIndex); 93 95 begin 94 96 SetLength(FItems, AValue); … … 96 98 end; 97 99 98 procedure TGList.QuickSort(L, R: T ListIndex; Compare: TGListSortCompare);99 var 100 I, J: T ListIndex;101 P, Q: T ListItem;100 procedure TGList.QuickSort(L, R: TGListIndex; Compare: TGListSortCompare); 101 var 102 I, J: TGListIndex; 103 P, Q: TGListItem; 102 104 begin 103 105 repeat … … 139 141 procedure TGList.Expand; 140 142 var 141 IncSize: T ListIndex;143 IncSize: TGListIndex; 142 144 begin 143 145 if FCount = Capacity then begin … … 158 160 end; 159 161 160 function TGList.Extract(Item: T ListItem): TListItem;161 var 162 I: T ListIndex;162 function TGList.Extract(Item: TGListItem): TGListItem; 163 var 164 I: TGListIndex; 163 165 begin 164 166 I := IndexOf(Item); … … 170 172 end; 171 173 172 function TGList.First: T ListItem;174 function TGList.First: TGListItem; 173 175 begin 174 176 if FCount = 0 then … … 178 180 end; 179 181 180 function TGList.IndexOf(Item: T ListItem; Start: TListIndex): TListIndex;182 function TGList.IndexOf(Item: TGListItem; Start: TGListIndex): TGListIndex; 181 183 begin 182 184 Result := Start; 183 185 while (Result < FCount) and 184 not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(T ListItem)) do186 not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TGListItem)) do 185 187 Result := Result + 1; 186 188 if Result = FCount then Result := -1; 187 189 end; 188 190 189 procedure TGList.Insert(Index: T ListIndex; Item: TListItem);191 procedure TGList.Insert(Index: TGListIndex; Item: TGListItem); 190 192 begin 191 193 if (Index < 0) or (Index > FCount ) then … … 193 195 if FCount = Capacity then Expand; 194 196 if Index < FCount then 195 System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(T ListItem));197 System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TGListItem)); 196 198 FItems[Index] := Item; 197 199 FCount := FCount + 1; 198 200 end; 199 201 200 procedure TGList.InsertList(Index: T ListIndex; List: TGList);201 var 202 I: T ListIndex;202 procedure TGList.InsertList(Index: TGListIndex; List: TGList); 203 var 204 I: TGListIndex; 203 205 begin 204 206 I := 0; … … 209 211 end; 210 212 211 function TGList.IndexOfList(List: TGList; Start: T ListIndex): TListIndex;212 var 213 I: T ListIndex;213 function TGList.IndexOfList(List: TGList; Start: TGListIndex): TGListIndex; 214 var 215 I: TGListIndex; 214 216 begin 215 217 if List.Count > 0 then begin … … 218 220 I := 1; 219 221 while I < List.Count do begin 220 if not CompareMem(Addr(FItems[Result + I]), Addr(List.FItems[I]), SizeOf(T ListItem)) then begin222 if not CompareMem(Addr(FItems[Result + I]), Addr(List.FItems[I]), SizeOf(TGListItem)) then begin 221 223 Result := -1; 222 224 Break; … … 228 230 end; 229 231 230 function TGList.Last: T ListItem;232 function TGList.Last: TGListItem; 231 233 begin 232 234 if FCount = 0 then … … 236 238 end; 237 239 238 procedure TGList.Move(CurIndex, NewIndex: T ListIndex);239 var 240 Temp: T ListItem;240 procedure TGList.Move(CurIndex, NewIndex: TGListIndex); 241 var 242 Temp: TGListItem; 241 243 begin 242 244 if ((CurIndex < 0) or (CurIndex > Count - 1)) then … … 246 248 Temp := FItems[CurIndex]; 247 249 if NewIndex > CurIndex then begin 248 System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(T ListItem));250 System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(TGListItem)); 249 251 end else 250 252 if NewIndex < CurIndex then begin 251 System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(T ListItem));253 System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(TGListItem)); 252 254 end; 253 255 FItems[NewIndex] := Temp; … … 256 258 end; 257 259 258 procedure TGList.MoveItems(CurIndex, NewIndex, Count: T ListIndex);260 procedure TGList.MoveItems(CurIndex, NewIndex, Count: TGListIndex); 259 261 var 260 262 S: Integer; … … 281 283 end; 282 284 283 function TGList.Remove(Item: T ListItem): TListIndex;285 function TGList.Remove(Item: TGListItem): TGListIndex; 284 286 begin 285 287 Result := IndexOf(Item); … … 290 292 function TGList.Equals(List: TGList): Boolean; 291 293 var 292 I: T ListIndex;294 I: TGListIndex; 293 295 begin 294 296 Result := Count = List.Count; … … 296 298 I := 0; 297 299 while I < Count do begin 298 if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(T ListItem)) then begin300 if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(TGListItem)) then begin 299 301 Result := False; 300 302 Break; … … 307 309 procedure TGList.Reverse; 308 310 var 309 I: T ListIndex;311 I: TGListIndex; 310 312 begin 311 313 I := 0; … … 322 324 end; 323 325 324 procedure TGList.AddArray(Values: array of T ListItem);325 var 326 I: T ListIndex;326 procedure TGList.AddArray(Values: array of TGListItem); 327 var 328 I: TGListIndex; 327 329 begin 328 330 I := 0; … … 333 335 end; 334 336 335 procedure TGList.SetArray(Values: array of T ListItem);336 var 337 I: T ListIndex;337 procedure TGList.SetArray(Values: array of TGListItem); 338 var 339 I: TGListIndex; 338 340 begin 339 341 Clear; … … 345 347 end; 346 348 347 procedure TGList.InsertArray(Index: T ListIndex; Values: array of TListItem);348 var 349 I: T ListIndex;349 procedure TGList.InsertArray(Index: TGListIndex; Values: array of TGListItem); 350 var 351 I: TGListIndex; 350 352 begin 351 353 I := 0; … … 358 360 function TGList.Implode(Separator: string; Converter: TGListStringConverter): string; 359 361 var 360 I: T ListIndex;362 I: TGListIndex; 361 363 begin 362 364 Result := ''; … … 370 372 end; 371 373 372 procedure TGList.Perform(Operation: TGListOperation); 373 var 374 I: TListIndex; 375 begin 376 I := 0; 377 while I < Count do begin 378 Operation(Self, @FItems[I]); 379 I := I + 1; 380 end; 381 end; 382 383 function TGList.Add(Item: TListItem): TListIndex; 374 function TGList.Add(Item: TGListItem): TGListIndex; 384 375 begin 385 376 if FCount = Capacity then … … 392 383 procedure TGList.AddList(List: TGList); 393 384 var 394 I: T ListIndex;385 I: TGListIndex; 395 386 begin 396 387 I := 0; … … 407 398 end; 408 399 409 procedure TGList.Delete(Index: T ListIndex);400 procedure TGList.Delete(Index: TGListIndex); 410 401 begin 411 402 if (Index < 0) or (Index >= FCount) then 412 403 raise EListError.CreateFmt(SListIndexError, [Index]); 413 404 FCount := FCount - 1; 414 System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(T ListItem));405 System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TGListItem)); 415 406 Contract; 416 407 end; 417 408 418 procedure TGList.DeleteItems(Index, Count: T ListIndex);419 var 420 I: T ListIndex;409 procedure TGList.DeleteItems(Index, Count: TGListIndex); 410 var 411 I: TGListIndex; 421 412 begin 422 413 I := Index; … … 427 418 end; 428 419 429 procedure TGList.Fill(Start, Count: T ListIndex; Value: TListItem);420 procedure TGList.Fill(Start, Count: TGListIndex; Value: TGListItem); 430 421 begin 431 422 while Count > 0 do begin … … 436 427 end; 437 428 438 procedure TGList.Exchange(Index1, Index2: T ListIndex);439 var 440 Temp: T ListItem;429 procedure TGList.Exchange(Index1, Index2: TGListIndex); 430 var 431 Temp: TGListItem; 441 432 begin 442 433 if ((Index1 >= FCount) or (Index1 < 0)) then -
Generics/TemplateGenerics/Generic/GenericObjectList.inc
r83 r84 1 1 {$IFDEF INTERFACE} 2 2 3 TListIndex = TObjectListIndex; 4 TListItem = TObjectListItem; 5 {$DEFINE INTERFACE} 6 {$INCLUDE 'GenericList.inc'} 3 {$DEFINE TGListIndex := TGObjectListIndex} 4 {$DEFINE TGListItem := TGObjectListItem} 5 {$DEFINE TGList := TGObjectListList} 6 {$DEFINE TGListSortCompare := TGObjectListSortCompare} 7 {$DEFINE TGListStringConverter := TObjectListStringConverter} 8 {$DEFINE INTERFACE} 9 {$INCLUDE 'GenericList.inc'} 7 10 8 11 // TGObjectList<TObjectListIndex, TObjectListItem> = class(TGList) 9 12 TGObjectList = class(TGList) 10 13 private 11 procedure Put(Index: T ListIndex; const AValue: TListItem); override;14 procedure Put(Index: TGListIndex; const AValue: TGListItem); override; 12 15 public 13 16 OwnsObjects: Boolean; 14 procedure Delete(Index: T ListIndex); override;17 procedure Delete(Index: TGObjectListIndex); override; 15 18 procedure Clear; override; 16 19 constructor Create; … … 23 26 {$IFDEF IMPLEMENTATION} 24 27 28 {$UNDEF IMPLEMENTATION} 29 {$DEFINE IMPLEMENTATION_USES} 30 {$INCLUDE '..\Generic\GenericList.inc'} 31 32 {$DEFINE TGListIndex := TGObjectListIndex} 33 {$DEFINE TGListItem := TGObjectListItem} 34 {$DEFINE TGList := TGObjectListList} 35 {$DEFINE TGListSortCompare := TGObjectListSortCompare} 36 {$DEFINE TGListStringConverter := TObjectListStringConverter} 25 37 {$DEFINE IMPLEMENTATION} 26 38 {$INCLUDE 'GenericList.inc'} … … 28 40 { TGObjectList } 29 41 30 procedure TGObjectList.Put(Index: T ObjectListIndex; const AValue: TObjectListItem);42 procedure TGObjectList.Put(Index: TGListIndex; const AValue: TGListItem); 31 43 begin 32 44 if OwnsObjects then FItems[Index].Free; … … 34 46 end; 35 47 36 procedure TGObjectList.Delete(Index: T ObjectListIndex);48 procedure TGObjectList.Delete(Index: TGObjectListIndex); 37 49 begin 38 50 if OwnsObjects then FItems[Index].Free; … … 42 54 procedure TGObjectList.Clear; 43 55 var 44 I: T ObjectListIndex;56 I: TGObjectListIndex; 45 57 begin 46 58 if OwnsObjects then begin … … 66 78 end; 67 79 80 {$UNDEF IMPLEMENTATION} 68 81 {$ENDIF} -
Generics/TemplateGenerics/Generic/GenericQueue.inc
r83 r84 1 1 {$IFDEF INTERFACE} 2 2 3 TListIndex = TQueueIndex; 4 TListItem = TQueueItem; 5 {$DEFINE INTERFACE} 6 {$INCLUDE 'GenericList.inc'} 3 {$DEFINE TGListIndex := TGQueueIndex} 4 {$DEFINE TGListItem := TGQueueItem} 5 {$DEFINE TGList := TGQueueList} 6 {$DEFINE TGListSortCompare := TGQueueSortCompare} 7 {$DEFINE TGListStringConverter := TGQueueStringConverter} 8 {$DEFINE INTERFACE} 9 {$INCLUDE 'GenericList.inc'} 7 10 8 11 // TGQueue<TSetIndex, TSetItem> = class(TGList) … … 11 14 FList: TGList; 12 15 public 13 procedure Enqueue(Value: T QueueItem);14 function Dequeue: T QueueItem;15 function Peek: T QueueItem;16 procedure Enqueue(Value: TGQueueItem); 17 function Dequeue: TGQueueItem; 18 function Peek: TGQueueItem; 16 19 constructor Create; 17 20 destructor Destroy; override; … … 22 25 {$ENDIF} 23 26 27 {$IFDEF IMPLEMENTATION_USES} 28 29 {$DEFINE IMPLEMENTATION_USES} 30 {$INCLUDE '..\Generic\GenericList.inc'} 31 32 {$UNDEF IMPLEMENTATION_USES} 33 {$ENDIF} 34 24 35 {$IFDEF IMPLEMENTATION} 25 36 37 {$DEFINE TGListIndex := TGQueueIndex} 38 {$DEFINE TGListItem := TGQueueItem} 39 {$DEFINE TGList := TGQueueList} 40 {$DEFINE TGListSortCompare := TGQueueSortCompare} 41 {$DEFINE TGListStringConverter := TGQueueStringConverter} 26 42 {$DEFINE IMPLEMENTATION} 27 43 {$INCLUDE 'GenericList.inc'} … … 29 45 { TGQueue } 30 46 31 procedure TGQueue.Enqueue(Value: T QueueItem);47 procedure TGQueue.Enqueue(Value: TGQueueItem); 32 48 begin 33 49 FList.Add(Value); 34 50 end; 35 51 36 function TGQueue.Peek: T QueueItem;52 function TGQueue.Peek: TGQueueItem; 37 53 begin 38 54 Result := FList.First; … … 50 66 end; 51 67 52 function TGQueue.Dequeue: T QueueItem;68 function TGQueue.Dequeue: TGQueueItem; 53 69 begin 54 70 Result := FList.Extract(FList.First); 55 71 end; 56 72 73 {$UNDEF IMPLEMENTATION} 57 74 {$ENDIF} -
Generics/TemplateGenerics/Generic/GenericRange.inc
r83 r84 41 41 end; 42 42 43 {$UNDEF IMPLEMENTATION} 43 44 {$ENDIF} -
Generics/TemplateGenerics/Generic/GenericSet.inc
r83 r84 1 1 {$IFDEF INTERFACE} 2 2 3 TListIndex = TSetIndex; 4 TListItem = TSetItem; 5 {$DEFINE INTERFACE} 6 {$INCLUDE 'GenericList.inc'} 3 {$DEFINE TGListIndex := TGSetIndex} 4 {$DEFINE TGListItem := TGSetItem} 5 {$DEFINE TGList := TGSetList} 6 {$DEFINE TGListSortCompare := TGSetSortCompare} 7 {$DEFINE TGListStringConverter := TGSetStringConverter} 8 {$DEFINE INTERFACE} 9 {$INCLUDE 'GenericList.inc'} 7 10 8 // TGSet<T SetIndex, TSetItem> = class(TGSet)11 // TGSet<TGSetIndex, TGSetItem> = class 9 12 TGSet = class 10 13 private 11 14 FList: TGList; 12 15 public 13 function IsIn(Item: T SetItem): Boolean;16 function IsIn(Item: TGSetItem): Boolean; 14 17 constructor Create; 15 18 destructor Destroy; override; … … 20 23 {$ENDIF} 21 24 25 {$IFDEF IMPLEMENTATION_USES} 26 27 {$DEFINE IMPLEMENTATION_USES} 28 {$INCLUDE '..\Generic\GenericList.inc'} 29 30 {$UNDEF IMPLEMENTATION_USES} 31 {$ENDIF} 32 22 33 {$IFDEF IMPLEMENTATION} 23 34 35 {$DEFINE TGListIndex := TGSetIndex} 36 {$DEFINE TGListItem := TGSetItem} 37 {$DEFINE TGList := TGSetList} 38 {$DEFINE TGListSortCompare := TGSetSortCompare} 39 {$DEFINE TGListStringConverter := TGSetStringConverter} 24 40 {$DEFINE IMPLEMENTATION} 25 41 {$INCLUDE 'GenericList.inc'} … … 27 43 { TGSet } 28 44 29 function TGSet.IsIn(Item: T SetItem): Boolean;45 function TGSet.IsIn(Item: TGSetItem): Boolean; 30 46 begin 31 47 Result := FList.IndexOf(Item) <> -1; … … 43 59 end; 44 60 61 {$UNDEF IMPLEMENTATION} 45 62 {$ENDIF} -
Generics/TemplateGenerics/Generic/GenericStack.inc
r83 r84 1 1 {$IFDEF INTERFACE} 2 2 3 TListIndex = TStackIndex; 4 TListItem = TStackItem; 5 {$DEFINE INTERFACE} 6 {$INCLUDE 'GenericList.inc'} 3 {$DEFINE TGListIndex := TGStackIndex} 4 {$DEFINE TGListItem := TGStackItem} 5 {$DEFINE TGList := TGStackList} 6 {$DEFINE TGListSortCompare := TGStackSortCompare} 7 {$DEFINE TGListStringConverter := TGStackStringConverter} 8 {$DEFINE INTERFACE} 9 {$INCLUDE 'GenericList.inc'} 7 10 8 11 // TGStack<TStackIndex, TStackItem> = class(TGList) … … 11 14 FList: TGList; 12 15 public 13 procedure Push(Value: T StackItem);14 function Pop: T StackItem;16 procedure Push(Value: TGStackItem); 17 function Pop: TGStackItem; 15 18 constructor Create; 16 19 destructor Destroy; override; … … 21 24 {$ENDIF} 22 25 26 {$IFDEF IMPLEMENTATION_USES} 27 28 {$DEFINE IMPLEMENTATION_USES} 29 {$INCLUDE '..\Generic\GenericList.inc'} 30 31 {$UNDEF IMPLEMENTATION_USES} 32 {$ENDIF} 33 23 34 {$IFDEF IMPLEMENTATION} 24 35 36 {$DEFINE TGListIndex := TGStackIndex} 37 {$DEFINE TGListItem := TGStackItem} 38 {$DEFINE TGList := TGStackList} 39 {$DEFINE TGListSortCompare := TGStackSortCompare} 40 {$DEFINE TGListStringConverter := TGStackStringConverter} 25 41 {$DEFINE IMPLEMENTATION} 26 42 {$INCLUDE 'GenericList.inc'} … … 28 44 { TGStack } 29 45 30 procedure TGStack.Push(Value: T StackItem);46 procedure TGStack.Push(Value: TGStackItem); 31 47 begin 32 48 FList.Add(Value); 33 49 end; 34 50 35 function TGStack.Pop: T StackItem;51 function TGStack.Pop: TGStackItem; 36 52 begin 37 53 Result := FList.Extract(FList.Last); … … 49 65 end; 50 66 67 {$UNDEF IMPLEMENTATION} 51 68 {$ENDIF} -
Generics/TemplateGenerics/Generic/GenericTree.inc
r83 r84 3 3 TGTreeNode = class; 4 4 5 TListIndex = TTreeIndex; 6 TListItem = TGTreeNode; 7 {$DEFINE INTERFACE} 8 {$INCLUDE 'GenericList.inc'} 5 {$DEFINE TGListIndex := TGTreeIndex} 6 {$DEFINE TGListItem := TGTreeNode} 7 {$DEFINE TGList := TGTreeNodeList} 8 {$DEFINE TGListSortCompare := TGTreeSortCompare} 9 {$DEFINE TGListStringConverter := TGTreeStringConverter} 10 {$DEFINE INTERFACE} 11 {$INCLUDE 'GenericList.inc'} 9 12 10 TTreeNodeList = class(TGList) 11 end; 12 13 // TGTreeNode<TTreeIndex, TTreeItem> = class 13 // TGTreeNode<TGTreeIndex, TGTreeItem> = class 14 14 TGTreeNode = class 15 Childs: T TreeNodeList;16 Value: T TreeItem;15 Childs: TGTreeNodeList; 16 Value: TGTreeItem; 17 17 procedure Clear; 18 18 end; 19 19 20 // TGTree<T TreeIndex, TTreeItem> = class20 // TGTree<TGTreeIndex, TGTreeItem> = class 21 21 TGTree = class 22 22 TopItem: TGTreeNode; … … 27 27 {$ENDIF} 28 28 29 {$IFDEF IMPLEMENTATION_USES} 30 31 {$DEFINE IMPLEMENTATION_USES} 32 {$INCLUDE 'GenericList.inc'} 33 34 {$UNDEF INTERFACE_USES} 35 {$ENDIF} 36 37 29 38 {$IFDEF IMPLEMENTATION} 39 {$UNDEF IMPLEMENTATION} 30 40 41 {$DEFINE TGListIndex := TGTreeIndex} 42 {$DEFINE TGListItem := TGTreeNode} 43 {$DEFINE TGList := TGTreeNodeList} 44 {$DEFINE TGListSortCompare := TGTreeSortCompare} 45 {$DEFINE TGListStringConverter := TGTreeStringConverter} 31 46 {$DEFINE IMPLEMENTATION} 32 47 {$INCLUDE 'GenericList.inc'} … … 46 61 end; 47 62 63 {$UNDEF IMPLEMENTATION} 48 64 {$ENDIF} -
Generics/TemplateGenerics/TemplateGenerics.lpk
r83 r84 17 17 </CompilerOptions> 18 18 <Version Minor="1"/> 19 <Files Count=" 35">19 <Files Count="15"> 20 20 <Item1> 21 <Filename Value=" Specialized\ListDouble.pas"/>22 < UnitName Value="ListDouble"/>21 <Filename Value="ReadMe.txt"/> 22 <Type Value="Text"/> 23 23 </Item1> 24 24 <Item2> 25 <Filename Value=" Specialized\ListInteger.pas"/>26 < UnitName Value="ListInteger"/>25 <Filename Value="Generic\GenericDictionary.inc"/> 26 <Type Value="Include"/> 27 27 </Item2> 28 28 <Item3> 29 <Filename Value=" Specialized\ListPointer.pas"/>30 < UnitName Value="ListPointer"/>29 <Filename Value="Generic\GenericList.inc"/> 30 <Type Value="Include"/> 31 31 </Item3> 32 32 <Item4> 33 <Filename Value=" Specialized\ListString.pas"/>34 < UnitName Value="ListString"/>33 <Filename Value="Generic\GenericObjectList.inc"/> 34 <Type Value="Include"/> 35 35 </Item4> 36 36 <Item5> 37 <Filename Value=" Specialized\TreeInteger.pas"/>38 < UnitName Value="TreeInteger"/>37 <Filename Value="Generic\GenericQueue.inc"/> 38 <Type Value="Include"/> 39 39 </Item5> 40 40 <Item6> 41 <Filename Value=" Specialized\TreeObject.pas"/>42 < UnitName Value="TreeObject"/>41 <Filename Value="Generic\GenericRange.inc"/> 42 <Type Value="Include"/> 43 43 </Item6> 44 44 <Item7> 45 <Filename Value=" Specialized\TreePointer.pas"/>46 < UnitName Value="TreePointer"/>45 <Filename Value="Generic\GenericSet.inc"/> 46 <Type Value="Include"/> 47 47 </Item7> 48 48 <Item8> 49 <Filename Value=" Specialized\TreeString.pas"/>50 < UnitName Value="TreeString"/>49 <Filename Value="Generic\GenericStack.inc"/> 50 <Type Value="Include"/> 51 51 </Item8> 52 52 <Item9> 53 <Filename Value=" Specialized\DictionaryStringString.pas"/>54 < UnitName Value="DictionaryStringString"/>53 <Filename Value="Generic\GenericTree.inc"/> 54 <Type Value="Include"/> 55 55 </Item9> 56 56 <Item10> 57 <Filename Value="Specialized\S tackDouble.pas"/>58 <UnitName Value="S tackDouble"/>57 <Filename Value="Specialized\SpecializedList.pas"/> 58 <UnitName Value="SpecializedList"/> 59 59 </Item10> 60 60 <Item11> 61 <Filename Value="Specialized\S tackInteger.pas"/>62 <UnitName Value="S tackInteger"/>61 <Filename Value="Specialized\SpecializedDictionary.pas"/> 62 <UnitName Value="SpecializedDictionary"/> 63 63 </Item11> 64 64 <Item12> 65 <Filename Value="Specialized\S tackObject.pas"/>66 <UnitName Value="S tackObject"/>65 <Filename Value="Specialized\SpecializedStack.pas"/> 66 <UnitName Value="SpecializedStack"/> 67 67 </Item12> 68 68 <Item13> 69 <Filename Value="Specialized\S tackPointer.pas"/>70 <UnitName Value="S tackPointer"/>69 <Filename Value="Specialized\SpecializedTree.pas"/> 70 <UnitName Value="SpecializedTree"/> 71 71 </Item13> 72 72 <Item14> 73 <Filename Value="Specialized\S tackString.pas"/>74 <UnitName Value="S tackString"/>73 <Filename Value="Specialized\SpecializedQueue.pas"/> 74 <UnitName Value="SpecializedQueue"/> 75 75 </Item14> 76 76 <Item15> 77 <Filename Value="Specialized\ QueueDouble.pas"/>78 <UnitName Value=" QueueDouble"/>77 <Filename Value="Specialized\SpecializedSet.pas"/> 78 <UnitName Value="SpecializedSet"/> 79 79 </Item15> 80 <Item16>81 <Filename Value="Specialized\QueueInteger.pas"/>82 <UnitName Value="QueueInteger"/>83 </Item16>84 <Item17>85 <Filename Value="Specialized\QueueObject.pas"/>86 <UnitName Value="QueueObject"/>87 </Item17>88 <Item18>89 <Filename Value="Specialized\QueuePointer.pas"/>90 <UnitName Value="QueuePointer"/>91 </Item18>92 <Item19>93 <Filename Value="Specialized\QueueString.pas"/>94 <UnitName Value="QueueString"/>95 </Item19>96 <Item20>97 <Filename Value="Specialized\ListChar.pas"/>98 <UnitName Value="ListChar"/>99 </Item20>100 <Item21>101 <Filename Value="ReadMe.txt"/>102 <Type Value="Text"/>103 </Item21>104 <Item22>105 <Filename Value="Specialized\ListVariant.pas"/>106 <UnitName Value="ListVariant"/>107 </Item22>108 <Item23>109 <Filename Value="Specialized\SetInteger.pas"/>110 <UnitName Value="SetInteger"/>111 </Item23>112 <Item24>113 <Filename Value="Specialized\SetString.pas"/>114 <UnitName Value="SetString"/>115 </Item24>116 <Item25>117 <Filename Value="Specialized\SetChar.pas"/>118 <UnitName Value="SetChar"/>119 </Item25>120 <Item26>121 <Filename Value="Specialized\RangeDateTime.pas"/>122 <UnitName Value="RangeDateTime"/>123 </Item26>124 <Item27>125 <Filename Value="Specialized\ListByte.pas"/>126 <UnitName Value="ListByte"/>127 </Item27>128 <Item28>129 <Filename Value="Generic\GenericDictionary.inc"/>130 <Type Value="Include"/>131 </Item28>132 <Item29>133 <Filename Value="Generic\GenericList.inc"/>134 <Type Value="Include"/>135 </Item29>136 <Item30>137 <Filename Value="Generic\GenericObjectList.inc"/>138 <Type Value="Include"/>139 </Item30>140 <Item31>141 <Filename Value="Generic\GenericQueue.inc"/>142 <Type Value="Include"/>143 </Item31>144 <Item32>145 <Filename Value="Generic\GenericRange.inc"/>146 <Type Value="Include"/>147 </Item32>148 <Item33>149 <Filename Value="Generic\GenericSet.inc"/>150 <Type Value="Include"/>151 </Item33>152 <Item34>153 <Filename Value="Generic\GenericStack.inc"/>154 <Type Value="Include"/>155 </Item34>156 <Item35>157 <Filename Value="Generic\GenericTree.inc"/>158 <Type Value="Include"/>159 </Item35>160 80 </Files> 161 81 <Type Value="RunAndDesignTime"/> -
Generics/TemplateGenerics/TemplateGenerics.pas
r82 r84 8 8 9 9 uses 10 ListDouble, ListInteger, ListPointer, ListString, TreeInteger, TreeObject, 11 TreePointer, TreeString, DictionaryStringString, StackDouble, StackInteger, 12 StackObject, StackPointer, StackString, QueueDouble, QueueInteger, 13 QueueObject, QueuePointer, QueueString, ListChar, ListVariant, SetInteger, 14 SetString, SetChar, RangeDateTime, ListByte, LazarusPackageIntf; 10 SpecializedList, SpecializedDictionary, SpecializedStack, SpecializedTree, 11 SpecializedQueue, SpecializedSet, LazarusPackageIntf; 15 12 16 13 implementation
Note:
See TracChangeset
for help on using the changeset viewer.