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 () | |
| Free up all memory used by the array. More... | |
| packed_array & | operator= (const packed_array &a) |
| Copy elements from another array into this. More... | |
| void | resize (size_t s) |
| Change the size of the array. 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 |
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 stream_size_type | memory_usage (stream_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 87 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 250 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 255 of file packed_array.h.
| typedef iter_base<true> tpie::packed_array< T, B >::iterator |
Iterator over an array.
Definition at line 260 of file packed_array.h.
| typedef iter_base<false> tpie::packed_array< T, B >::reverse_iterator |
Reverse iterator over an array.
Definition at line 265 of file packed_array.h.
| typedef T tpie::packed_array< T, B >::value_type |
Type of values containd in the array.
Definition at line 245 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 289 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 297 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 303 of file packed_array.h.
|
inline |
Free up all memory used by the array.
Definition at line 308 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 412 of file packed_array.h.
|
inline |
Return a const iterator to the beginning of the array.
Definition at line 419 of file packed_array.h.
|
inline |
Check if the array is empty.
Definition at line 367 of file packed_array.h.
|
inline |
Return an iterator to the end of the array.
Definition at line 426 of file packed_array.h.
|
inline |
Return a const iterator to the end of the array.
Definition at line 433 of file packed_array.h.
|
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 397 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 405 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 271 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 279 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 317 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 375 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 386 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 331 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 |
| elm | the initialization element |
Definition at line 346 of file packed_array.h.
References tpie::packed_array< T, B >::resize().
|
inline |
Return the size of the array.
Definition at line 360 of file packed_array.h.