Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/genstruct/FragTable.h>
Classes | |
class | Iterator |
Public Member Functions | |
FragTable (int size_pow=8) | |
FragTable (const FragTable &tab) | |
~FragTable (void) | |
int | count (void) const |
bool | isEmpty (void) const |
operator bool (void) const | |
bool | contains (const T &item) const |
void | clear (void) |
void | add (const T &item) |
template<template< class _ > class C> | |
void | addAll (const C< T > &items) |
void | remove (const T &item) |
void | remove (const Iterator &iter) |
template<template< class _ > class C> | |
void | removeAll (const C< T > &items) |
int | length (void) const |
const T & | get (int index) const |
int | indexOf (const T &value, int start=0) const |
int | lastIndexOf (const T &value, int start=-1) const |
const T & | operator[] (int index) const |
void | shrink (int length) |
void | set (int index, const T &item) |
void | set (const Iterator &iter, const T &item) |
T & | get (int index) |
T & | operator[] (int index) |
void | insert (int index, const T &item) |
void | insert (const Iterator &iter, const T &item) |
void | removeAt (int index) |
void | removeAt (const Iterator &iter) |
int | alloc (int count) |
void | clean (void) |
FragTable< T > & | operator+= (T value) |
This container class allows indexed access to its data. It is implemented as expandable fragmented table using a two-level table traversal. The first level table selects a sub-table that contains the actual stored items.
Implemented concepts: concept::MutableArray.
T | Type of stored items. |
elm::genstruct::FragTable< T >::FragTable | ( | int | chunk_size = 8 | ) |
The constructor of a fragmented table.
chunk_size | 2^chunk_size is the size of sub-tables (default to 256). |
elm::genstruct::FragTable< T >::FragTable | ( | const FragTable< T > & | tab | ) |
Build a fragmented table by copy.
tab | Table to copy. |
References elm::genstruct::FragTable< T >::addAll().
elm::genstruct::FragTable< T >::~FragTable | ( | void | ) |
void elm::genstruct::FragTable< T >::add | ( | const T & | value | ) |
Add an item to the table.
value | Value of the item to add. |
References elm::value().
Referenced by elm::genstruct::FragTable< T >::addAll().
void elm::genstruct::FragTable< T >::addAll | ( | const C< T > & | items | ) |
Add a collection of item to the table.
items | Items to add. |
References elm::genstruct::FragTable< T >::add().
Referenced by elm::genstruct::FragTable< T >::FragTable().
int elm::genstruct::FragTable< T >::alloc | ( | int | count | ) |
Allocate the given count of items in sequence in the table and return the index of the first item.
count | Count of items to allocate. |
void elm::genstruct::FragTable< T >::clean | ( | void | ) |
Use clear() instead.
References elm::genstruct::FragTable< T >::clear().
void elm::genstruct::FragTable< T >::clear | ( | void | ) |
Remove all items from the fragmeted table and release as many memory as possible.
Referenced by elm::genstruct::FragTable< T >::clean().
bool elm::genstruct::FragTable< T >::contains | ( | const T & | item | ) | const |
Test if the table contains the given item.
item | Item to look for. |
References elm::genstruct::FragTable< T >::length().
int elm::genstruct::FragTable< T >::count | ( | void | ) | const |
Same as ().
References elm::genstruct::FragTable< T >::length().
const T & elm::genstruct::FragTable< T >::get | ( | int | index | ) | const |
Get the item at the given index.
index | Index of the looked item. |
T & elm::genstruct::FragTable< T >::get | ( | int | index | ) |
Same as but return a mutable reference.
index | Index of the looked item. |
int elm::genstruct::FragTable< T >::indexOf | ( | const T & | value, |
int | start = 0 |
||
) | const |
Get the first index of a value in the array.
value | Value to look for. |
start | Start index to look at (default to 0). |
void elm::genstruct::FragTable< T >::insert | ( | int | index, |
const T & | item | ||
) |
Insert an item at the given position and move the following item in the next indexes.
index | Index to insert to. |
item | Item to insert. |
References elm::array::set().
Referenced by elm::genstruct::FragTable< T >::insert().
void elm::genstruct::FragTable< T >::insert | ( | const Iterator & | iter, |
const T & | item | ||
) |
Insert an item at the given position and move the following item in the next indexes.
iter | Location to insert to. |
item | Item to insert. |
References elm::genstruct::FragTable< T >::Iterator::i, and elm::genstruct::FragTable< T >::insert().
bool elm::genstruct::FragTable< T >::isEmpty | ( | void | ) | const |
Test if the fragmented table is empty.
References elm::genstruct::Vector< T >::count().
Referenced by elm::genstruct::FragTable< T >::operator bool().
int elm::genstruct::FragTable< T >::lastIndexOf | ( | const T & | value, |
int | start = -1 |
||
) | const |
Get the last index of a value in the array.
value | Value to look for. |
start | Start index to look back (default to -1 for end of array). |
References elm::genstruct::FragTable< T >::length().
int elm::genstruct::FragTable< T >::length | ( | void | ) | const |
Get the length / item count of the table.
Referenced by elm::genstruct::FragTable< T >::contains(), elm::genstruct::FragTable< T >::count(), and elm::genstruct::FragTable< T >::lastIndexOf().
elm::genstruct::FragTable< T >::operator bool | ( | void | ) | const |
Same as !isEmpty()/
References elm::genstruct::FragTable< T >::isEmpty().
FragTable< T > & elm::genstruct::FragTable< T >::operator+= | ( | T | value | ) |
Operator implementing FragTable::add().
const T& elm::genstruct::FragTable< T >::operator[] | ( | int | index | ) | const |
T & elm::genstruct::FragTable< T >::operator[] | ( | int | index | ) |
Operator implementing FragTable::get().
void elm::genstruct::FragTable< T >::remove | ( | const T & | item | ) |
Remove an item from the table.
item | Item to remove. |
void elm::genstruct::FragTable< T >::remove | ( | const Iterator & | iter | ) |
Remove an item pointed by an iterator.
iter | Iterator pointing to the item to remove. |
References elm::genstruct::FragTable< T >::removeAt().
void elm::genstruct::FragTable< T >::removeAll | ( | const C< T > & | items | ) |
Remove a collection of items.
items | Items to remove. |
void elm::genstruct::FragTable< T >::removeAt | ( | int | index | ) |
Remove the item at the given index and shift back following items.
index | Index of the item to remove. |
References elm::array::set().
Referenced by elm::genstruct::FragTable< T >::remove().
void elm::genstruct::FragTable< T >::removeAt | ( | const Iterator & | iter | ) |
Remove the item at the given location and shift back following items.
iter | Location of the item to remove. |
References elm::genstruct::FragTable< T >::Iterator::i, and elm::genstruct::FragTable< T >::removeAt().
Referenced by elm::genstruct::FragTable< T >::removeAt().
void elm::genstruct::FragTable< T >::set | ( | int | index, |
const T & | item | ||
) |
References elm::value().
void elm::genstruct::FragTable< T >::set | ( | const Iterator & | iter, |
const T & | item | ||
) |
References elm::genstruct::FragTable< T >::Iterator::i, and elm::genstruct::FragTable< T >::set().
Referenced by elm::genstruct::FragTable< T >::set().
void elm::genstruct::FragTable< T >::shrink | ( | int | length | ) |
Shrink the size of the table.
length | New length of the table. |