/ / In the usual application, some often, each A object in the object set TAS corresponds to each B object, and each object B in the object TBS corresponds to an object. If you put each in A and B A TOBJECT property is also quoted, but it is very good, but that dependence is too strong. Looking for the name from the number, or find the number from the name. //, so extract two objects TDOUBJLIST and TDOUBLESTRING, although it can be abstract from them, but because String's memory management mechanism is a bit awkward It is not a strong type, so it is still separated. The full code is as follows: Unit DoubleObject;
InterfaceUses Contnts, Classes;
type TDoubleObjList = class private ObjectList1: TObjectList; ObjectList2: TObjectList; FOwnsObjects: Boolean; procedure SetOwnsObjects (const Value: Boolean); public constructor Create; destructor Destroy; override; procedure Clear; property OwnsObjects: Boolean read FOwnsObjects write SetOwnsObjects; procedure AddData ( AObject1, AObject2: TOBJECT);
Function IndexofData1 (Aindex: Integer): Tobject; OverLoad; Function IndexOfData1 (AObject: Tobject): Integer; Overload;
Function IndexofData2 (Aindex: Integer): Tobject; OverLoad; Function IndexOfData2 (AObject: TOBJECT): Integer; Overload;
Function Data2Getdata1 (AObject: Tobject): Tobject; Function Data1Getdata2: TOBJECT
Function count: integer; end;
TDoubleString = class private Strings1: TStringList; Strings2: TStringList; public constructor Create; destructor Destroy; override; procedure Clear; procedure AddString (AString1, AString2: string);
Function IndexOfData1 (Aindex: Integer): String; Overload; Function IndexOfData1 (Astring: String): Integer; Overload;
Function IndexOfData2 (Aindex: Integer): String; Overload; Function IndexOfData2 (Astring: String): Integer; Overload;
Function Data2Getdata1 (Astring: String): String: String: String Download Adobe Reader: STRING: STRING;
Function Count: Integer; End; Implementation
{TDOUBLEOBJLIST}
procedure TDoubleObjList.AddData (AObject1, AObject2: TObject); begin ObjectList1.Add (AObject1); ObjectList2.Add (AObject2); end; procedure TDoubleObjList.Clear; begin ObjectList1.Clear; ObjectList2.Clear; end;
Function TDOUBLOBJLIST.COUNT: Inteder; Begin Result: = ObjectList1.count;
Constructor tdoubleobjlist.create; begin fownsObjects: = false; ObjectList1: = TOBJECTLIST.CREATE; ObjectList2: = TOBJECTLIST.CREATE; END
Function TDOUBLOBJLIST.DATA1GETDATA2: TOBJECT; Begin Result: = ObjectList2.Items [indexofdata1 (aobject)];
Function TDOUBEOBJLIST.DATA2GETDATA1 (AObject: Tobject): Tobject; Begin Result: = ObjectList1.items [IndexOfData2 (AOBJECT)];
Destructor tdoubleObjlist.destroy; begin object1.free; objectlist2.free; inherited;
Function TDOUBLOPJLIST.INDEXOFDATA1 (AObject: TOBJECT): Integer; begin result: = ObjectList1.indexof (AOBJECT);
Function TDOUBLOBJLIST.INDEXOFDATA1 (Aindex: Integer): TOBJECT; Begin Result: = ObjectList1.Items [aindex];
Function TDOUBLOPJLIST.INDEXOFDATA2: Integer; Begin Result: = ObjectList2.indexof (AOBJECT);
Function tdoubleobjlist.indexofdata2 (aindex: integer): TOBJECT; Begin Result: = ObjectList2.Items [aindex];
Procedure tdoubleobjects: = value; = value; objectlist2.OwnsObjects: = value;
{TDOUBLESTRING}
Procedure tdouplastring.addstring (astring1, asseting2: string); begin strings1.add (assenging1); strings2.add (assenging2);
Procedure tdouplastring.clear; begin strings1.clear; strings2.clear;
Function TDOUBLESTRING.COUNT: INTEGER; Begin Result: = strings1.count; end; constructor tdouboard.create; begin strings1: = tstringlist.create; strings2: = tstringlist.create;
Function TDOUBLESTRING.DATA1GETDATA2: String; Begin Result: = strings2.strings [indexofdata1 (asseter);
Function TDOUBLESTRING.DATA2GETDATA1 (Astring: String): String; Begin Result: = strings1.strings [indexofdata2 (astring)];
DESTRUCTOR TDOUBLESTRING.DESTROY; Begin strings1.free; strings2.free; inherited;
Function TDOUBLESTRING.INDEXOFDATA1: String; Begin Result: = Strings1.Strings [aindex];
Function TDOUBLESTRING.INDEXOFDATA1 (Astring: String): Integer; Begin Result: = Strings1.indexof (Astring);
Function TDOUBLESTRING.INDEXOFDATA2: Integer; Begin Result: = Strings2.indexof (Astring);
Function TDOUBLESTRING.INDEXOFDATA2 (Aindex: Integer): String; Begin Result: = Strings2.Strings [Aindex];
End.