The Sparta Modeling Framework
|
An alternative to std::list, about 70% faster. More...
#include <FastList.hpp>
Classes | |
class | NodeIterator |
The internal iterator type of FastList. Use FastList<T>::[const_]iterator instead. More... | |
Public Types | |
using | value_type = DataT |
Handy using. | |
using | iterator = NodeIterator< false > |
Iterator type. | |
using | const_iterator = NodeIterator< true > |
Iterator type, const. | |
Public Member Functions | |
FastList (size_t size) | |
Construct FastList of a given size. | |
~FastList () | |
Destroy (clear) the list. | |
iterator | begin () |
Obtain a beginning iterator. | |
const_iterator | begin () const |
Obtain a beginning const_iterator. | |
iterator | end () |
Obtain an end iterator. | |
const_iterator | end () const |
Obtain an end const_iterator. | |
DataT & | front () |
Get the front of the fast list non-const. | |
const DataT & | front () const |
Get the front of the fast list, const. | |
bool | empty () const |
size_t | size () const |
size_t | max_size () const |
void | clear () noexcept |
iterator | erase (const const_iterator &entry) |
Erase an element with the given iterator. | |
template<class ... ArgsT> | |
iterator | emplace (const const_iterator &pos, ArgsT &&...args) |
template<class ... ArgsT> | |
iterator | emplace_front (ArgsT &&...args) |
Add an element to the front of the list. | |
template<class ... ArgsT> | |
iterator | emplace_back (ArgsT &&...args) |
emplace and object at the back | |
template<class ... ArgsT> | |
iterator | insert (const const_iterator &pos, ArgsT &&...args) |
void | pop_back () |
Pop the last element off of the list. | |
void | pop_front () |
Pop the first element off of the list. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const FastList< DataT > &fl) |
An alternative to std::list, about 70% faster.
T | The object to maintain |
This class is a container type that allows back emplacement and random deletion. 'std::list' provides the same type of functionality, but performs heap allocation of the internal nodes. Under the covers, this class does not perform new/delete of the Nodes, but reuses existing ones, performing an inplace-new of the user's object.
Testing shows this class is 70% faster than using std::list. Caveats:
Definition at line 46 of file FastList.hpp.
using sparta::utils::FastList< DataT >::const_iterator = NodeIterator<true> |
Iterator type, const.
Definition at line 210 of file FastList.hpp.
using sparta::utils::FastList< DataT >::iterator = NodeIterator<false> |
Iterator type.
Definition at line 209 of file FastList.hpp.
using sparta::utils::FastList< DataT >::value_type = DataT |
Handy using.
Definition at line 86 of file FastList.hpp.
|
inline |
Construct FastList of a given size.
size | Fixed size of the list |
Definition at line 190 of file FastList.hpp.
|
inline |
Destroy (clear) the list.
Definition at line 207 of file FastList.hpp.
|
inline |
Obtain a beginning iterator.
Definition at line 213 of file FastList.hpp.
|
inline |
Obtain a beginning const_iterator.
Definition at line 218 of file FastList.hpp.
|
inlinenoexcept |
Definition at line 245 of file FastList.hpp.
|
inline |
Definition at line 295 of file FastList.hpp.
|
inline |
emplace and object at the back
args | The arguments to the T constructor |
Definition at line 372 of file FastList.hpp.
|
inline |
Add an element to the front of the list.
args | Arguments to be passed to the user type for construction |
Definition at line 339 of file FastList.hpp.
|
inline |
Definition at line 235 of file FastList.hpp.
|
inline |
Obtain an end iterator.
Definition at line 223 of file FastList.hpp.
|
inline |
Obtain an end const_iterator.
Definition at line 226 of file FastList.hpp.
|
inline |
Erase an element with the given iterator.
entry | Iterator to the entry being erased |
Definition at line 256 of file FastList.hpp.
|
inline |
Get the front of the fast list non-const.
Definition at line 229 of file FastList.hpp.
|
inline |
Get the front of the fast list, const.
Definition at line 232 of file FastList.hpp.
|
inline |
Insert an element at a specific place in the list. Really just an alias for emplace
Definition at line 401 of file FastList.hpp.
|
inline |
Definition at line 241 of file FastList.hpp.
|
inline |
Pop the last element off of the list.
Definition at line 406 of file FastList.hpp.
|
inline |
Pop the first element off of the list.
Definition at line 413 of file FastList.hpp.
|
inline |
Definition at line 238 of file FastList.hpp.
|
friend |
Definition at line 422 of file FastList.hpp.