Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
rune::List< T > Class Template Reference

A list that can be used to store data. More...

#include <list.h>

Public Member Functions

T * getList ()
 
T * getNext ()
 
int size ()
 
void add (T const &newData)
 
void remove (int index)
 
void clear ()
 Clears the list.
 
void insert (T const &newData, int index)
 
T & operator[] (int index)
 

Detailed Description

template<class T>
class rune::List< T >

A list that can be used to store data.

The methodology for iterating through a list is very similar to a range based loop syntax. To iterate through a list without copying or having to redo iterations, you should create a for loop like this:

for (TYPE* currentObject = myList.getList(); currentObject != nullptr; currentObject = myList.getNext())
{
//Do stuff
currentObject.myFunction();
}
Author
Thomas Montano
Date
July 21 2020

Member Function Documentation

◆ add()

template<class T >
void rune::List< T >::add ( T const &  newData)
inline

Adds an element to the end of the list.

Parameters
newDataThe data point to be added to the list.

◆ getList()

template<class T >
T* rune::List< T >::getList ( )
inline

Gets the current head of the list for purposes of iteration.

Returns
A pointer to the head of the list.
Warning
Do not call this function from inside a list iteration. If you are already looking through this list it will cause an infinite loop.

◆ getNext()

template<class T >
T* rune::List< T >::getNext ( )
inline

Gets the next element of the list.

Returns
A pointer to the next element
Warning
Will return nullptr if the end of the list has been reached.

◆ insert()

template<class T >
void rune::List< T >::insert ( T const &  newData,
int  index 
)
inline

Insert an element at the specified index.

Parameters
newDataThe element to be inserted.
indexThe zero based index of the location.

◆ operator[]()

template<class T >
T& rune::List< T >::operator[] ( int  index)
inline

List access operator

Parameters
indexThe zero based index of the element to be accessed.
Returns
The accessed element.
Warning
This should not be used to iterate through a list. Only use this function if you are looking for single elements.

◆ remove()

template<class T >
void rune::List< T >::remove ( int  index)
inline

Remove an element at the specified index.

Parameters
indexThe zero based index of the element to be deleted.

◆ size()

template<class T >
int rune::List< T >::size ( )
inline

Gets the number of elements in the list.

Returns
The number of elements in the list.

The documentation for this class was generated from the following file: