Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
prog:lazarus:classes:tlist [24/05/2021 14:37]
thierry [Les Containers]
prog:lazarus:classes:tlist [15/03/2023 16:28] (Version actuelle)
thierry [Sources & Ressources]
Ligne 39: Ligne 39:
  
 </​code>​ </​code>​
 +
 +===== Enumeration =====
 +On en parle ici -> [[https://​www.freepascal.org/​docs-html/​current/​rtl/​system/​ienumerator.html]]
 +
 +<code delphi>
 +//A for in loop like the following:
 +
 +For O in MyObject do
 +  begin
 +  // do things
 +  end;
 +
 +//is treated by the compiler as equivalent to the following code:
 +
 +Var
 +  I : IEnumerator;​
 +  O : TObject;
 +    ​
 +begin
 +  I:​=MyObject.GetEnumerator;​
 +  While I.MoveNext do
 +    begin
 +    O:​=I.GetCurrent;​
 +    // Do things
 +    end; 
 +end.  ​
 +
 +</​code>​
 +
 ===== Partage de TList entre Threads ===== ===== Partage de TList entre Threads =====
 avec TThreadList -> [[https://​www.freepascal.org/​docs-html/​rtl/​classes/​tthreadlist.html]] avec TThreadList -> [[https://​www.freepascal.org/​docs-html/​rtl/​classes/​tthreadlist.html]]
 +===== Autres listes =====
  
 +|TList<​Char>​|string|
 +|TList<​WideChar>​|WideString|
 +|TList<​Byte>​|array of Byte|
 +|TList<​string>​|Classes.TStrings|
 +|TList<​Pointer>​|Classes.TList|
 +|TList<​Boolean>​|Classes.TBits|
 +|TList<​TObject>​|Contnrs.TObjectList|
 +|TList<​TComponent>​|Contnrs.TComponentList|
 +|TList<​TClass>​|Contnrs.TClassList|
 +|TStack<​Pointer>​|Contnrs.TStack|
 +|TStack<​TObject>​|Contnrs.TObjectStack|
 +|TQueue<​Pointer>​|Contnrs.TQueue|
 +|TQueue<​TObject>​|Contnrs.TObjectQueue|
 +|TStream<​Byte>​|Classes.TMemoryStream|
 +|TDictionary<​TPair<​string,​ string>>​|Classes.TStringList|
 +|TList<​TMethod>​|LCLProc.TMethodList|
 +|TTree<​TTreeNode>​|ComCtrls.TTreeView|
 +|TPoint<​Integer>​|Classes.TPoint|
 +|TPoint<​SmallInt>​|Classes.TSmallPoint|
 +|TRectangle<​Integer>​|Classes.TRect|
 ====== Sources & Ressources ====== ====== Sources & Ressources ======
   * [[http://​www.atug.com/​andypatterns/​collections.htm|TCollection VS TList VS TObjectList]]   * [[http://​www.atug.com/​andypatterns/​collections.htm|TCollection VS TList VS TObjectList]]
   * [[https://​stackoverflow.com/​questions/​5797368/​delphi-tlist-of-records|TList Of Records]] : Utilisation d'un ''​TList''​ a la place d'un ''​Array''​ ou ''​Dynamic Array''​ pour contenir des ''​Records''​.   * [[https://​stackoverflow.com/​questions/​5797368/​delphi-tlist-of-records|TList Of Records]] : Utilisation d'un ''​TList''​ a la place d'un ''​Array''​ ou ''​Dynamic Array''​ pour contenir des ''​Records''​.
 +  * [[https://​wiki.freepascal.org/​Templates/​fr|les templates -> TList<​object>​]]
 +  * [[https://​wiki.freepascal.org/​Data_Structures,​_Containers,​_Collections/​fr|Data Structures, Containers, Collections]]