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 () |
template<typename OtherAllocator > | |
array & | operator= (const array< T, OtherAllocator > &other) |
Copy elements from another array 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=0, const Allocator &alloc=Allocator()) | |
Construct array of given size. More... | |
array (const array &other) | |
Construct a copy of 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... | |
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... | |
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 375 of file array.h.
Referenced by tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::memory_overhead().
|
inline |
Construct array of given size.
s | The number of elements in the array. |
Definition at line 385 of file array.h.
|
inline |
|
inline |
Free up all memory used by the array.
Definition at line 419 of file array.h.
|
inline |
Return the element located at the given index.
i | The index of the element returned. |
Definition at line 187 of file array.h.
Referenced by tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::back(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::front(), and tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::operator[]().
|
inline |
|
inline |
Return the last element in the array.
Definition at line 310 of file array.h.
|
inline |
Return the last element in the array.
Definition at line 315 of file array.h.
|
inline |
Return an iterator to the beginning of the array.
Definition at line 274 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::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::clear(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::make_safe(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::pop(), and tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::pop_and_push().
|
inline |
|
inline |
|
inline |
Return an iterator to the end of the array.
Definition at line 288 of file array.h.
Referenced by tpie::chaining_hash_table< value_t, hash_t, equal_t, index_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 166 of file array.h.
Referenced by tpie::internal_vector< T >::end(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::insert(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::make_safe(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::pop(), and tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::pop_and_push().
|
inline |
|
inline |
Return the first element in the array.
Definition at line 300 of file array.h.
|
inline |
Return the first element in the array.
Definition at line 305 of file array.h.
|
inline |
Return a raw pointer to the array content.
Definition at line 477 of file array.h.
Referenced by tpie::bits::serialization_reader_base::read().
|
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 360 of file array.h.
Referenced by tpie::internal_queue< memory_size_type >::memory_coefficient(), tpie::internal_stack_vector_base< T, internal_stack< T > >::memory_coefficient(), tpie::disjoint_sets< value_t >::memory_coefficient(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::memory_coefficient(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::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 367 of file array.h.
Referenced by tpie::internal_queue< memory_size_type >::memory_overhead(), tpie::internal_stack_vector_base< T, internal_stack< T > >::memory_overhead(), tpie::disjoint_sets< value_t >::memory_overhead(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::memory_overhead(), 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 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 |
|
inline |
Return a const reference to an array entry.
i | The index of the entry to return. |
Definition at line 228 of file array.h.
|
inline |
Return a reference to an array entry.
i | The index of the entry to return. |
Definition at line 239 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 431 of file array.h.
Referenced by tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::array(), tpie::merge_sorter< T, UseProgress, pred_t >::begin(), tpie::pipelining::parallel_bits::producer< T1, T2 >::begin(), tpie::merge_sorter< T, UseProgress, pred_t >::end(), tpie::pipelining::parallel_bits::producer< T1, T2 >::end(), tpie::serialization_bits::internal_sort< T, pred_t >::free(), tpie::internal_queue< memory_size_type >::internal_queue(), tpie::internal_stack_vector_base< T, internal_stack< T > >::internal_stack_vector_base(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::operator=(), tpie::merge_sorter< T, UseProgress, pred_t >::pull(), tpie::internal_queue< memory_size_type >::resize(), tpie::internal_stack_vector_base< T, internal_stack< T > >::resize(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::resize(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::resize(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::resize(), and tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::~array().
|
inline |
|
inline |
Return the size of the array.
Definition at line 472 of file array.h.
Referenced by tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::array(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::at(), tpie::internal_queue< memory_size_type >::back(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::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::chaining_hash_table< value_t, hash_t, equal_t, index_t >::clear(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::empty(), tpie::merge_sorter< T, UseProgress, pred_t >::end(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::end(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::end(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_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::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::find(), tpie::chaining_hash_table< value_t, hash_t, equal_t, index_t >::find(), tpie::linear_probing_hash_table< value_t, hash_t, equal_t, index_t >::find(), tpie::internal_queue< memory_size_type >::front(), tpie::internal_queue< memory_size_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::serialization_bits::internal_sort< T, pred_t >::memory_usage(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::operator!=(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::operator=(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::operator==(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::operator[](), tpie::internal_queue< memory_size_type >::push(), tpie::serialization_bits::internal_sort< T, pred_t >::push(), tpie::internal_priority_queue< std::pair< T, size_t >, tpie::merger::predwrap >::push(), tpie::stack< item_type >::push(), tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::rend(), and tpie::array< tpie::pipelining::parallel_bits::parallel_input_buffer< T > * >::resize().
|
inline |
Swap two arrays.
Definition at line 445 of file array.h.
Referenced by tpie::merge_sorter< T, UseProgress, pred_t >::end().