Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Array< T > Class Template Reference

#include <elm/data/Array.h>

+ Inheritance diagram for Array< T >:

Classes

class  Iter
 

Public Types

typedef T t
 
typedef Array< T > self_t
 

Public Member Functions

 Array (void)
 
 Array (int count, T *buffer)
 
const T * buffer (void) const
 
T * buffer (void)
 
int size (void) const
 
void set (int count, T *buffer)
 
void set (const Array< T > &t)
 
void copy (const Array &t)
 
void fill (const T &val)
 
const T * operator() (void) const
 
T * operator() (void)
 
Array< T > & operator= (const Array< T > &t)
 
Iter items (void) const
 
Iter operator* (void) const
 
Iter begin (void) const
 
Iter end (void) const
 
int count (void) const
 
bool contains (const T &item)
 
template<class C >
bool containsAll (const C &c)
 
bool isEmpty (void) const
 
 operator bool (void) const
 
bool equals (const Array< T > &a)
 
bool operator== (const Array< T > &a) const
 
bool operator!= (const Array< T > &a) const
 
bool operator<= (const Array< T > &a) const
 
bool operator< (const Array< T > &a) const
 
bool operator>= (const Array< T > &a) const
 
bool operator> (const Array< T > &a) const
 
int length (void) const
 
const T & get (int idx) const
 
int indexOf (const T &v, int i=0) const
 
int lastIndexOf (const T &v, int i=-1) const
 
const T & operator[] (int idx) const
 
void set (int idx, const T &val)
 
void set (const Iter &i, const T &val)
 
T & get (int idx)
 
T & operator[] (int idx)
 

Static Public Attributes

static const Array< T > null
 

Protected Attributes

int cnt
 
T * buf
 

Detailed Description

template<class T>
class elm::Array< T >

An array is a simple wrapper around the C array data type. It provides controlled methods to it (indexed accesses are protected with assertions) and implements the concept:: Collection concept and therefore can be used as any collection. Yet, it doesn't manage the memory of the array.

To shorten the construction of an Array, you can use the function _array().

Parameters
TType of elements stored in the array.
See also
AllocArray, _array()

Member Typedef Documentation

◆ self_t

typedef Array<T> self_t

◆ t

typedef T t

Constructor & Destructor Documentation

◆ Array() [1/2]

Array ( void  )
inline

Build an empty array.

◆ Array() [2/2]

Array ( int  count,
T *  buffer 
)
inline

Build an array using buffer as array and with size count. The Array will NOT be in charge of freeing this memory!

Parameters
countArray size.
bufferBuffer Array buffer.

Member Function Documentation

◆ begin()

Iter begin ( void  ) const
inline

◆ buffer() [1/2]

T * buffer ( void  )
inline
Returns
Buffer of the array.

◆ buffer() [2/2]

const T * buffer ( void  ) const
inline

◆ contains()

bool contains ( const T &  item)
inline

◆ containsAll()

◆ copy()

void copy ( const Array< T > &  t)
inline

Copy the array t inside the current array. If the current array is smaller than t, only the first elements will be copied.

Parameters
tArray to copy.

Referenced by AllocArray< elm::String >::AllocArray(), and AllocArray< elm::String >::copy().

◆ count()

◆ end()

Iter end ( void  ) const
inline

◆ equals()

◆ fill()

void fill ( const T &  val)
inline

Fill the array with the gien value.

Parameters
valValue to copy in the array elements.

Referenced by AllocArray< elm::String >::AllocArray().

◆ get() [1/2]

T & get ( int  idx)
inline

Get a reference on an element by index. Raise an assertion failure if idx is out of array bounds.

Parameters
idxIndex of element to get.
Returns
Reference on element at index idx.

◆ get() [2/2]

const T & get ( int  idx) const
inline

Get an element by index. Raise an assertion failure if idx is out of array bounds.

Parameters
idxIndex of element to get.
Returns
Element at index idx.

Referenced by Array< elm::String >::indexOf(), Array< elm::String >::lastIndexOf(), and Array< elm::String >::operator[]().

◆ indexOf()

int indexOf ( const T &  v,
int  i = 0 
) const
inline

◆ isEmpty()

bool isEmpty ( void  ) const
inline

◆ items()

Array::Iter items ( void  ) const
inline
Returns
iterator on the items of the array.

Referenced by Array< elm::String >::begin(), and Array< elm::String >::operator*().

◆ lastIndexOf()

int lastIndexOf ( const T &  v,
int  i = -1 
) const
inline

◆ length()

int length ( void  ) const
inline

◆ operator bool()

operator bool ( void  ) const
inline

◆ operator!=()

bool operator!= ( const Array< T > &  a) const
inline

◆ operator()() [1/2]

T * operator() ( void  )
inline

Same as buffer().

◆ operator()() [2/2]

const T * operator() ( void  ) const
inline

Same as buffer().

◆ operator*()

Array::Iter operator* ( void  ) const
inline

Same as items().

◆ operator<()

bool operator< ( const Array< T > &  a) const
inline

◆ operator<=()

bool operator<= ( const Array< T > &  a) const
inline

◆ operator=()

Array< T > & operator= ( const Array< T > &  t)
inline

Same as set().

◆ operator==()

bool operator== ( const Array< T > &  a) const
inline

◆ operator>()

bool operator> ( const Array< T > &  a) const
inline

◆ operator>=()

bool operator>= ( const Array< T > &  a) const
inline

◆ operator[]() [1/2]

T & operator[] ( int  idx)
inline

Same as get().

◆ operator[]() [2/2]

const T & operator[] ( int  idx) const
inline

Same as get().

◆ set() [1/4]

void set ( const Array< T > &  t)
inline

Assign the given array t to the current array.

Parameters
tArray to assign.

◆ set() [2/4]

void set ( const Iter i,
const T &  val 
)
inline

Set a value according to an iterator.

Parameters
iNon-ended iterator.
valValue to set.

◆ set() [3/4]

void set ( int  count,
T *  buffer 
)
inline

Change the buffer of the array. The Array will NOT be in charge of freeing this buffer.

Parameters
countArray count.
bufferArray buffer.

Referenced by AllocArray< elm::String >::copy(), Array< elm::String >::operator=(), and AllocArray< elm::String >::tie().

◆ set() [4/4]

void set ( int  idx,
const T &  val 
)
inline

Set an array element according to index idx. If the index is out of bound, an assertion failure is raised.

Parameters
idxIndex of the element to assign.
valValue to assign.

◆ size()

int size ( void  ) const
inline

Member Data Documentation

◆ buf

◆ cnt

◆ null

const Array< T > null
static

Singleton representing an empty array.


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