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 [17/05/2021 11:38]
thierry [Sources & Ressources]
prog:lazarus:classes:tlist [15/03/2023 16:28] (Version actuelle)
thierry [Sources & Ressources]
Ligne 1: Ligne 1:
 ====== TList et descendants ====== ====== TList et descendants ======
 +===== Les Containers =====
 +Informations sur les differents types de "​Containers"​ en Pascal.
 +  * [[https://​wiki.freepascal.org/​Data_Structures,​_Containers,​_Collections/​fr|Data Structures, Containers, Collections/​fr]]
 +  * [[https://​www.freepascal.org/​docs-html/​current/​rtl/​classes/​tfplist.html|TFPList]]
 +
 +==== Choisir son container ====
 +  * ''​TFPList''​ VS ''​TStringList''​ : il vaudrait mieux utiliser ''​TStringList''​ d'​aprés [[https://​www.freepascal.org/​docs-html/​current/​rtl/​classes/​tfplist.html|les informations contenues sur cette page]]
 +
 +
 ===== Sort ===== ===== Sort =====
 Pour utiliser la méthode Sort sur un TList il faut lui fournir une function de comparaison Pour utiliser la méthode Sort sur un TList il faut lui fournir une function de comparaison
Ligne 30: 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 =====
 +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]]