mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-05 05:42:18 +00:00
initial commit. This is icculus version 5542b94cae02a6333845854bbbd1abe0a259f1a4
This commit is contained in:
commit
3096eaf5e2
2519 changed files with 816064 additions and 0 deletions
112
ExternalLibs/FTGL/include/FTList.h
Normal file
112
ExternalLibs/FTGL/include/FTList.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
#ifndef __FTList__
|
||||
#define __FTList__
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
/**
|
||||
* Provides a non-STL alternative to the STL list
|
||||
*/
|
||||
template <typename FT_LIST_ITEM_TYPE>
|
||||
class FTGL_EXPORT FTList
|
||||
{
|
||||
public:
|
||||
typedef FT_LIST_ITEM_TYPE value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef size_t size_type;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
FTList()
|
||||
: listSize(0),
|
||||
tail(0)
|
||||
{
|
||||
tail = NULL;
|
||||
head = new Node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTList()
|
||||
{
|
||||
Node* next;
|
||||
|
||||
for( Node *walk = head; walk; walk = next)
|
||||
{
|
||||
next = walk->next;
|
||||
delete walk;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of items in the list
|
||||
*/
|
||||
size_type size() const
|
||||
{
|
||||
return listSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the end of the list
|
||||
*/
|
||||
void push_back( const value_type& item)
|
||||
{
|
||||
Node* node = new Node( item);
|
||||
|
||||
if( head->next == NULL)
|
||||
{
|
||||
head->next = node;
|
||||
}
|
||||
|
||||
if( tail)
|
||||
{
|
||||
tail->next = node;
|
||||
}
|
||||
tail = node;
|
||||
++listSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item at the front of the list
|
||||
*/
|
||||
reference front() const
|
||||
{
|
||||
return head->next->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item at the end of the list
|
||||
*/
|
||||
reference back() const
|
||||
{
|
||||
return tail->payload;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Node
|
||||
{
|
||||
Node()
|
||||
: next(NULL)
|
||||
{}
|
||||
|
||||
Node( const value_type& item)
|
||||
: next(NULL)
|
||||
{
|
||||
payload = item;
|
||||
}
|
||||
|
||||
Node* next;
|
||||
|
||||
value_type payload;
|
||||
};
|
||||
|
||||
size_type listSize;
|
||||
|
||||
Node* head;
|
||||
Node* tail;
|
||||
};
|
||||
|
||||
#endif // __FTList__
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue