A generic array with a fixed size. More...
#include <tpie/array.h>
Inherits tpie::linear_memory_base< array< T > >.
Public Types | |
typedef array_iter_base< T const, true > | const_iterator |
Iterator over a const array. More... | |
typedef array_iter_base< T const, false > | const_reverse_iterator |
Reverse iterator over a const array. More... | |
typedef array_iter_base< T, true > | iterator |
Iterator over an array. More... | |
typedef array_iter_base< T, false > | reverse_iterator |
Reverse iterator over an array. More... | |
typedef T | value_type |
Type of values containd in the array. More... | |
Public Member Functions | |
iterator | find (size_t idx) throw () |
Return an iterator to the i'th element of the array. More... | |
const_iterator | find (size_t idx) const throw () |
Return a const iterator to the i'th element of the array. More... | |
T & | at (size_t i) throw () |
Return the element located at the given index. More... | |
const T & | at (size_t i) const throw () |
array & | operator= (const array &other) |
Copy elements from another array into this. More... | |
array & | operator= (array &&other) |
Move elements from another array into this. More... | |
template<typename OtherAllocator > | |
array & | operator= (const array< T, OtherAllocator > &other) |
Copy elements from another array with any allocator into this. More... | |
bool | empty () const |
Check if the array is empty. More... | |
const T & | operator[] (size_t i) const |
Return a const reference to an array entry. More... | |
T & | operator[] (size_t i) |
Return a reference to an array entry. More... | |
bool | operator== (const array &other) const |
Compare if the other array has the same elements in the same order as this. More... | |
bool | operator!= (const array &other) const |
Check if two arrays differ. 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... | |
const T & | front () const |
Return the first element in the array. More... | |
T & | front () |
Return the first element in the array. More... | |
const T & | back () const |
Return the last element in the array. More... | |
T & | back () |
Return the last element in the array. More... | |
reverse_iterator | rbegin () |
Reverse iterator to beginning of reverse sequence. More... | |
const_reverse_iterator | rbegin () const |
Const reverse iterator to beginning of reverse sequence. More... | |
reverse_iterator | rend () |
Reverse iterator to end of reverse sequence. More... | |
const_reverse_iterator | rend () const |
Const reverse iterator to end of reverse sequence. More... | |
array (size_type s, const T &value, const Allocator &alloc=Allocator()) | |
Construct array of given size. More... | |
array (size_type s, memory_bucket_ref bucket) | |
array (memory_bucket_ref bucket) | |
array (size_type s=0, const Allocator &alloc=Allocator()) | |
Construct array of given size. More... | |
array (const array &other) | |
Construct a copy of another array. More... | |
array (array &&other) | |
Move construct from another array. More... | |
array (const array_view_base< T > &view) | |
array (const array_view_base< const T > &view) | |
~array () | |
Free up all memory used by the array. More... | |
void | resize (size_t size, const T &elm) |
Change the size of the array. More... | |
void | swap (array &other) |
Swap two arrays. More... | |
void | resize (size_t s) |
Change the size of the array. More... | |
size_type | size () const |
Return the size of the array. More... | |
T * | get () |
Return a raw pointer to the array content. More... | |
const T * | get () const |
Return a raw pointer to the array content. More... | |
Allocator | get_allocator () const |
Return copy of the allocator. 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... | |
Friends | |
struct | bits::allocator_usage< T, Allocator > |
A generic array with a fixed size.
This is almost the same as a real C-style T array but the memory management is better.
T | The type of element to contain. |
alloc_t | Allocator. |
typedef array_iter_base<T const, true> tpie::array< T, Allocator >::const_iterator |
typedef array_iter_base<T const, false> tpie::array< T, Allocator >::const_reverse_iterator |
typedef array_iter_base<T, true> tpie::array< T, Allocator >::iterator |
typedef array_iter_base<T, false> tpie::array< T, Allocator >::reverse_iterator |
typedef T tpie::array< T, Allocator >::value_type |
|
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 408 of file array.h.
Referenced by tpie::array< push_type< dest_t >::type >::memory_overhead().
|
inline |
Construct array of given size.
s | The number of elements in the array. |
Definition at line 425 of file array.h.
|
inline |
|
inline |
Move construct from another array.
other | The array to move. |
|
inline |
Free up all memory used by the array.
Definition at line 473 of file array.h.
|
inline |
Return the element located at the given index.
i | The index of the element returned. |
Definition at line 188 of file array.h.
Referenced by tpie::array< push_type< dest_t >::type >::back(), tpie::array< push_type< dest_t >::type >::front(), and tpie::array< push_type< dest_t >::type >::operator[]().
|
inline |
|
inline |
Return the last element in the array.
Definition at line 343 of file array.h.
|
inline |
Return the last element in the array.
Definition at line 348 of file array.h.
|
inline |
Return an iterator to the beginning of the array.
Definition at line 307 of file array.h.
Referenced by tpie::internal_vector< T >::begin(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::clear(), tpie::disjoint_sets< value_t >::clear(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::clear(), and tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::make_safe().
|
inline |
|
inline |
|
inline |
Return an iterator to the end of the array.
Definition at line 321 of file array.h.
Referenced by tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::clear(), tpie::disjoint_sets< value_t >::clear(), and tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::clear().
|
inline |
|
inline |
Return an iterator to the i'th element of the array.
idx | The index of the element we want an iterator to. |
Definition at line 167 of file array.h.
Referenced by tpie::internal_vector< T >::end(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::insert(), and tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::make_safe().
|
inline |
|
inline |
Return the first element in the array.
Definition at line 333 of file array.h.
|
inline |
Return the first element in the array.
Definition at line 338 of file array.h.
|
inline |
Return a raw pointer to the array content.
Definition at line 531 of file array.h.
Referenced by tpie::compressor_buffer::get(), and tpie::bits::serialization_reader_base::read().
|
inline |
|
inline |
|
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 393 of file array.h.
Referenced by tpie::internal_queue< item_type >::memory_coefficient(), tpie::internal_stack_vector_base< T, internal_stack< T > >::memory_coefficient(), tpie::disjoint_sets< value_t >::memory_coefficient(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::memory_coefficient(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::memory_coefficient(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::memory_coefficient(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::memory_overhead(), and tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::memory_overhead().
|
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 400 of file array.h.
Referenced by tpie::internal_queue< item_type >::memory_overhead(), tpie::internal_stack_vector_base< T, internal_stack< T > >::memory_overhead(), tpie::disjoint_sets< value_t >::memory_overhead(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::memory_overhead(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::memory_overhead(), and tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::memory_overhead().
|
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 |
Definition at line 81 of file util.h.
Referenced by tpie::stack< item_type >::memory_usage().
|
inline |
|
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 209 of file array.h.
|
inline |
Move 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 223 of file array.h.
|
inline |
Copy elements from another array with any allocator into this.
Note: This array is resized to the size of other.
other | The array to copy from. |
OtherAllocator | The allocator used by the other array. |
Definition at line 242 of file array.h.
|
inline |
|
inline |
Return a const reference to an array entry.
i | The index of the entry to return. |
Definition at line 261 of file array.h.
|
inline |
Return a reference to an array entry.
i | The index of the entry to return. |
Definition at line 272 of file array.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Change the size of the array.
All elements are lost.
Memory manager MUST be initialized at this point unless s == 0.
size | The new size of the array. |
elm | The initialization element. |
Definition at line 485 of file array.h.
Referenced by tpie::array< push_type< dest_t >::type >::array(), tpie::merge_sorter< T, UseProgress, pred_t, store_t >::begin(), tpie::pipelining::parallel_bits::producer< T1, T2 >::begin(), tpie::merge_sorter< T, UseProgress, pred_t, store_t >::end(), tpie::pipelining::parallel_bits::producer< T1, T2 >::end(), tpie::serialization_bits::internal_sort< T, pred_t >::free(), tpie::internal_queue< item_type >::internal_queue(), tpie::array< push_type< dest_t >::type >::operator=(), tpie::merge_sorter< T, UseProgress, pred_t, store_t >::pull(), tpie::internal_queue< item_type >::resize(), tpie::internal_stack_vector_base< T, internal_stack< T > >::resize(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::resize(), tpie::disjoint_sets< value_t >::resize(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::resize(), tpie::compressor_buffer::set_capacity(), and tpie::array< push_type< dest_t >::type >::~array().
|
inline |
|
inline |
Return the size of the array.
Definition at line 526 of file array.h.
Referenced by tpie::array< push_type< dest_t >::type >::array(), tpie::array< push_type< dest_t >::type >::at(), tpie::internal_queue< item_type >::back(), tpie::array< push_type< dest_t >::type >::back(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::begin(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::begin(), tpie::compressor_buffer::capacity(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::clear(), tpie::array< push_type< dest_t >::type >::empty(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::end(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::end(), tpie::array< push_type< dest_t >::type >::end(), tpie::merge_sorter< T, UseProgress, pred_t, store_t >::end(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::erase(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::erase(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::find(), tpie::array< push_type< dest_t >::type >::find(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::find(), tpie::internal_queue< item_type >::front(), tpie::internal_queue< item_type >::full(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::insert(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::insert(), tpie::array< push_type< dest_t >::type >::operator!=(), tpie::array< push_type< dest_t >::type >::operator=(), tpie::array< push_type< dest_t >::type >::operator==(), tpie::array< push_type< dest_t >::type >::operator[](), tpie::internal_queue< item_type >::push(), tpie::stack< item_type >::push(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::push(), tpie::serialization_bits::internal_sort< T, pred_t >::push(), tpie::array< push_type< dest_t >::type >::rend(), and tpie::array< push_type< dest_t >::type >::resize().
|
inline |
Swap two arrays.
Definition at line 499 of file array.h.
Referenced by tpie::merge_sorter< T, UseProgress, pred_t, store_t >::end().