Evo C++ Library v0.5.1
|
#include <evo/list.h>
Sequential list container with random access.
T | Item type to use |
TSize | Size type to use for size/index values (must be unsigned integer) – default: SizeT |
vector
C++11:
Output:
Classes | |
struct | Buf |
List buffer data helper. More... | |
struct | Edit |
Edit buffer for advEdit(). More... | |
struct | Header |
List data header. More... | |
Public Types | |
typedef void | EvoContainerType |
typedef T | Item |
Item type (same as Value) More... | |
typedef DataCopy< T >::PassType | ItemVal |
Item type as parameter (POD types passed by value, otherwise by const-ref) More... | |
typedef IteratorRa< ThisType >::Const | Iter |
Iterator (const) - IteratorRa. More... | |
typedef IteratorRa< ThisType > | IterM |
Iterator (mutable) - IteratorRa. More... | |
typedef Size | Key |
Key type (item index) More... | |
typedef ListBase< T, Size > | ListBaseType |
List base type for any Evo list More... | |
typedef List< T, Size > | ListType |
List type for parameters More... | |
typedef TSize | Size |
List size integer type More... | |
typedef List< T, Size > | ThisType |
This list type. More... | |
typedef T | Value |
Value type (same as Item) More... | |
Public Member Functions | |
List () | |
Default constructor sets as null. More... | |
List (const ValEmpty &val) | |
Constructor sets as empty but not null. More... | |
List (const ListType &data) | |
Copy constructor. More... | |
List (const ListType &data, Key index, Key size=ALL) | |
Extended copy constructor. More... | |
List (const ListBaseType &data, Key index=0, Key size=ALL) | |
Constructor to copy sublist data. More... | |
List (const ListBaseType *data, Key index=0, Key size=ALL) | |
Constructor to copy sublist data. More... | |
List (const Item *data, Size size) | |
Constructor for data pointer. More... | |
List (const PtrBase< Item > &data, Size size) | |
Constructor to copy from managed pointer. More... | |
List (std::initializer_list< T > init) | |
Sequence constructor (C++11). More... | |
List (ListType &&src) | |
Move constructor (C++11). More... | |
ListType & | add (const Item *data, Size size) |
Append new items copied from data pointer (modifier). More... | |
ListType & | add (const ListBaseType &data) |
Append new items copied from another list (modifier). More... | |
ListType & | add (const Item &data) |
Append new item (modifier). More... | |
ListType & | addmin (Size minsize) |
Append new items up to a given minimum size (modifier). More... | |
ListType & | addnew (Size size=1) |
Append new items (modifier). More... | |
void | advAdd (Size size) |
Advanced: Append new items without initializing (constructing) them. More... | |
T * | advBuffer (Size size) |
Advanced: Resize and get buffer pointer (modifier). More... | |
T * | advBuffer () |
Advanced: Get buffer pointer (modifier). More... | |
bool | advEdit (Edit &edit, Size minsize, bool inplace=true) |
Advanced: Start optimized in-place/buffer edit. More... | |
void | advEditDone (Edit &edit) |
Advanced: Finish edit started with advEdit() (modifier). More... | |
T * | advFirst () |
Advanced: Get first item (modifier). More... | |
Key | advInsert (Key index, Size size) |
Advanced: Insert new items without initializing (constructing) them. More... | |
T & | advItem (Key index) |
Advanced: Get item (mutable). More... | |
T * | advLast () |
Advanced: Get last item (modifier). More... | |
void | advPrepend (Size size) |
Advanced: Prepend new items without initializing (constructing) them. More... | |
void | advRemove (Key index, Size size) |
Advanced: Remove given items without uninitializing (destructing) them. More... | |
ListType & | advResize (Size size) |
Advanced: Resize while preserving existing data, POD items not initialized (modifier). More... | |
void | advSize (Size size) |
Advanced: Set new size after writing directly to buffer. More... | |
void | advSwap (Key index1, Key index2) |
Advanced: Swap given items. More... | |
T * | advWrite (Size addsize) |
Advanced: Get buffer pointer to write/append (modifier). More... | |
void | advWriteDone (Size addsize) |
Advanced: Update size added after writing directly to buffer. More... | |
const ListType & | asconst () const |
Explicitly use a const reference to this. More... | |
IterM | begin () |
Get iterator at first item (mutable). More... | |
Iter | begin () const |
Get iterator at first item (const). More... | |
Size | capacity () const |
Get capacity. More... | |
ListType & | capacity (Size size) |
Set new capacity (modifier). More... | |
ListType & | capacitymax (Size max) |
Set maximum capacity (modifier). More... | |
ListType & | capacitymin (Size min) |
Set minimum capacity (modifier). More... | |
Iter | cbegin () const |
Get iterator at first item (const). More... | |
Iter | cend () const |
Get iterator at end (const). More... | |
ListType & | clear () |
Clear by removing all items. More... | |
ListType & | compact () |
Reduce capacity to fit current size (modifier). More... | |
int | compare (const ListBaseType &data) const |
Comparison. More... | |
bool | contains (ItemVal item) const |
Check whether contains given item. More... | |
bool | contains (const Item *data, Size size) const |
Check if contains given data. More... | |
bool | contains (const ListBaseType &data) const |
Check if contains given data. More... | |
ListType & | copy (const Item *data, Size size) |
Set as full (unshared) copy using data pointer (modifier). More... | |
ListType & | copy (const ListBaseType &data) |
Set as full (unshared) copy of another list (modifier). More... | |
const Item * | data () const |
Get data pointer (const). More... | |
T * | dataM () |
Get data pointer (mutable). More... | |
bool | empty () const |
Get whether empty. More... | |
IterM | end () |
Get iterator at end. More... | |
Iter | end () const |
Get iterator at end (const). More... | |
bool | ends (ItemVal item) const |
Check if this ends with given item. More... | |
bool | ends (const Item *items, Size size) const |
Check if this ends with given items. More... | |
bool | ends (const ListBaseType &items) const |
Check if this ends with given items. More... | |
ListType & | fill (const Item &item, Key index=0, Size size=ALL) |
Fill using item (modifier). More... | |
Key | find (ItemVal item, Key start=0, Key end=END) const |
Find first occurrence of item with forward search. More... | |
Key | findany (const Item *items, Size count, Key start=0, Key end=END) const |
Find first occurrence of any given items with forward search. More... | |
Key | findanyr (const Item *items, Size count, Key start=0, Key end=END) const |
Find last occurrence of any given items with reverse search. More... | |
Key | findr (ItemVal item, Key start=0, Key end=END) const |
Find last occurrence of item with reverse search. More... | |
const Item * | first () const |
Get first item (const). More... | |
Item * | firstM () |
Get first item (mutable). More... | |
ulong | hash (ulong seed=0) const |
Get data hash value. More... | |
Key | iend (Size offset=0) const |
Get index from last item using offset. More... | |
Size | insert (Key index, const Item *data, Size size) |
Insert new items copied from data pointer (modifier). More... | |
Size | insert (Key index, const ListBaseType &data) |
Insert new items copied from another list (modifier). More... | |
Size | insert (Key index, const Item &data) |
Insert new item (modifier). More... | |
Size | insertnew (Key index, Size size=1) |
Insert new items (modifier). More... | |
const Item & | item (Key index) const |
Get item at position (const). More... | |
T & | itemM (Key index) |
Get item at position (mutable). More... | |
const Item * | last () const |
Get last item (const). More... | |
Item * | lastM () |
Get last item (mutable). More... | |
void | move (Key dest, Key index) |
Move item to position (modifier). More... | |
Size | move (Key dest, ListType &src, Key srcindex=0, Size size=ALL) |
Move items from another list. More... | |
bool | null () const |
Get whether null. More... | |
bool | operator!= (const ListBaseType &data) const |
Inequality operator. More... | |
T & | operator() (Key index) |
Get item at position (mutable). More... | |
ListType & | operator<< (const Item &data) |
Append operator. More... | |
ListType & | operator<< (const ListBaseType &data) |
Append operator. More... | |
ListType & | operator<< (const ValNull &val) |
Append operator to set as null and empty. More... | |
ListType & | operator<< (const ValEmpty &val) |
Append operator to set as empty but not null. More... | |
ListType & | operator= (ListType &&src) |
Move assignment operator (C++11). More... | |
ListType & | operator= (const ListType &data) |
Assignment operator. More... | |
ListType & | operator= (const ListBaseType &data) |
Assignment operator to copy sublist. More... | |
ListType & | operator= (const ValNull &) |
Assignment operator to set as null and empty. More... | |
ListType & | operator= (const ValEmpty &) |
Assignment operator to set as empty but not null. More... | |
bool | operator== (const ListBaseType &data) const |
Equality operator. More... | |
const Item & | operator[] (Key index) const |
Get item at position (const). More... | |
bool | pop (T &item, Key index) |
Pop a copy of given item (modifier). More... | |
bool | pop (T &item) |
Pop a copy of last item (stack) (modifier). More... | |
const Item * | pop () |
Pop last item (stack). More... | |
bool | popq (T &item) |
Pop a copy of first item (queue) (modifier). More... | |
const Item * | popq () |
Pop first item (queue). More... | |
ListType & | prepend (const Item *data, Size size) |
Prepend new items copied from data pointer (modifier). More... | |
ListType & | prepend (const ListBaseType &data) |
Prepend new items copied from another list (modifier). More... | |
ListType & | prepend (const Item &data) |
Prepend new item (modifier). More... | |
ListType & | prependnew (Size size=1) |
Prepend new items (modifier). More... | |
Size | remove (Key index, Size size=1) |
Remove items (modifier). More... | |
ListType & | replace (Key index, Size rsize, const Item *data, Size size) |
Replace items with new data (modifier). More... | |
ListType & | reserve (Size size, bool prefer_realloc=false) |
Reserve capacity for additional items (modifier). More... | |
ListType & | resize (Size size) |
Resize while preserving existing data (modifier). More... | |
ListType & | reverse () |
Reverse item order (modifier). More... | |
ListType & | set () |
Set as null and empty. More... | |
ListType & | set (const Item *data, Size size) |
Set from data pointer. More... | |
ListType & | set (const PtrBase< Item > &data, Size size) |
Set from managed data pointer. More... | |
ListType & | set (const ListType &data) |
Set from another list. More... | |
ListType & | set (const ListType &data, Key index, Key size=ALL) |
Set from subset of another list. More... | |
ListType & | set (const ListBaseType &data, Key index=0, Key size=ALL) |
Set as copy of sublist. More... | |
ListType & | set2 (const ListType &data, Key index1, Key index2) |
Set from subset of another list using start/end positions. More... | |
ListType & | set2 (const ListBaseType &data, Key index1, Key index2) |
Set as copy of sublist using start/end positions. More... | |
ListType & | setempty () |
Set as empty but not null. More... | |
bool | shared () const |
Get whether shared. More... | |
Size | size () const |
Get size. More... | |
ListType & | slice (Key index) |
Slice beginning items. More... | |
ListType & | slice (Key index, Size size) |
Slice to given sublist. More... | |
ListType & | slice2 (Key index1, Key index2) |
Slice to given sublist using start/end positions. More... | |
template<class T1 , class T2 > | |
bool | splitat (Key index, T1 &left, T2 &right) const |
Split into left/right sublists at index. More... | |
template<class T1 > | |
bool | splitat (Key index, T1 &left) const |
Split into left sublist at index. More... | |
template<class T2 > | |
bool | splitat (Key index, ValNull left, T2 &right) const |
Split into right sublist at index. More... | |
bool | splitat_setl (Key index) |
Split at index and set as left sublist. More... | |
template<class T2 > | |
bool | splitat_setl (Key index, T2 &right) |
Split at index, set as left sublist, and save right sublist. More... | |
bool | splitat_setr (Key index) |
Split at index and set as right sublist. More... | |
template<class T1 > | |
bool | splitat_setr (Key index, T1 &left) |
Split at index, set as right sublist, and save left sublist. More... | |
bool | starts (ItemVal item) const |
Check if this starts with given item. More... | |
bool | starts (const Item *items, Size size) const |
Check if starts with given items. More... | |
bool | starts (const ListBaseType &items) const |
Check if this starts with given items. More... | |
void | swap (Key index1, Key index2) |
Swap items. More... | |
void | swap (ListType &list) |
Swap with another list. More... | |
ListType & | triml (Size size) |
Trim left (beginning) items. More... | |
ListType & | trimr (Size size) |
Trim right (ending) items. More... | |
ListType & | truncate (Size size=0) |
Truncate to given size. More... | |
ListType & | unshare () |
Make data unique by allocating new buffer, if needed (modifier). More... | |
ListType & | unslice () |
Clean and remove hidden items previously removed via slicing (modifier). More... | |
Public Attributes | |
T * | data_ |
Data pointer, NULL if null. More... | |
TSize | size_ |
Data size as item count, 0 if empty or null. More... | |
Protected Member Functions | |
void | ref (const ListType &data) |
Set as reference to another list. More... | |
void | ref (const ListType &data, Size index, Size size) |
Set as sliced reference to another list. More... | |
void | ref (const Item *data, Size size, bool term=false) |
Set as reference to given data. More... | |
Protected Attributes | |
Buf | buf_ |
List buffer. More... | |
typedef void EvoContainerType |
typedef T Item |
Item type (same as Value)
Item type as parameter (POD types passed by value, otherwise by const-ref)
typedef IteratorRa<ThisType>::Const Iter |
Iterator (const) - IteratorRa.
typedef IteratorRa<ThisType> IterM |
Iterator (mutable) - IteratorRa.
typedef ListBase<T,Size> ListBaseType |
List base type for any Evo list
typedef TSize Size |
List size integer type
typedef T Value |
Value type (same as Item)
|
inline |
Default constructor sets as null.
Constructor sets as empty but not null.
val | vEMPTY |
Extended copy constructor.
data | Data to copy |
index | Start index of data to copy, END to set as empty |
size | Size as item count, ALL for all from index |
|
inline |
Constructor to copy sublist data.
data | Data to copy |
index | Start index of data to reference, END to set as empty |
size | Size as item count, ALL for all from index |
|
inline |
Constructor to copy sublist data.
data | Data pointer to copy from, NULL to set as null |
index | Start index of data to reference, END to set as empty |
size | Size as item count, ALL for all from index |
Constructor for data pointer.
data | Data pointer to use |
size | Data size as item count |
Constructor to copy from managed pointer.
data | Data pointer to use |
size | Data size as item count |
|
inline |
Sequence constructor (C++11).
init | Initializer list, passed as comma-separated values in braces { } |
|
inline |
Append new items up to a given minimum size (modifier).
minsize | Minimum list size |
|
inline |
Advanced: Append new items without initializing (constructing) them.
size | Size to append |
|
inline |
Advanced: Resize and get buffer pointer (modifier).
size | Size to resize to |
|
inline |
Advanced: Get buffer pointer (modifier).
Advanced: Start optimized in-place/buffer edit.
edit | Edit buffer data, use 'edit.ptr' |
minsize | Minimum buffer size needed, must be positive |
inplace | Whether to try in-place edit, false to always use new buffer |
|
inline |
|
inline |
Advanced: Get first item (modifier).
Advanced: Insert new items without initializing (constructing) them.
index | Insert index (END for end of list) |
size | Insert data size |
|
inline |
Advanced: Get item (mutable).
index | Item index |
|
inline |
Advanced: Get last item (modifier).
|
inline |
Advanced: Prepend new items without initializing (constructing) them.
size | Size to prepend |
Advanced: Remove given items without uninitializing (destructing) them.
index | Remove index |
size | Remove size as item count, ALL for all from index |
Advanced: Resize while preserving existing data, POD items not initialized (modifier).
size | New size as item count |
|
inline |
Advanced: Set new size after writing directly to buffer.
size | New size |
Advanced: Swap given items.
index1 | Index of first item to swap |
index2 | Index of second item to swap |
|
inline |
Advanced: Get buffer pointer to write/append (modifier).
addsize | Max size to write/append, must be at least 1 |
|
inline |
Advanced: Update size added after writing directly to buffer.
addsize | Actual size written |
|
inline |
Explicitly use a const reference to this.
|
inline |
|
inline |
Get iterator at first item (const).
|
inline |
Set new capacity (modifier).
size | New capacity |
Set maximum capacity (modifier).
max | Maximum capacity |
Set minimum capacity (modifier).
min | Minimum capacity |
|
inline |
|
inline |
|
inline |
Clear by removing all items.
|
inline |
Reduce capacity to fit current size (modifier).
|
inline |
Comparison.
data | Data to compare to |
|
inline |
Check whether contains given item.
item | Item to check for |
Check if contains given data.
data | Data to check for |
size | Size as item count to check for |
|
inline |
Check if contains given data.
data | Data to check for |
Set as full (unshared) copy using data pointer (modifier).
data | Data to copy |
size | Data size as item count |
|
inline |
Set as full (unshared) copy of another list (modifier).
data | Data to copy |
|
inline |
Get data pointer (const).
|
inline |
|
inline |
|
inline |
|
inline |
Get iterator at end (const).
|
inline |
Check if this ends with given item.
item | Item to check |
Check if this ends with given items.
items | Items to check |
size | Item count to check |
|
inline |
Check if this ends with given items.
items | Items to check |
Fill using item (modifier).
item | Item to fill with |
index | Start index, END to start at end and append |
size | Size to fill as item count from index, ALL for all items from index, 0 to do nothing |
Find first occurrence of item with forward search.
item | Item to find |
start | Starting index for search |
end | End index for search, END for end of list |
Find first occurrence of any given items with forward search.
items | Items to search for |
count | Count of items to search for |
start | Starting index for search |
end | End index for search, END for end of list |
Find last occurrence of any given items with reverse search.
items | Items to search for |
count | Count of items to search for |
start | Starting index for search range – last item checked in reverse search |
end | End index for search range (reverse search starting point), END for end of list |
Find last occurrence of item with reverse search.
item | Item to find |
start | Starting index for search range – last item checked in reverse search |
end | End index for search range (reverse search starting point), END for end of list |
|
inline |
Get first item (const).
|
inline |
Get first item (mutable).
|
inline |
Get data hash value.
seed | Seed value for hashing multiple values, 0 if none |
Get index from last item using offset.
offset | Offset from end, 0 for last item, 1 for second-last, etc |
Insert new items copied from data pointer (modifier).
index | Insert index, END to append |
data | Data to insert |
size | Size as item count to insert |
|
inline |
Insert new items copied from another list (modifier).
index | Insert index, END to append |
data | Data to insert |
Insert new item (modifier).
index | Insert index, END to append |
data | Data to insert |
Insert new items (modifier).
index | Insert index, END to append |
size | Size as item count to insert |
Get item at position (const).
index | Item index |
|
inline |
Get item at position (mutable).
index | Item index |
|
inline |
Get last item (const).
|
inline |
Move item to position (modifier).
dest | Destination index to move item to, END to move to end |
index | Item index to move from |
Move items from another list.
dest | Destination index to insert moved items, END for append |
src | Source to move from |
srcindex | Source index to move items from |
size | Size as item count to move from source |
|
inline |
Get whether null.
|
inline |
Inequality operator.
data | Data to compare to |
|
inline |
Get item at position (mutable).
index | Item index |
Append operator.
data | Data to append |
|
inline |
Append operator.
data | Data to append |
Append operator to set as empty but not null.
val | vEMPTY |
Move assignment operator (C++11).
src | Source to move |
Assignment operator.
data | Data to copy |
|
inline |
Assignment operator to copy sublist.
data | Data to copy |
|
inline |
Equality operator.
data | Data to compare to |
Get item at position (const).
index | Item index |
|
inline |
Pop a copy of given item (modifier).
item | Stores popped item [out] |
index | Index to pop |
|
inline |
Pop a copy of last item (stack) (modifier).
item | Stores popped item [out] |
|
inline |
|
inline |
Pop a copy of first item (queue) (modifier).
item | Stores popped item [out] |
|
inline |
|
inline |
Prepend new item (modifier).
data | Data to prepend |
|
inlineprotected |
Set as reference to another list.
data | Data to reference |
Set as sliced reference to another list.
data | Data to reference |
index | Start index of data, END to set as empty |
size | Size as item count, ALL for all from index |
Set as reference to given data.
data | Data to reference |
size | Data size |
term | Whether referenced data is terminated |
Remove items (modifier).
index | Remove index |
size | Remove size, ALL for all items from index |
Replace items with new data (modifier).
index | Start index to replace |
rsize | Size as item count from index to replace, ALL for all items from index |
data | Replacement data to copy |
size | Replacement data size as item count |
Reserve capacity for additional items (modifier).
size | Size as item count to reserve |
prefer_realloc | Advanced: True to prefer realloc for certain conditition where would otherwise unslice via alloc and move to new buffer |
Resize while preserving existing data (modifier).
size | New size as item count |
|
inline |
Set as null and empty.
Set from data pointer.
data | Data pointer to use |
size | Data size as item count |
Set from managed data pointer.
data | Data pointer to copy |
size | Data size as item count |
Set from another list.
data | Data to copy |
Set from subset of another list.
data | Data to copy |
index | Start index of data, END to set as empty |
size | Data size as item count, ALL for all from index |
|
inline |
Set as copy of sublist.
data | Data to copy |
index | Start index of sublist data, END to set as empty |
size | Data size as item count, ALL for all from index |
Set from subset of another list using start/end positions.
data | Data to copy |
index1 | Start index of new slice, END to slice all items from beginning |
index2 | End index of new slice (this item not included), END for all after index1 |
|
inline |
Set as copy of sublist using start/end positions.
data | Data to copy |
index1 | Start index of sublist data, END to set as empty |
index2 | End index of sublist data (this item not included), END for all after index1 |
|
inline |
Set as empty but not null.
|
inline |
Get whether shared.
|
inline |
Get size.
Slice beginning items.
index | Start index of new slice, END to slice (remove) all items from beginning |
Slice to given sublist.
index | Start index of new slice, END to slice (remove) all items from beginning |
size | Slice size as item count, ALL for all from index |
Slice to given sublist using start/end positions.
index1 | Start index of new slice, END to slice all items from beginning |
index2 | End index of new slice (this item not included), END for all after index1 |
|
inline |
Split into left/right sublists at index.
T1 | List type to store left sublist |
T2 | List type to store right sublist |
index | Index to split at, bad index (NONE or out-of-bounds) splits at end |
left | Set to sublist before index, set to this if bad index [out] |
right | Set to sublist after index, null if bad index [out] |
|
inline |
Split into left sublist at index.
T1 | List type to store left sublist |
index | Index to split at, bad index (NONE or out-of-bounds) splits at end |
left | Set to sublist before index, set to this if bad index [out] |
Split into right sublist at index.
T2 | List type to store right sublist |
index | Index to split at, bad index (NONE or out-of-bounds) splits at end |
left | vNULL (ignored) |
right | Set to sublist after index, null if bad index [out] |
|
inline |
Split at index and set as left sublist.
index | Index to split at, bad index (NONE or out-of-bounds) splits at end (i.e. unchanged) |
|
inline |
Split at index, set as left sublist, and save right sublist.
index | Index to split at, bad index (NONE or out-of-bounds) splits at end (i.e. unchanged) |
right | Set to sublist after index, null if bad index [out] |
|
inline |
|
inline |
Split at index, set as right sublist, and save left sublist.
index | Index to split at, bad index (NONE or out-of-bounds) splits at end |
left | Set to sublist before index, set to this if bad index [out] |
|
inline |
Check if this starts with given item.
item | Item to check |
Check if starts with given items.
items | Items to check |
size | Size as item count to check |
|
inline |
Check if this starts with given items.
items | Items to check |
Swap items.
index1 | Index of first item to swap |
index2 | Index of second item to swap |
|
inline |
Swap with another list.
list | List to swap with |
Trim left (beginning) items.
size | Trim size as item count to remove |
Trim right (ending) items.
size | Trim size as item count to remove |
Truncate to given size.
size | Size to truncate to as item count |
|
inline |
Make data unique by allocating new buffer, if needed (modifier).
|
inline |
Clean and remove hidden items previously removed via slicing (modifier).
|
inherited |
Data pointer, NULL if null.
|
inherited |
Data size as item count, 0 if empty or null.