|
Public Member Functions |
void | Push (const _DataType &d, const char *file=__FILE__, unsigned int line=__LINE__) |
_DataType & | Pop (const char *file=__FILE__, unsigned int line=__LINE__) |
void | PushOpposite (const _DataType &d, const char *file=__FILE__, unsigned int line=__LINE__) |
_DataType & | PopOpposite (const char *file=__FILE__, unsigned int line=__LINE__) |
| Same as Pop() and Peek(), except FIFO and LIFO are reversed.
|
void | RemoveAtIndex (_IndexType position, const char *file=__FILE__, unsigned int line=__LINE__) |
bool | RemoveAtKey (_KeyType key, bool assertIfDoesNotExist) |
| Find the index of key, and remove at that index.
|
_IndexType | GetIndexOf (_KeyType key) const |
| Finds the index of key. Return -1 if the key is not found.
|
_DataType | GetPtr (_KeyType key) const |
| Finds the index of key. Return 0 if the key is not found. Useful if _DataType is always non-zero pointers.
|
void | ForEach (void(*func)(_DataType &item, const char *file, unsigned int line), const char *file, unsigned int line) |
| Iterate over the list, calling the function pointer on each element.
|
bool | IsEmpty (void) const |
| Returns if the list is empty.
|
_IndexType | GetSize (void) const |
| Returns the number of elements used in the list.
|
void | Clear (bool deallocateSmallBlocks=true, const char *file=__FILE__, unsigned int line=__LINE__) |
| Empties the list. The list is not deallocated if it is small, unless deallocateSmallBlocks is true.
|
void | ReverseList (void) |
| Reverses the elements in the list, and flips the sort order returned by GetSortOrder() if IsSorted() returns true at the time the function is called.
|
void | Reallocate (_IndexType size, const char *file=__FILE__, unsigned int line=__LINE__) |
void | Sort (bool force) |
void | SetSortOrder (bool ascending) |
bool | GetSortOrder (void) const |
| Returns true if ascending.
|
bool | IsSorted (void) const |
MultilistType | GetMultilistType (void) const |
| Returns what type of list this is.
|
void | SetMultilistType (MultilistType newType) |
Protected Attributes |
_DataType * | data |
| An array of user values.
|
_IndexType | dataSize |
| Number of elements in the list.
|
_IndexType | allocationSize |
| Size of array.
|
_IndexType | queueHead |
| Array index for the head of the queue.
|
_IndexType | queueTail |
| Array index for the tail of the queue.
|
_IndexType | preallocationSize |
template<const MultilistType _MultilistType, class _DataType , class _KeyType , class _IndexType >
Returns true if the list is currently believed to be in a sorted state Doesn't actually check for sortedness, just if Sort() was recently called, or MultilistType is ML_ORDERED_LIST
template<const MultilistType _MultilistType, class _DataType , class _KeyType , class _IndexType >
void DataStructures::Multilist< _MultilistType, _DataType, _KeyType, _IndexType >::RemoveAtIndex |
( |
_IndexType |
position, |
|
|
const char * |
file = __FILE__ , |
|
|
unsigned int |
line = __LINE__ | |
|
) |
| | [inline] |
Unordered list, removes at index indicated, swaps last element with that element Otherwise, array is shifted left to overwrite removed element Index[0] returns the same as Pop() for a queue. Same as PopOpposite() for the list and ordered list
template<const MultilistType _MultilistType, class _DataType , class _KeyType , class _IndexType >
Sorts the list unless it is an ordered list, in which it does nothing as the list is assumed to already be sorted. However, if force is true, it will also resort the ordered list, useful if the comparison operator between _KeyType and _DataType would now return different results Once the list is sorted, further operations to lookup by key will be log2(n) until the list is modified