Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

List

This is an archived page!
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!

There is a list template called "tList" use it as follows:

Use in Functions without Global Reference

It you just want to create a new list and just quickly use it make it as follows:

#include <list>                             /* include the header */
#include "debug.h"                          /* for use of PRINTF */
.
.
.
std::list<char*> nameList;                  /* create the new list*/

nameList.push_back("Pumba");                /* add some elements at the end of the list (back)*/
nameList.push_back("Mogli");
nameList.push_back("Timon");

std::list<char*>::iterator element;
for (element = nameList.begin(); element != nameList.end(); element++)
{
  PRINTF(3)("found name: %s in list\n", (*name));
}
.
.

This code will have an output like this:

found name: Pumpa in list
found name: Mogli in list
found name: Timon in list

You can make lists of whatever you want eg also from WorldEntities:

#include <list>
.
.
list<WorldEntity*>* entityList = new List<WorldEntity*>;    /* crete new list*/
entityList->push_back(new WorldEntity());                   /* just adds an new entity */
.
.

Now I hear you screem: "ENOUGH"! And you are right…:)

Use in Header Files

If you want a list as a class attribute you have to make a forward declaration of the list:

#inlcude <list>                   /* include the header of the list */

class ExampleClass
{
 private:
  list<>
};

Last modified 8 years ago Last modified on Apr 15, 2017, 3:48:36 PM