An array storring elements of type T using B bits to to store a element. More...
#include <tpie/packed_array.h>
Inherits tpie::linear_memory_base< packed_array< T, B > >.
Public Types | |
typedef size_t | storage_type |
typedef T | value_type |
Type of values containd in the array. More... | |
typedef const_iter_base< true > | const_iterator |
Iterator over a const array. More... | |
typedef const_iter_base< false > | const_reverse_iterator |
Reverse iterator over a const array. More... | |
typedef iter_base< true > | iterator |
Iterator over an array. More... | |
typedef iter_base< false > | reverse_iterator |
Reverse iterator over an array. More... | |
Public Member Functions | |
packed_array (size_t s=0) | |
Construct array of given size. More... | |
packed_array (size_t s, T value) | |
Construct array of given size. More... | |
packed_array (const packed_array &a) | |
Construct a copy of another array. More... | |
packed_array (packed_array &&a) | |
Move another aray into me. More... | |
~packed_array () | |
Free up all memory used by the array. More... | |
packed_array & | operator= (const packed_array &a) |
Copy elements from another array into this. More... | |
packed_array & | operator= (packed_array &&a) |
Move another array. More... | |
void | resize (size_t s) |
Change the size of the array. More... | |
void | fill (T value) |
Fill the entier array with the given value. More... | |
void | resize (size_t s, T value) |
Change the size of the array. More... | |
size_t | size () const |
Return the size of the array. More... | |
bool | empty () const |
Check if the array is empty. More... | |
T | operator[] (size_t t) const |
Return an array entry. More... | |
return_type | operator[] (size_t t) |
Return a object behaving like a reference to an array entry. More... | |
iterator | find (size_type i) |
Return an iterator to the i'th element of the array. More... | |
const_iterator | find (size_type i) const |
Return a const iterator to the i'th element of the array. More... | |
iterator | begin () |
Return an iterator to the beginning of the array. More... | |
const_iterator | begin () const |
Return a const iterator to the beginning of the array. More... | |
iterator | end () |
Return an iterator to the end of the array. More... | |
const_iterator | end () const |
Return a const iterator to the end of the array. More... | |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
void | swap (packed_array &o) |
Swap two arrays. More... | |
Static Public Member Functions | |
static double | memory_coefficient () |
Return the memory coefficient of the structure. More... | |
static double | memory_overhead () |
Return the memory overhead of the structure. More... | |
static memory_size_type | memory_usage (memory_size_type size) |
Return the number of bytes required to create a data structure supporting a given number of elements. More... | |
static memory_size_type | memory_fits (memory_size_type memory) |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes. More... | |
An array storring elements of type T using B bits to to store a element.
T must be either bool or int. B must devide the word size, (XXX why?) in reality only 1, 2 or 4 seems usamle
T | The type of elements to store in the array |
B | The number of bits used to store a single element |
Definition at line 89 of file packed_array.h.
typedef const_iter_base<true> tpie::packed_array< T, B >::const_iterator |
Iterator over a const array.
Definition at line 251 of file packed_array.h.
typedef const_iter_base<false> tpie::packed_array< T, B >::const_reverse_iterator |
Reverse iterator over a const array.
Definition at line 256 of file packed_array.h.
typedef iter_base<true> tpie::packed_array< T, B >::iterator |
Iterator over an array.
Definition at line 261 of file packed_array.h.
typedef iter_base<false> tpie::packed_array< T, B >::reverse_iterator |
Reverse iterator over an array.
Definition at line 266 of file packed_array.h.
typedef T tpie::packed_array< T, B >::value_type |
Type of values containd in the array.
Definition at line 246 of file packed_array.h.
|
inline |
Construct array of given size.
The elements have undefined values
s | The number of elements in the array |
Definition at line 290 of file packed_array.h.
References tpie::packed_array< T, B >::resize().
Referenced by tpie::packed_array< T, B >::memory_overhead().
|
inline |
Construct array of given size.
s | The number of elements in the array |
value | Each entry of the array is initialized with this value |
Definition at line 298 of file packed_array.h.
References tpie::packed_array< T, B >::resize().
|
inline |
Construct a copy of another array.
other | The array to copy |
Definition at line 304 of file packed_array.h.
|
inline |
Move another aray into me.
other | The array to copy |
Definition at line 310 of file packed_array.h.
|
inline |
Free up all memory used by the array.
Definition at line 318 of file packed_array.h.
References tpie::packed_array< T, B >::resize().
|
inline |
Return an iterator to the beginning of the array.
Definition at line 444 of file packed_array.h.
|
inline |
Return a const iterator to the beginning of the array.
Definition at line 451 of file packed_array.h.
|
inline |
Check if the array is empty.
Definition at line 399 of file packed_array.h.
|
inline |
Return an iterator to the end of the array.
Definition at line 458 of file packed_array.h.
|
inline |
Return a const iterator to the end of the array.
Definition at line 465 of file packed_array.h.
|
inline |
Fill the entier array with the given value.
elm | the initialization element |
Definition at line 365 of file packed_array.h.
Referenced by tpie::packed_array< T, B >::resize().
|
inline |
Return an iterator to the i'th element of the array.
i | the index of the element we want an iterator to |
Definition at line 429 of file packed_array.h.
|
inline |
Return a const iterator to the i'th element of the array.
i | the index of the element we want an iterator to |
Definition at line 437 of file packed_array.h.
|
inlinestatic |
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most bytes. This does not include memory overhead incurred if the structure is allocated using new.
Definition at line 272 of file packed_array.h.
|
inlinestaticinherited |
Return the maximum number of elements that can be contained in in the structure when it is allowed to fill a given number of bytes.
memory | The number of bytes the structure is allowed to occupy |
|
inlinestatic |
Return the memory overhead of the structure.
Definition at line 280 of file packed_array.h.
References tpie::packed_array< T, B >::packed_array().
|
inlinestaticinherited |
Return the number of bytes required to create a data structure supporting a given number of elements.
size | The number of elements to support |
|
inline |
Copy elements from another array into this.
Note this array is resized to the size of other
other | The array to copy from |
Definition at line 327 of file packed_array.h.
References tpie::packed_array< T, B >::resize().
|
inline |
Move another array.
Definition at line 338 of file packed_array.h.
References tpie::packed_array< T, B >::resize().
|
inline |
Return an array entry.
i | the index of the entry to return |
Definition at line 407 of file packed_array.h.
|
inline |
Return a object behaving like a reference to an array entry.
i | the index of the entry to return |
Definition at line 418 of file packed_array.h.
|
inline |
Change the size of the array.
All elements are lost, after resize the value of the entries is undefined
s | the new size of the array |
Definition at line 353 of file packed_array.h.
References tpie::tpie_delete_array().
Referenced by tpie::packed_array< T, B >::operator=(), tpie::packed_array< T, B >::packed_array(), tpie::packed_array< T, B >::resize(), and tpie::packed_array< T, B >::~packed_array().
|
inline |
Change the size of the array.
All elements are lost, after resize the value of the entries is initialized by a copy of elm
s | the new size of the array |
value | the initialization element |
Definition at line 382 of file packed_array.h.
References tpie::packed_array< T, B >::fill(), and tpie::packed_array< T, B >::resize().
|
inline |
Return the size of the array.
Definition at line 392 of file packed_array.h.
|
inline |
Swap two arrays.
Definition at line 477 of file packed_array.h.