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

#include <elm/data/Bag.h>

Classes

class  Iter
 

Public Member Functions

int count () const
 
bool isEmpty () const
 
 operator bool () const
 
const T & get (int i) const
 
T & get (int i)
 
const T & operator[] (int i) const
 
T & operator[] (int i)
 
Iter begin () const
 
Iter end () const
 
bool contains (const T &x) const
 
bool containsAll (const Bag< T > &c) const
 
bool equals (const Bag< T > &c) const
 
bool operator== (const Bag< T > &b) const
 
bool operator!= (const Bag< T > &b) const
 
int length () const
 
int indexOf (const T &x, int i=-1) const
 
int lastIndexOf (const T &x, int i=-1) const
 

Static Public Member Functions

static void operator delete (void *p)
 
static Bag< T > * make (int count, const T *items)
 
static Bag< T > * make (const Array< T > &a)
 
static Bagmake (const Vector< T > &v)
 

Detailed Description

template<class T>
class elm::Bag< T >

A bag is a cheap collection to store an immutable array of data. The allocated data encompasses only the integer for the count and the array items. Yet, this requires a special procedure to create a bag using the function make as below:

float array[N] = { ... };
Bag<float> *bag = Bag<float>(N, array);

Yet, the release of the data is standard:

delete bag;

Bag implements the following concepts:

Parameters
TType of data stored in the bag.

Member Function Documentation

◆ begin()

Iter begin ( ) const
inline

◆ contains()

bool contains ( const T &  x) const
inline

Referenced by Bag< T >::containsAll().

◆ containsAll()

bool containsAll ( const Bag< T > &  c) const
inline

References Bag< T >::contains().

◆ count()

int count ( ) const
inline

◆ end()

Iter end ( ) const
inline

◆ equals()

bool equals ( const Bag< T > &  c) const
inline

◆ get() [1/2]

T& get ( int  i)
inline

◆ get() [2/2]

const T& get ( int  i) const
inline

◆ indexOf()

int indexOf ( const T &  x,
int  i = -1 
) const
inline

References Bag< T >::get().

◆ isEmpty()

bool isEmpty ( ) const
inline

Referenced by Bag< T >::operator bool().

◆ lastIndexOf()

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

References Bag< T >::get().

◆ length()

int length ( ) const
inline

References Bag< T >::count().

◆ make() [1/3]

static Bag<T>* make ( const Array< T > &  a)
inlinestatic

◆ make() [2/3]

static Bag* make ( const Vector< T > &  v)
inlinestatic

◆ make() [3/3]

static Bag<T>* make ( int  count,
const T *  items 
)
inlinestatic

References elm::array::copy(), and Bag< T >::count().

Referenced by Bag< T >::make().

◆ operator bool()

operator bool ( ) const
inline

References Bag< T >::isEmpty().

◆ operator delete()

static void operator delete ( void p)
inlinestatic

References elm::io::p().

◆ operator!=()

bool operator!= ( const Bag< T > &  b) const
inline

References Bag< T >::equals().

◆ operator==()

bool operator== ( const Bag< T > &  b) const
inline

References Bag< T >::equals().

◆ operator[]() [1/2]

T& operator[] ( int  i)
inline

References Bag< T >::get().

◆ operator[]() [2/2]

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

References Bag< T >::get().


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