Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of ~archive/GenList


Ignore:
Timestamp:
Nov 27, 2007, 9:46:45 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ~archive/GenList

    v1 v1  
     1== list ==
     2[[TracNav(TracNav/TOCCode)]]
     3There is a list template called "tList" use it as follows:
     4
     5=== Use in Functions without Global Reference ===
     6It you just want to create a new list and just quickly use it make it as follows:
     7{{{
     8#!cpp
     9#include <list>                             /* include the header */
     10#include "debug.h"                          /* for use of PRINTF */
     11.
     12.
     13.
     14std::list<char*> nameList;                  /* create the new list*/
     15
     16nameList.push_back("Pumba");                /* add some elements at the end of the list (back)*/
     17nameList.push_back("Mogli");
     18nameList.push_back("Timon");
     19
     20std::list<char*>::iterator element;
     21for (element = nameList.begin(); element != nameList.end(); element++)
     22{
     23  PRINTF(3)("found name: %s in list\n", (*name));
     24}
     25.
     26.
     27}}}
     28This code will have an output like this:
     29{{{
     30found name: Pumpa in list
     31found name: Mogli in list
     32found name: Timon in list
     33}}}
     34You can make lists of whatever you want eg also from WorldEntities:
     35{{{
     36#!cpp
     37#include <list>
     38.
     39.
     40list<WorldEntity*>* entityList = new List<WorldEntity*>;    /* crete new list*/
     41entityList->push_back(new WorldEntity());                   /* just adds an new entity */
     42.
     43.
     44}}}
     45
     46Now I hear you screem: "ENOUGH"! And you are right...:)
     47
     48=== Use in Header Files ===
     49If you want a list as a class attribute you have to make a forward declaration of the list:
     50{{{
     51#!cpp
     52#inlcude <list>                   /* include the header of the list */
     53
     54class ExampleClass
     55{
     56 private:
     57  list<>
     58};
     59
     60}}}