template class Core::ConstVector
Overview
Immutable one-dimensional array container class. More…
#include <corevector.h> template <class T> class ConstVector { public: // construction ConstVector (const T* items, int numItems); // methods bool isEmpty () const; INLINE int count () const; INLINE bool isValidIndex (int index) const; T& at (int idx) const; T& first () const; T& last () const; bool isEqual (const ConstVector <T>& other) const; bool operator == (const ConstVector& other) const; bool operator != (const ConstVector& other) const; int index (const T& data) const; int index (const T* item) const; bool contains (const T& data) const; bool containsAnyOf (const ConstVector <T>& other) const; T* search (const T& data) const; template <class Predicate> T* findIf (const Predicate& recognize) const; T* findIf (ContainerPredicateFunction recognize) const; INLINE T* getItems () const; INLINE operator T* () const; RangeIterator <ConstVector <T>, VectorIterator <T>, T&> begin () const; RangeIterator <ConstVector <T>, VectorIterator <T>, T&> end () const; static T& getError (); };
Detailed Documentation
Immutable one-dimensional array container class.
External memory is passed as C array.
Construction
ConstVector (const T* items, int numItems)
[LIGHT] Construct with C array (no copying).
Methods
bool isEmpty () const
Check if container is empty.
INLINE int count () const
Get number of elements in container.
INLINE bool isValidIndex (int index) const
Check if index is valid for accessing element.
T& at (int idx) const
Get element at index.
T& first () const
Get first element.
T& last () const
Get last element.
bool isEqual (const ConstVector <T>& other) const
Check if other vecotor is equal.
int index (const T& data) const
Get index of given element in container (by reference).
int index (const T* item) const
Get index of given element in container (by pointer).
bool contains (const T& data) const
Check if container holds given element.
bool containsAnyOf (const ConstVector <T>& other) const
Check if container holds any other other container.
T* search (const T& data) const
Search for given element and return its address.
Uses binary search, vector needs to be sorted.
template <class Predicate> T* findIf (const Predicate& recognize) const
Find element based on predicate.
predicate: (T&) -> bool
T* findIf (ContainerPredicateFunction recognize) const
Find element based on predicate.
Use DEFINE_CONTAINER_PREDICATE.
INLINE T* getItems () const
Get start address of array.
static T& getError ()
Access error element.