Evo C++ Library v0.5.1
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
List< T, TSize > Class Template Reference

#include <evo/list.h>

Inheritance diagram for List< T, TSize >:
Inheritance graph
[legend]

Detailed Description

template<class T, class TSize = SizeT>
class evo::List< T, TSize >

Sequential list container with random access.

Template Parameters
TItem type to use
TSizeSize type to use for size/index values (must be unsigned integer) – default: SizeT
Features

C++11:

Iterators
Constructors
Read Access
Slicing
Modifiers
Advanced
Example
#include <evo/list.h>
#include <evo/io.h>
using namespace evo;
static Console& c = con();
int main() {
// Create number list, add some numbers
List<int> list;
list.add(1);
list << 2 << 3;
// operator[] provides read-only (const) access
int value = list[0];
//list[0] = 0; // Error: operator[] is read-only (const)
// operator() provides write (mutable) access
list(0) = 0; // Allowed: operator() is mutable
// Iterate and modify items (mutable)
for (List<int>::IterM iter(list); iter; ++iter)
(*iter) += 10; // Parenthesis not required, only used to workaround doxygen formatting bug
// Iterate and print items (read-only)
for (List<int>::Iter iter(list); iter; ++iter)
c.out << "Item: " << *iter << NL;
return 0;
}

Output:

Item: 10
Item: 12
Item: 13

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< ThisTypeIterM
 Iterator (mutable) - IteratorRa. More...
 
typedef Size Key
 Key type (item index) More...
 
typedef ListBase< T, SizeListBaseType
 List base type for any Evo list More...
 
typedef List< T, SizeListType
 List type for parameters More...
 
typedef TSize Size
 List size integer type More...
 
typedef List< T, SizeThisType
 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...
 
ListTypeadd (const Item *data, Size size)
 Append new items copied from data pointer (modifier). More...
 
ListTypeadd (const ListBaseType &data)
 Append new items copied from another list (modifier). More...
 
ListTypeadd (const Item &data)
 Append new item (modifier). More...
 
ListTypeaddmin (Size minsize)
 Append new items up to a given minimum size (modifier). More...
 
