Otawa
0.10
|
#include <otawa/util/Bag.h>
Public Member Functions | |
Bag (void) | |
Empty array constructor. More... | |
Bag (const Bag &bag) | |
Clone constructor. More... | |
Bag (int c, const T *a) | |
Constructor using a raw array. More... | |
Bag (int c, T *a) | |
Constructor using a raw array. More... | |
Bag (const genstruct::Vector< T > &v) | |
Constructor from a vector. More... | |
Bag (Pair< int, T * > p) | |
Construction from a pair (array count, array base). More... | |
Bag (const Give< T > &g) | |
Construction from a given array. More... | |
~Bag (void) | |
bool | isEmpty (void) const |
Test if the bag is empty. More... | |
operator bool (void) const | |
int | count (void) const |
Get the count of items in the bag. More... | |
int | size (void) const |
Same as count(). More... | |
const T & | get (int i) const |
Get the ith item of the bag. More... | |
T & | get (int i) |
Get the ith item of the bag. More... | |
const T & | operator[] (int i) const |
T & | operator[] (int i) |
Bag & | operator= (const Bag &bag) |
Bag & | operator= (const genstruct::Vector< T > &v) |
Bag & | operator= (Pair< int, T * > p) |
Bag & | operator= (const Give< T > &g) |
void | clear (void) |
Clear the content of the bag. More... | |
Private Member Functions | |
void | copy (int c, const T *a) |
void | copy (const genstruct::Vector< T > &v) |
Private Attributes | |
int | cnt |
T * | arr |
T | Type of stored items. This light parametric class is dedicated to the storage of small sets of simple items hooked to a property. It may be used as a normal array but the stored objects will be deleted when the property is removed. |
Normal work of the Bag class is to perform a copy of the arguments passed to the constructor and it will manage the new allocated array. If a transfer of array is needed (the array has been allocated by another class but the responsibility for releasing the array is transfered to the Bag), the array must be passed through a small Give object. Give objects may be built from a pair (array count, array pointer) but also from a elm::genstruct::Vector (in this case, the array is detached).
|
inline |
Empty array constructor.
|
inline |
Clone constructor.
bag | Bag to clone. |
References otawa::Bag< T >::arr, otawa::Bag< T >::cnt, and copy().
|
inline |
Constructor using a raw array.
c | Count of items in the array. |
a | Base pointer of the array. |
References copy().
|
inline |
Constructor using a raw array.
c | Count of items in the array. |
a | Base pointer of the array. |
References copy().
|
inline |
|
inline |
Construction from a pair (array count, array base).
p | Pair to build from. |
References copy(), elm::Pair< T1, T2 >::fst, and elm::Pair< T1, T2 >::snd.
|
inline |
Construction from a given array.
The current Bag object becomes responsible for freeing the array passed in g.
g | Given array. |
|
inline |
References clear().
|
inline |
Clear the content of the bag.
After this call, the bag is empty.
|
inlineprivate |
References elm::array::copy().
|
inlineprivate |
References elm::genstruct::Vector< T >::length().
|
inline |
Get the count of items in the bag.
|
inline |
Get the ith item of the bag.
i | Index of the looked item. |
|
inline |
Get the ith item of the bag.
i | Index of the looked item. |
|
inline |
Test if the bag is empty.
|
inline |
|
inline |
References otawa::Bag< T >::arr, clear(), otawa::Bag< T >::cnt, and copy().
|
inline |
|
inline |
References clear(), copy(), elm::Pair< T1, T2 >::fst, and elm::Pair< T1, T2 >::snd.
|
inline |
References otawa::Give< T >::array(), clear(), and otawa::Give< T >::count().
|
inline |
|
inline |
|
inline |
Same as count().
|
private |
Referenced by otawa::Bag< T >::Bag(), and otawa::Bag< T >::operator=().
|
private |
Referenced by otawa::Bag< T >::Bag(), and otawa::Bag< T >::operator=().