delphi - On Joining TObjectlists -


I think I should cover with a nudge in the right direction:

I have the same datatype There are two related lists, and I want to add them to a new list where the list 1 will be copied (inappropriate), followed by list2 (in reverse)

  type TMyListType = TobkeList & Lt; MyClass & gt; Var list1, list2, resList: Start TMyListtype FillListWithObjects (list1); FillListWithOtherObjects (List2); List2.reverse // Now, I tried to use resList.Assign (list1, list2, laOr), //, but the tobAstlist does not have any assignment. I do not want to re-sell all the objects in my list to fill the Askelst End;  

Does Delphi have an underlying function to merge two tobavista into one?

<< >> to prevent double-freeing in LRes in broken list Use TOBjectList.AddRange () and use False from OwnsObjects .

  var L1, L2, LRes: Tobage list & lt; TPerson & gt ;; Item: Tipperson; {...} L1: = Tubectlight list & lt; TPerson & gt; Create (); Try L2: = TOBjectList & lt; TPerson & gt; Create (); Try LRes: = Tokelah list & lt; TPerson & gt; Create (); Try L1. Add (Tipperson ('A', 'AA')); L1.Add (TPerson.Create ('bb', 'BB')); L2.Add (TPerson.Create ('xx', 'XX')); L2.Add (TPerson.Create ('yy', 'yy')); L2.Reverse; LRes.OwnsObjects: = False; LRes.AddRange (L1); LRes.AddRange (L2); Start output range for items in LRS (item: first name + '' + item.lastname); End; Finally LRes.Free; End; Finally L2. free; End; Finally L1 free; End;  

Comments