ListTypeaddnew (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...
 
ListTypeadvResize (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 ListTypeasconst () 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...
 
ListTypecapacity (Size size)
 Set new capacity (modifier). More...
 
ListTypecapacitymax (Size max)
 Set maximum capacity (modifier). More...
 
ListTypecapacitymin (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...
 
ListTypeclear ()
 Clear by removing all items. More...
 
ListTypecompact ()
 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...
 
ListTypecopy (const Item *data, Size size)
 Set as full (unshared) copy using data pointer (modifier). More...
 
ListTypecopy (const ListBaseType &data)
 Set as full (unshared) copy of another list (modifier). More...
 
const Itemdata () 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...
 
ListTypefill (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 Itemfirst () const
 Get first item (const). More...
 
ItemfirstM ()
 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 Itemitem (Key index) const
 Get item at position (const). More...
 
T & itemM (Key index)
 Get item at position (mutable). More...
 
const Itemlast () const
 Get last item (const). More...
 
ItemlastM ()
 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...
 
ListTypeoperator<< (const Item &data)
 Append operator. More...
 
ListTypeoperator<< (const ListBaseType &data)
 Append operator. More...
 
ListTypeoperator<< (const ValNull &val)
 Append operator to set as null and empty. More...
 
ListTypeoperator<< (const ValEmpty &val)
 Append operator to set as empty but not null. More...
 
ListTypeoperator= (ListType &&src)
 Move assignment operator (C++11). More...
 
ListTypeoperator= (const ListType &data)
 Assignment operator. More...
 
ListTypeoperator= (const ListBaseType &data)
 Assignment operator to copy sublist. More...
 
ListTypeoperator= (const ValNull &)
 Assignment operator to set as null and empty. More...
 
ListTypeoperator= (const ValEmpty &)
 Assignment operator to set as empty but not null. More...
 
bool operator== (const ListBaseType &data) const
 Equality operator. More...
 
const Itemoperator[] (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 Itempop ()
 Pop last item (stack). More...
 
bool popq (T &item)
 Pop a copy of first item (queue) (modifier). More...
 
const Itempopq ()
 Pop first item (queue). More...
 
ListTypeprepend (const Item *data, Size size)
 Prepend new items copied from data pointer (modifier). More...
 
ListTypeprepend (const ListBaseType &data)
 Prepend new items copied from another list (modifier). More...
 
ListTypeprepend (const Item &data)
 Prepend new item (modifier). More...
 
ListTypeprependnew (Size size=1)
 Prepend new items (modifier). More...
 
Size remove (Key index, Size size=1)
 Remove items (modifier). More...
 
ListTypereplace (Key index, Size rsize, const Item *data, Size size)
 Replace items with new data (modifier). More...
 
ListTypereserve (Size size, bool prefer_realloc=false)
 Reserve capacity for additional items (modifier). More...
 
ListTyperesize (Size size)
 Resize while preserving existing data (modifier). More...
 
ListTypereverse ()
 Reverse item order (modifier). More...
 
ListTypeset ()
 Set as null and empty. More...
 
ListTypeset (const Item *data, Size size)
 Set from data pointer. More...
 
ListTypeset (const PtrBase< Item > &data, Size size)
 Set from managed data pointer. More...
 
ListTypeset (const ListType &data)
 Set from another list. More...
 
ListTypeset (const ListType &data, Key index, Key size=ALL)
 Set from subset of another list. More...
 
ListTypeset (const ListBaseType &data, Key index=0, Key size=ALL)
 Set as copy of sublist. More...
 
ListTypeset2 (const ListType &data, Key index1, Key index2)
 Set from subset of another list using start/end positions. More...
 
ListTypeset2 (const ListBaseType &data, Key index1, Key index2)
 Set as copy of sublist using start/end positions. More...
 
ListTypesetempty ()
 Set as empty but not null. More...
 
bool shared () const
 Get whether shared. More...
 
Size size () const
 Get size. More...
 
ListTypeslice (Key index)
 Slice beginning items. More...
 
ListTypeslice (Key index, Size size)
 Slice to given sublist. More...
 
ListTypeslice2 (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...
 
ListTypetriml (Size size)
 Trim left (beginning) items. More...
 
ListTypetrimr (Size size)
 Trim right (ending) items. More...
 
ListTypetruncate (Size size=0)
 Truncate to given size. More...
 
ListTypeunshare ()
 Make data unique by allocating new buffer, if needed (modifier). More...
 
ListTypeunslice ()
 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...
 

Member Typedef Documentation

◆ EvoContainerType

typedef void EvoContainerType

◆ Item

typedef T Item

Item type (same as Value)

◆ ItemVal

typedef DataCopy<T>::PassType ItemVal

Item type as parameter (POD types passed by value, otherwise by const-ref)

◆ Iter

typedef IteratorRa<ThisType>::Const Iter

Iterator (const) - IteratorRa.

◆ IterM

Iterator (mutable) - IteratorRa.

◆ Key

typedef Size Key

Key type (item index)

◆ ListBaseType

List base type for any Evo list

◆ ListType

typedef List<T,Size> ListType

List type for parameters

◆ Size

typedef TSize Size

List size integer type

◆ ThisType

typedef List<T,Size> ThisType

This list type.

◆ Value

typedef T Value

Value type (same as Item)

Constructor & Destructor Documentation

◆ List() [1/10]

List ( )
inline

Default constructor sets as null.

◆ List() [2/10]

List ( const ValEmpty val)
inlineexplicit

Constructor sets as empty but not null.

Parameters
valvEMPTY

◆ List() [3/10]

List ( const ListType data)
inline

Copy constructor.

  • Makes shared copy if possible – see Sharing
Parameters
dataData to copy

◆ List() [4/10]

List ( const ListType data,
Key  index,
Key  size = ALL 
)
inline

Extended copy constructor.

  • Makes shared copy if possible – see Sharing
Parameters
dataData to copy
indexStart index of data to copy, END to set as empty
sizeSize as item count, ALL for all from index

◆ List() [5/10]

List ( const ListBaseType data,
Key  index = 0,
Key  size = ALL 
)
inline

Constructor to copy sublist data.

Parameters
dataData to copy
indexStart index of data to reference, END to set as empty
sizeSize as item count, ALL for all from index

◆ List() [6/10]

List ( const ListBaseType data,
Key  index = 0,
Key  size = ALL 
)
inline

Constructor to copy sublist data.

Parameters
dataData pointer to copy from, NULL to set as null
indexStart index of data to reference, END to set as empty
sizeSize as item count, ALL for all from index

◆ List() [7/10]

List ( const Item data,
Size  size 
)
inline

Constructor for data pointer.

Parameters
dataData pointer to use
sizeData size as item count

◆ List() [8/10]

List ( const PtrBase< Item > &  data,
Size  size 
)
inline

Constructor to copy from managed pointer.

Parameters
dataData pointer to use
sizeData size as item count

◆ List() [9/10]

List ( std::initializer_list< T >  init)
inline

Sequence constructor (C++11).

Parameters
initInitializer list, passed as comma-separated values in braces { }

◆ List() [10/10]

List ( ListType &&  src)
inline

Move constructor (C++11).

Parameters
srcSource to move

Member Function Documentation

◆ add() [1/3]

ListType& add ( const Item data,
Size  size 
)
inline

Append new items copied from data pointer (modifier).

Parameters
dataData to append
sizeSize as item count to append
Returns
This

◆ add() [2/3]

ListType& add ( const ListBaseType data)
inline

Append new items copied from another list (modifier).

Parameters
dataData to append
Returns
This

◆ add() [3/3]

ListType& add ( const Item data)
inline

Append new item (modifier).

Parameters
dataData to append
Returns
This

◆ addmin()

ListType& addmin ( Size  minsize)
inline

Append new items up to a given minimum size (modifier).

  • This calls addnew() to add items as needed to reach given minimum size
Parameters
minsizeMinimum list size
Returns
This

◆ addnew()

ListType& addnew ( Size  size = 1)
inline

Append new items (modifier).

Parameters
sizeSize as item count to append
Returns
This

◆ advAdd()

void advAdd ( Size  size)
inline

Advanced: Append new items without initializing (constructing) them.

  • Caution: Data must be unique (not shared) or results are undefined
  • Caution: The new items must be initialized with DataInit::init_safe() or removed with advRemove() before items are accessed, modified, or list is destroyed
  • Caution: Results are undefined if new items are left uninitialized
Parameters
sizeSize to append

◆ advBuffer() [1/2]

T* advBuffer ( Size  size)
inline

Advanced: Resize and get buffer pointer (modifier).

  • Used for writing directly to buffer – this calls advResize() first to make room
  • For best performance call clear() first
  • Call advSize() after writing to adjust size, if needed
  • Caution: Results are undefined if buffer is accessed after size
  • Caution: For non-POD type results are undefined if don't initialize new items or uninitialize removed items correctly
Parameters
sizeSize to resize to
Returns
Buffer pointer

◆ advBuffer() [2/2]

T* advBuffer ( )
inline

Advanced: Get buffer pointer (modifier).

  • Used for writing directly to buffer
  • Buffer must be resized first to make room – see advBuffer(Size), advResize(), resize()
  • Call advSize() after writing to adjust size, if needed
  • Caution: Data must be unique (not shared) when writing or results are undefined
  • Caution: Results are undefined if buffer is accessed out of bounds
  • Caution: For non-POD type results are undefined if don't initialize new items or uninitialize removed items correctly
Returns
Buffer pointer, NULL for none

◆ advEdit()

bool advEdit ( Edit edit,
Size  minsize,
bool  inplace = true 
)
inline

Advanced: Start optimized in-place/buffer edit.

  • This approach optimizes by selecting the best case for editing (in-place or new buffer), and the caller must handle each case correctly
  • For easier approach use advBuffer(Size) and always edit in-place – but is less efficient in certain cases, like when buffer grows
  • If the current buffer is unique and big enough (and beginning isn't sliced, and inplace flag is set):
    • This sets 'edit.ptr' and 'edit.size' to current buffer and size, and returns true to edit in-place
    • Modify buffer as needed via 'edit.ptr', update 'edit.size'
    • Call advEditDone() when done to adjust to new size
    • Note: If you don't call advEditDone() then in-place edits will still remain and the previous size will be used
  • Otherwise a new empty buffer is created:
    • This sets 'edit.ptr' to a new buffer and 'edit.size' to 0, and returns false
    • Write to buffer in 'edit.ptr' as needed, copy from data() or use edit.write() methods if needed, update 'edit.size'
    • Call advEditDone() when done to use new buffer and new size
    • Note: If you don't call advEditDone() then Edit destructor will still free the new buffer (no memory leak)
  • This is mainly intended for POD types
  • Caution: Results are undefined if another modifier method is used during an edit
  • Caution: Results are undefined if edit buffer is accessed after minsize
  • Caution: For non-POD type, results are undefined if you don't initialize new items or don't uninitialize removed items correctly
Parameters
editEdit buffer data, use 'edit.ptr'
minsizeMinimum buffer size needed, must be positive
inplaceWhether to try in-place edit, false to always use new buffer
Returns
Whether editing in-place, false if a new empty buffer was created

◆ advEditDone()

void advEditDone ( Edit edit)
inline

Advanced: Finish edit started with advEdit() (modifier).

  • Must call advEdit() first to start edit
  • This applies the pending edit and makes it permanent
Parameters
editEdit data set from advEdit()

◆ advFirst()

T* advFirst ( )
inline

Advanced: Get first item (modifier).

  • Caution: This does not call unshare() – results are undefined if in a shared state
Returns
First item pointer, NULL if empty

◆ advInsert()

Key advInsert ( Key  index,
Size  size 
)
inline

Advanced: Insert new items without initializing (constructing) them.

  • Caution: Data must be unique (not shared) or results are undefined
  • Caution: The new items must be initialized with DataInit::init_safe() or removed with advRemove() before items are accessed, modified, or list is destroyed
  • Caution: Results are undefined if new items are left uninitialized
Parameters
indexInsert index (END for end of list)
sizeInsert data size
Returns
Actual insert index

◆ advItem()

T& advItem ( Key  index)
inline

Advanced: Get item (mutable).

  • Caution: Data must be unique (not shared) or results are undefined
  • Caution: Results are undefined if index is out of bounds – though index is checked with assert()
Parameters
indexItem index
Returns
Given item

◆ advLast()

T* advLast ( )
inline

Advanced: Get last item (modifier).

  • Caution: This does not call unshare() – results are undefined if in a shared state
Returns
Last item pointer, NULL if empty

◆ advPrepend()

void advPrepend ( Size  size)
inline

Advanced: Prepend new items without initializing (constructing) them.

  • Caution: Data must be unique (not shared) or results are undefined
  • Caution: The new items must be initialized with DataInit::init_safe() or removed with advRemove() before items are accessed, modified, or list is destroyed
  • Caution: Results are undefined if new items are left uninitialized
Parameters
sizeSize to prepend

◆ advRemove()

void advRemove ( Key  index,
Size  size 
)
inline

Advanced: Remove given items without uninitializing (destructing) them.

  • Caution: Use only to remove uninitialized items – use DataInit::uninit() to uninitialize items that have been initialized
  • Caution: Data must be unique (not shared) or results are undefined
  • Caution: Uninitialized items must be initialized with DataInit::init_safe() or removed with advRemove() before items are accessed, modified, or list is destroyed
Parameters
indexRemove index
sizeRemove size as item count, ALL for all from index

◆ advResize()

ListType& advResize ( Size  size)
inline

Advanced: Resize while preserving existing data, POD items not initialized (modifier).

  • This is a slightly modified version of resize():
    • No difference on non POD item types
    • For POD item type: New items created here will not be initialized/zeroed
    • This gives a slight performance increase in some cases but will leave uninitialized garbage data for POD items
    • In most cases resize() is preferred since it's safer and the performance difference is usually negligible
  • This adds/removes items as needed until given size is reached
  • Effectively calls unshare()
  • Advanced: See advBuffer() for getting writable pointer to buffer
Parameters
sizeNew size as item count
Returns
This

◆ advSize()

void advSize ( Size  size)
inline

Advanced: Set new size after writing directly to buffer.

  • Used after calling advBuffer() and writing to buffer
  • Caution: Using this on non POD list can create/leave uninitialized items and undefined results
  • Caution: Data must be unique (not shared) when writing or results are undefined
  • Caution: No bounds checking is used on new size
Parameters
sizeNew size

◆ advSwap()

void advSwap ( Key  index1,
Key  index2 
)
inline

Advanced: Swap given items.

  • A faster version of swap() without bounds checking
  • Caution: Data must be unique (not shared) and indexes must be valid or results are undefined
Parameters
index1Index of first item to swap
index2Index of second item to swap

◆ advWrite()

T* advWrite ( Size  addsize)
inline

Advanced: Get buffer pointer to write/append (modifier).

  • Used for appending by writing directly to buffer – this calls unslice() and resrve() first to make room
  • Call advWriteDone() after writing to adjust actual size used, skip if nothing written
  • Caution: Results are undefined if buffer is accessed after addsize
  • Caution: For non-POD type results are undefined if don't initialize new items items correctly
Parameters
addsizeMax size to write/append, must be at least 1
Returns
Pointer to buffer to write to (after existing data)

◆ advWriteDone()

void advWriteDone ( Size  addsize)
inline

Advanced: Update size added after writing directly to buffer.

  • Used after calling advWrite() and writing to buffer
    • No need to call this if nothing written
  • Caution: Using this on non POD list can create uninitialized items and undefined results
  • Caution: Data must be unique (not shared) when writing or results are undefined – advWrite() covers this
  • Caution: No bounds checking is used on addsize
Parameters
addsizeActual size written

◆ asconst()

const ListType& asconst ( ) const
inline

Explicitly use a const reference to this.

  • This is useful to force using this as const without casting
Returns
This

◆ begin() [1/2]

IterM begin ( )
inline

Get iterator at first item (mutable).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
  • cbegin() is more efficient, since this effectively calls unshare() to make items mutable
Returns
Iterator at first item, or at end position if empty
See also
IterM, end(), cbegin(), cend()

◆ begin() [2/2]

Iter begin ( ) const
inline

Get iterator at first item (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
Returns
Iterator at first item, or at end position if empty
See also
end() const, cbegin()

◆ capacity() [1/2]

Size capacity ( ) const
inline

Get capacity.

  • This gets the total size of currently allocated buffer
  • Data still may be referenced without a buffer so this could return less than size()
  • Buffer may be allocated (by previous use) even though not currently used
Returns
Capacity as item count, 0 if no buffer allocated

◆ capacity() [2/2]

ListType& capacity ( Size  size)
inline

Set new capacity (modifier).

  • Consider using reserve() instead to allocate additional capacity in advance
  • Items that don't fit new capacity are removed, even if buffer isn't used
  • Effectively calls unshare() if buffer is shared
  • May still reference external data even though buffer is allocated
  • Use unshare() to force data to buffer
Parameters
sizeNew capacity
Returns
This

◆ capacitymax()

ListType& capacitymax ( Size  max)
inline

Set maximum capacity (modifier).

  • This reduces capacity to given maximum if it's greater
  • Items that don't fit new capacity are removed, even if buffer isn't used
  • Effectively calls unshare() if capacity changes and buffer is shared
  • May still reference external data even though buffer is allocated
  • Use unshare() to force data to buffer
Parameters
maxMaximum capacity
Returns
This

◆ capacitymin()

ListType& capacitymin ( Size  min)
inline

Set minimum capacity (modifier).

  • This increases capacity to given minimum if it's less
  • Effectively calls unshare() if capacity changes and buffer is shared
  • May still reference external data even though buffer is allocated
  • Use unshare() to force data to buffer
Parameters
minMinimum capacity
Returns
This

◆ cbegin()

Iter cbegin ( ) const
inline

Get iterator at first item (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
Returns
Iterator at first item, or at end position if empty
See also
Iter, cend(), begin(), end()

◆ cend()

Iter cend ( ) const
inline

Get iterator at end (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
  • This really just creates an empty iterator
Returns
Iterator at end position
See also
Iter, cbegin(), begin(), end()

◆ clear()

ListType& clear ( )
inline

Clear by removing all items.

  • Does not set as null – null status is unchanged
  • Append operators can be chained
    Example:
    // Clear character list and append two characters
    list.clear() << 'a' << 'b';
Returns
This

◆ compact()

ListType& compact ( )
inline

Reduce capacity to fit current size (modifier).

  • Call to save memory when done expanding size
  • Ignored if shared, may want to call unshare() first
Returns
This

◆ compare()

int compare ( const ListBaseType data) const
inline

Comparison.

Parameters
dataData to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ contains() [1/3]

bool contains ( ItemVal  item) const
inline

Check whether contains given item.

  • This does a simple linear search for given item, using item operator==() for comparisons
Parameters
itemItem to check for
Returns
Whether item was found

◆ contains() [2/3]

bool contains ( const Item data,
Size  size 
) const
inline

Check if contains given data.

  • This does a simple linear search for given array of items, using item operator==() for comparisons
Parameters
dataData to check for
sizeSize as item count to check for
Returns
Whether data was found

◆ contains() [3/3]

bool contains ( const ListBaseType data) const
inline

Check if contains given data.

  • This does a simple linear search for given array of items, using item operator==() for comparisons
Parameters
dataData to check for
Returns
Whether data was found

◆ copy() [1/2]

ListType& copy ( const Item data,
Size  size 
)
inline

Set as full (unshared) copy using data pointer (modifier).

Parameters
dataData to copy
sizeData size as item count
Returns
This

◆ copy() [2/2]

ListType& copy ( const ListBaseType data)
inline

Set as full (unshared) copy of another list (modifier).

Parameters
dataData to copy
Returns
This

◆ data()

const Item* data ( ) const
inline

Get data pointer (const).

  • Caution: May return an invalid non-NULL pointer if empty
  • Caution: Calling any modifier/mutable method like unshare() after this may (will) invalidate the returned pointer
Returns
Data pointer as read-only, NULL if null, may be invalid if empty (const)

◆ dataM()

T* dataM ( )
inline

Get data pointer (mutable).

  • Calls unshare()
  • Caution: Calling any modifier method like add() after this may (will) invalidate the returned pointer
  • For best performance, reuse returned pointer for repeated access, or use data() instead for read-only access
Returns
Data pointer (mutable).

◆ empty()

bool empty ( ) const
inline

Get whether empty.

Returns
Whether empty

◆ end() [1/2]

IterM end ( )
inline

Get iterator at end.

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
  • This really just creates an empty iterator
Returns
Iterator at end position
See also
IterM, begin(), cbegin(), cend()

◆ end() [2/2]

Iter end ( ) const
inline

Get iterator at end (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
  • This really just creates an empty iterator
Returns
Iterator at end position
See also
begin() const, cend()

◆ ends() [1/3]

bool ends ( ItemVal  item) const
inline

Check if this ends with given item.

  • Uses item operator==() for comparisons
Parameters
itemItem to check
Returns
Whether ends with item

◆ ends() [2/3]

bool ends ( const Item items,
Size  size 
) const
inline

Check if this ends with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
sizeItem count to check
Returns
Whether ends with items

◆ ends() [3/3]

bool ends ( const ListBaseType items) const
inline

Check if this ends with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
Returns
Whether ends with items

◆ fill()

ListType& fill ( const Item item,
Key  index = 0,
Size  size = ALL 
)
inline

Fill using item (modifier).

  • Calls unshare() if any filling done
  • Resizes to fill new items if needed
Parameters
itemItem to fill with
indexStart index, END to start at end and append
sizeSize to fill as item count from index, ALL for all items from index, 0 to do nothing

◆ find()

Key find ( ItemVal  item,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of item with forward search.

  • This searches for given item, using item operator==() for comparisons
  • Search stops before reaching end index or end of list
  • Item at end index is not checked
Parameters
itemItem to find
startStarting index for search
endEnd index for search, END for end of list
Returns
Found item index or NONE if not found

◆ findany()

Key findany ( const Item items,
Size  count,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of any given items with forward search.

  • This searches for any of given items, using item operator==() for comparisons
  • Search stops before reaching end index or end of list
Parameters
itemsItems to search for
countCount of items to search for
startStarting index for search
endEnd index for search, END for end of list
Returns
Found item index or NONE if not found

◆ findanyr()

Key findanyr ( const Item items,
Size  count,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of any given items with reverse search.

  • This searches for any of given items, using item operator==() for comparisons
  • Same as findany() but does reverse search starting right before end index or at last item if end of list
  • As with findany(), item at end index is not checked
Parameters
itemsItems to search for
countCount of items to search for
startStarting index for search range – last item checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found item index or NONE if not found

◆ findr()

Key findr ( ItemVal  item,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of item with reverse search.

  • This searches for given item, using item operator==() for comparisons
  • This does a reverse search starting right before end index
  • Item at end index is not checked
Parameters
itemItem to find
startStarting index for search range – last item checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found item index or NONE if not found

◆ first()

const Item* first ( ) const
inline

Get first item (const).

Returns
First item pointer, NULL if empty

◆ firstM()

Item* firstM ( )
inline

Get first item (mutable).

Returns
First item pointer, NULL if empty

◆ hash()

ulong hash ( ulong  seed = 0) const
inline

Get data hash value.

Parameters
seedSeed value for hashing multiple values, 0 if none
Returns
Hash value

◆ iend()

Key iend ( Size  offset = 0) const
inline

Get index from last item using offset.

  • This simplifies math when computing an index from last item
  • This uses the formula: iend = size - 1 - offset
Parameters
offsetOffset from end, 0 for last item, 1 for second-last, etc
Returns
Resulting index, END if offset out of bounds

◆ insert() [1/3]

Size insert ( Key  index,
const Item data,
Size  size 
)
inline

Insert new items copied from data pointer (modifier).

Parameters
indexInsert index, END to append
dataData to insert
sizeSize as item count to insert
Returns
Inserted index

◆ insert() [2/3]

Size insert ( Key  index,
const ListBaseType data 
)
inline

Insert new items copied from another list (modifier).

Parameters
indexInsert index, END to append
dataData to insert
Returns
Inserted index

◆ insert() [3/3]

Size insert ( Key  index,
const Item data 
)
inline

Insert new item (modifier).

Parameters
indexInsert index, END to append
dataData to insert
Returns
Inserted index

◆ insertnew()

Size insertnew ( Key  index,
Size  size = 1 
)
inline

Insert new items (modifier).

Parameters
indexInsert index, END to append
sizeSize as item count to insert
Returns
Inserted index

◆ item()

const Item& item ( Key  index) const
inline

Get item at position (const).

  • Caution: Results are undefined if index is out of bounds
Parameters
indexItem index
Returns
Given item as read-only (const)

◆ itemM()

T& itemM ( Key  index)
inline

Get item at position (mutable).

  • Calls unshare()
  • For best performance, use operator[]() or item() instead for read-only access, or dataM() to get mutable pointer for repeated access
  • Caution: Results are undefined if index is out of bounds – though index is checked with assert()
Parameters
indexItem index
Returns
Given item (mutable)

◆ last()

const Item* last ( ) const
inline

Get last item (const).

Returns
Last item pointer, NULL if empty

◆ lastM()

Item* lastM ( )
inline

Get last item (mutable).

Returns
Last item pointer, NULL if empty

◆ move() [1/2]

void move ( Key  dest,
Key  index 
)
inline

Move item to position (modifier).

  • This will remove item at index and insert it at dest, shifting items in between as needed
  • If item is moved left it will be inserted before item at dest
  • If item is moved right it will be inserted after item at dest, since items are shifted before insert
Parameters
destDestination index to move item to, END to move to end
indexItem index to move from

◆ move() [2/2]

Size move ( Key  dest,
ListType src,
Key  srcindex = 0,
Size  size = ALL 
)
inline

Move items from another list.

  • Effectively calls unshare() on both this and src, if any items moved
Parameters
destDestination index to insert moved items, END for append
srcSource to move from
srcindexSource index to move items from
sizeSize as item count to move from source

◆ null()

bool null ( ) const
inline

Get whether null.

  • Always empty when null
Returns
Whether null

◆ operator!=()

bool operator!= ( const ListBaseType data) const
inline

Inequality operator.

Parameters
dataData to compare to
Returns
Whether inequal

◆ operator()()

T& operator() ( Key  index)
inline

Get item at position (mutable).

  • Calls unshare()
  • For best performance, use operator[]() or item() instead for read-only access, or dataM() to get mutable pointer for repeated access
  • Caution: Results are undefined if index is out of bounds – though index is checked with assert()
Parameters
indexItem index
Returns
Given item (mutable)

◆ operator<<() [1/4]

ListType& operator<< ( const Item data)
inline

Append operator.

  • Same as add(const Item&)
  • Append operators can be chained
    Example:
    // Clear character list and append two characters
    list << vEMPTY << 'a' << 'b';
Parameters
dataData to append
Returns
This

◆ operator<<() [2/4]

ListType& operator<< ( const ListBaseType data)
inline

Append operator.

  • Same as add(const ListBaseType&)
  • Append operators can be chained
    Example:
    // Clear list and append two other lists
    list << vEMPTY << list2 << list3;
Parameters
dataData to append
Returns
This

◆ operator<<() [3/4]

ListType& operator<< ( const ValNull val)
inline

Append operator to set as null and empty.

  • Same as set()
  • Append operators can be chained
    Example:
    // Clear character list and append two characters
    list << vNULL << 'a' << 'b';
Parameters
valvNULL
Returns
This

◆ operator<<() [4/4]

ListType& operator<< ( const ValEmpty val)
inline

Append operator to set as empty but not null.

  • Append operators can be chained
    Example:
    // Clear character list and append two characters
    list << vEMPTY << 'a' << 'b';
Parameters
valvEMPTY
Returns
This

◆ operator=() [1/5]

ListType& operator= ( ListType &&  src)
inline

Move assignment operator (C++11).

Parameters
srcSource to move
Returns
This

◆ operator=() [2/5]

ListType& operator= ( const ListType data)
inline

Assignment operator.

  • Makes shared copy if possible – see Sharing
Parameters
dataData to copy
Returns
This

◆ operator=() [3/5]

ListType& operator= ( const ListBaseType data)
inline

Assignment operator to copy sublist.

Parameters
dataData to copy
Returns
This

◆ operator=() [4/5]

ListType& operator= ( const ValNull )
inline

Assignment operator to set as null and empty.

Example:

list = vNULL;
Returns
This

◆ operator=() [5/5]

ListType& operator= ( const ValEmpty )
inline

Assignment operator to set as empty but not null.

Example:

list = vEMPTY;
Returns
This

◆ operator==()

bool operator== ( const ListBaseType data) const
inline

Equality operator.

Parameters
dataData to compare to
Returns
Whether equal

◆ operator[]()

const Item& operator[] ( Key  index) const
inline

Get item at position (const).

  • Caution: Results are undefined if index is out of bounds
Parameters
indexItem index
Returns
Given item as read-only (const)

◆ pop() [1/3]

bool pop ( T &  item,
Key  index 
)
inline

Pop a copy of given item (modifier).

  • This copies given item then removes the original
Parameters
itemStores popped item [out]
indexIndex to pop
Returns
Whether successful, false if empty or bad index

◆ pop() [2/3]

bool pop ( T &  item)
inline

Pop a copy of last item (stack) (modifier).

  • This copies last item then removes the original
  • For best performance use pop() to avoid the copy operation
Parameters
itemStores popped item [out]
Returns
Whether successful, false if empty

◆ pop() [3/3]

const Item* pop ( )
inline

Pop last item (stack).

  • This slices out and pops the last item
  • Caution: Removing sliced item will invalidate the returned pointer – see unslice() and unshare()
Returns
Popped item pointer (const), NULL if empty

◆ popq() [1/2]

bool popq ( T &  item)
inline

Pop a copy of first item (queue) (modifier).

  • This copies first item then removes the original
  • For best performance use popq() to avoid the copy operation
Parameters
itemStores popped item [out]
Returns
Whether successful, false if empty

◆ popq() [2/2]

const Item* popq ( )
inline

Pop first item (queue).

  • This slices out and pops the first item
  • Caution: Removing sliced item will invalidate the returned pointer – see unslice() and unshare()
Returns
Popped item pointer (const), NULL if empty

◆ prepend() [1/3]

ListType& prepend ( const Item data,
Size  size 
)
inline

Prepend new items copied from data pointer (modifier).

Parameters
dataData to prepend
sizeSize as item count to prepend
Returns
This

◆ prepend() [2/3]

ListType& prepend ( const ListBaseType data)
inline

Prepend new items copied from another list (modifier).

Parameters
dataData to prepend
Returns
This

◆ prepend() [3/3]

ListType& prepend ( const Item data)
inline

Prepend new item (modifier).

  • Removes items sliced from beginning – see unslice()
Parameters
dataData to prepend
Returns
This

◆ prependnew()

ListType& prependnew ( Size  size = 1)
inline

Prepend new items (modifier).

Parameters
sizeSize as item count to prepend
Returns
This

◆ ref() [1/3]

void ref ( const ListType data)
inlineprotected

Set as reference to another list.

Parameters
dataData to reference

◆ ref() [2/3]

void ref ( const ListType data,
Size  index,
Size  size 
)
inlineprotected

Set as sliced reference to another list.

Parameters
dataData to reference
indexStart index of data, END to set as empty
sizeSize as item count, ALL for all from index

◆ ref() [3/3]

void ref ( const Item data,
Size  size,
bool  term = false 
)
inlineprotected

Set as reference to given data.

Parameters
dataData to reference
sizeData size
termWhether referenced data is terminated

◆ remove()

Size remove ( Key  index,
Size  size = 1 
)
inline

Remove items (modifier).

Parameters
indexRemove index
sizeRemove size, ALL for all items from index
Returns
Number of items removed

◆ replace()

ListType& replace ( Key  index,
Size  rsize,
const Item data,
Size  size 
)
inline

Replace items with new data (modifier).

Parameters
indexStart index to replace
rsizeSize as item count from index to replace, ALL for all items from index
dataReplacement data to copy
sizeReplacement data size as item count
Returns
This

◆ reserve()

ListType& reserve ( Size  size,
bool  prefer_realloc = false 
)
inline

Reserve capacity for additional items (modifier).

  • Use to make buffer unique (not shared) and writable while reserving extra space
  • This effectively calls unshare(), though may still be sliced if prefer_realloc is true
Parameters
sizeSize as item count to reserve
prefer_reallocAdvanced: True to prefer realloc for certain conditition where would otherwise unslice via alloc and move to new buffer
Returns
This

◆ resize()

ListType& resize ( Size  size)
inline

Resize while preserving existing data (modifier).

  • This adds/removes items as needed until given size is reached
  • Effectively calls unshare()
  • Advanced: See advBuffer() for getting writable pointer to buffer
  • Advanced: See advResize() for best performance in certain POD cases
Parameters
sizeNew size as item count
Returns
This

◆ reverse()

ListType& reverse ( )
inline

Reverse item order (modifier).

Returns
This

◆ set() [1/6]

ListType& set ( )
inline

Set as null and empty.

  • Append operators can be chained
    Example:
    // Clear character list and append two characters
    list.set() << 'a' << 'b';
Returns
This

◆ set() [2/6]

ListType& set ( const Item data,
Size  size 
)
inline

Set from data pointer.

Parameters
dataData pointer to use
sizeData size as item count
Returns
This

◆ set() [3/6]

ListType& set ( const PtrBase< Item > &  data,
Size  size 
)
inline

Set from managed data pointer.

Parameters
dataData pointer to copy
sizeData size as item count

◆ set() [4/6]

ListType& set ( const ListType data)
inline

Set from another list.

  • Makes shared copy if possible – see Sharing
Parameters
dataData to copy
Returns
This

◆ set() [5/6]

ListType& set ( const ListType data,
Key  index,
Key  size = ALL 
)
inline

Set from subset of another list.

  • Makes shared copy if possible – see Sharing
Parameters
dataData to copy
indexStart index of data, END to set as empty
sizeData size as item count, ALL for all from index
Returns
This

◆ set() [6/6]

ListType& set ( const ListBaseType data,
Key  index = 0,
Key  size = ALL 
)
inline

Set as copy of sublist.

Parameters
dataData to copy
indexStart index of sublist data, END to set as empty
sizeData size as item count, ALL for all from index
Returns
This

◆ set2() [1/2]

ListType& set2 ( const ListType data,
Key  index1,
Key  index2 
)
inline

Set from subset of another list using start/end positions.

  • Makes shared copy if possible – see Sharing
  • If index2 < index1 then index2 will be set to index1 (empty sublist)
Parameters
dataData to copy
index1Start index of new slice, END to slice all items from beginning
index2End index of new slice (this item not included), END for all after index1
Returns
This

◆ set2() [2/2]

ListType& set2 ( const ListBaseType data,
Key  index1,
Key  index2 
)
inline

Set as copy of sublist using start/end positions.

Parameters
dataData to copy
index1Start index of sublist data, END to set as empty
index2End index of sublist data (this item not included), END for all after index1
Returns
This

◆ setempty()

ListType& setempty ( )
inline

Set as empty but not null.

  • Append operators can be chained
    Example:
    // Set as empty character list then append two characters
    list.setempty() << 'a' << 'b';
Returns
This

◆ shared()

bool shared ( ) const
inline

Get whether shared.

  • Data is shared when referencing external data or buffer is allocated and shared (reference count > 1)
Returns
Whether shared

◆ size()

Size size ( ) const
inline

Get size.

Returns
Size as item count

◆ slice() [1/2]

ListType& slice ( Key  index)
inline

Slice beginning items.

  • This non-destructively trims beginning items
Parameters
indexStart index of new slice, END to slice (remove) all items from beginning
Returns
This

◆ slice() [2/2]

ListType& slice ( Key  index,
Size  size 
)
inline

Slice to given sublist.

  • This non-destructively trims beginning and/or ending items
Parameters
indexStart index of new slice, END to slice (remove) all items from beginning
sizeSlice size as item count, ALL for all from index
Returns
This

◆ slice2()

ListType& slice2 ( Key  index1,
Key  index2 
)
inline

Slice to given sublist using start/end positions.

  • This non-destructively trims beginning and/or ending items
  • If index2 < index1 then index2 will be set to index1 (empty sublist)
Parameters
index1Start index of new slice, END to slice all items from beginning
index2End index of new slice (this item not included), END for all after index1
Returns
This

◆ splitat() [1/3]

bool splitat ( Key  index,
T1 &  left,
T2 &  right 
) const
inline

Split into left/right sublists at index.

  • Can use methods like find() or findany() for index
  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1List type to store left sublist
T2List type to store right sublist
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftSet to sublist before index, set to this if bad index [out]
rightSet to sublist after index, null if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat() [2/3]

bool splitat ( Key  index,
T1 &  left 
) const
inline

Split into left sublist at index.

  • Can use methods like find() or findany() for index
  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1List type to store left sublist
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftSet to sublist before index, set to this if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat() [3/3]

bool splitat ( Key  index,
ValNull  left,
T2 &  right 
) const
inline

Split into right sublist at index.

  • Can use methods like find() or findany() for index
  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T2List type to store right sublist
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftvNULL (ignored)
rightSet to sublist after index, null if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat_setl() [1/2]

bool splitat_setl ( Key  index)
inline

Split at index and set as left sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist before index, unchanged if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end (i.e. unchanged)
Returns
Whether successful, false if bad index

◆ splitat_setl() [2/2]

bool splitat_setl ( Key  index,
T2 &  right 
)
inline

Split at index, set as left sublist, and save right sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist before index, unchanged if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end (i.e. unchanged)
rightSet to sublist after index, null if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat_setr() [1/2]

bool splitat_setr ( Key  index)
inline

Split at index and set as right sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist after index, null if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
Returns
Whether successful, false if bad index

◆ splitat_setr() [2/2]

bool splitat_setr ( Key  index,
T1 &  left 
)
inline

Split at index, set as right sublist, and save left sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist after index, null if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftSet to sublist before index, set to this if bad index [out]
Returns
Whether successful, false if bad index

◆ starts() [1/3]

bool starts ( ItemVal  item) const
inline

Check if this starts with given item.

  • Uses item operator==() for comparisons
Parameters
itemItem to check
Returns
Whether starts with item

◆ starts() [2/3]

bool starts ( const Item items,
Size  size 
) const
inline

Check if starts with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
sizeSize as item count to check
Returns
Whether starts with items

◆ starts() [3/3]

bool starts ( const ListBaseType items) const
inline

Check if this starts with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
Returns
Whether starts with items

◆ swap() [1/2]

void swap ( Key  index1,
Key  index2 
)
inline

Swap items.

  • Calls unshare() and does swap, if index1 and index2 are valid and not the same
Parameters
index1Index of first item to swap
index2Index of second item to swap

◆ swap() [2/2]

void swap ( ListType list)
inline

Swap with another list.

  • This swaps internal state directly so is faster than moving items
Parameters
listList to swap with

◆ triml()

ListType& triml ( Size  size)
inline

Trim left (beginning) items.

  • This non-destructively trims beginning items
Parameters
sizeTrim size as item count to remove
Returns
This

◆ trimr()

ListType& trimr ( Size  size)
inline

Trim right (ending) items.

  • This non-destructively trims ending items
Parameters
sizeTrim size as item count to remove
Returns
This

◆ truncate()

ListType& truncate ( Size  size = 0)
inline

Truncate to given size.

  • This non-destructively trims ending items
Parameters
sizeSize to truncate to as item count
Returns
This

◆ unshare()

ListType& unshare ( )
inline

Make data unique by allocating new buffer, if needed (modifier).

  • Use reserve() instead to reserve additional space while unsharing
  • Use to make buffer unique (not shared) and writable (when not empty)
  • This is called automatically by mutable/modifier methods
  • This does nothing if empty or not shared
Returns
This

◆ unslice()

ListType& unslice ( )
inline

Clean and remove hidden items previously removed via slicing (modifier).

  • Modify operations do this automatically as needed
  • This is mainly useful for cleanup before starting critical performance code
Returns
This

Member Data Documentation

◆ buf_

Buf buf_
protected

List buffer.

◆ data_

T* data_
inherited

Data pointer, NULL if null.

◆ size_

TSize size_
inherited

Data size as item count, 0 if empty or null.


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