Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBListOf< T > Class Template Reference

TBListOf is a list (array) of pointers to the specified object type. More...

#include <tb_list.h>

Inheritance diagram for tb::TBListOf< T >:
tb::TBListAutoDeleteOf< T >

Public Member Functions

bool Reserve (int num)
 Make sure there is space for at least num items in the list. More...
 
bool GrowIfNeeded ()
 Make sure there is space for at least one more item in the list. More...
 
bool Add (T *data)
 Add data at the end of the list. More...
 
bool Add (T *data, int index)
 Add data at the given index in the list. More...
 
void Set (T *data, int index)
 Replace the item at the index with the new data.
 
T * Get (int index) const
 Returns the content at position index. More...
 
T * operator[] (int index) const
 Returns the content at position index. More...
 
T * RemoveFast (int index)
 Remove the item at position index from the list and returns the pointer. More...
 
T * Remove (int index)
 Remove the item at position index from the list and returns the pointer. More...
 
void DeleteFast (int index)
 Deletes the item at position index after removing it from the list. More...
 
void Delete (int index)
 Deletes the item at position index after removing it from the list. More...
 
void RemoveAll ()
 Remove all items without deleding them. More...
 
void DeleteAll ()
 Remove and delete all items from the list. More...
 
void Swap (int index1, int index2)
 Swap the items at index1 and index2.
 
int Find (T *data) const
 Search for the item with the given data and return the found index, or -1 if not found. More...
 
int GetNumItems () const
 Get the number of items in the list. More...
 
int GetCapacity () const
 Get the capacity of the list number of items it can hold without allocating more memory)
 

Detailed Description

template<class T>
class tb::TBListOf< T >

TBListOf is a list (array) of pointers to the specified object type.

Note: The objects won't be deleted automatically. If you want that, use TBListAutoDeleteOf!

Member Function Documentation

template<class T>
bool tb::TBListOf< T >::Add ( T *  data)
inline

Add data at the end of the list.

Returns false on OOM failure.

template<class T>
bool tb::TBListOf< T >::Add ( T *  data,
int  index 
)
inline

Add data at the given index in the list.

Returns false on OOM failure.

template<class T>
void tb::TBListOf< T >::Delete ( int  index)
inline

Deletes the item at position index after removing it from the list.

template<class T>
void tb::TBListOf< T >::DeleteAll ( )
inline

Remove and delete all items from the list.

template<class T>
void tb::TBListOf< T >::DeleteFast ( int  index)
inline

Deletes the item at position index after removing it from the list.

This method should only be used when the order of the list is not important. If the order is important, use Delete()

template<class T>
int tb::TBListOf< T >::Find ( T *  data) const
inline

Search for the item with the given data and return the found index, or -1 if not found.

template<class T>
T* tb::TBListOf< T >::Get ( int  index) const
inline

Returns the content at position index.

template<class T>
int tb::TBListOf< T >::GetNumItems ( ) const
inline

Get the number of items in the list.

template<class T>
bool tb::TBListOf< T >::GrowIfNeeded ( )
inline

Make sure there is space for at least one more item in the list.

Returns false on OOM failure. There's no need to call this, but it can make OOM handling easier in some situations since you can guarantee there is space is in a list before you allocate an object to insert into it.

template<class T>
T* tb::TBListOf< T >::operator[] ( int  index) const
inline

Returns the content at position index.

template<class T>
T* tb::TBListOf< T >::Remove ( int  index)
inline

Remove the item at position index from the list and returns the pointer.

template<class T>
void tb::TBListOf< T >::RemoveAll ( )
inline

Remove all items without deleding them.

template<class T>
T* tb::TBListOf< T >::RemoveFast ( int  index)
inline

Remove the item at position index from the list and returns the pointer.

This method should only be used when the order of the list is not important. If the order is important, use Remove()

template<class T>
bool tb::TBListOf< T >::Reserve ( int  num)
inline

Make sure there is space for at least num items in the list.

Returns false on OOM failure.


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