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 () |
| Return the element located at the given index. More... | |
| 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 constexpr double | memory_coefficient () noexcept |
| Return the memory coefficient of the structure. More... | |
| static constexpr double | memory_overhead () noexcept |
| Return the memory overhead of the structure. More... | |
| static constexpr memory_size_type | memory_usage (memory_size_type size) noexcept |
| Return the number of bytes required to create a data structure supporting a given number of elements. More... | |
| static constexpr linear_memory_usage | memory_usage () noexcept |
| static constexpr memory_size_type | memory_fits (memory_size_type memory) noexcept |
| 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 413 of file array.h.
Referenced by tpie::array< tpie::file_stream< element_type > >::memory_overhead().
|
inline |
|
inline |
|
inline |
Move construct from another array.
| other | The array to move. |
|
inline |
|
inline | ||||||||||||||
Return the element located at the given index.
| i | The index of the element returned. |
Definition at line 193 of file array.h.
Referenced by tpie::array< tpie::file_stream< element_type > >::back(), tpie::array< tpie::file_stream< element_type > >::front(), and tpie::array< tpie::file_stream< element_type > >::operator[]().
|
inline | ||||||||||||||
|
inline |
|
inline |
|
inline |
Return an iterator to the beginning of the array.
Definition at line 312 of file array.h.
Referenced by tpie::internal_vector< T >::begin(), tpie::disjoint_sets< value_t >::clear(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::make_safe(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::pop(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::pop_and_push(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::push(), tpie::serialize(), and tpie::unserialize().
|
inline |
|
inline |
|
inline |
Return an iterator to the end of the array.
Definition at line 326 of file array.h.
Referenced by tpie::disjoint_sets< value_t >::clear(), tpie::serialize(), and tpie::unserialize().
|
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 172 of file array.h.
Referenced by tpie::internal_vector< T >::end(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::insert(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::make_safe(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::pop(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::pop_and_push(), and tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::push().
|
inline | ||||||||||||||
|
inline |
|
inline |
|
inline |
Return a raw pointer to the array content.
Definition at line 536 of file array.h.
Referenced by tpie::compressor_buffer::get(), and tpie::bits::serialization_reader_base::read().
|
inline |
|
inline |
|
inlinestaticconstexprnoexcept |
Return the memory coefficient of the structure.
Allocating a structure with n elements will use at most \( \lfloor \mathrm{memory\_coefficient} \cdot n + \mathrm{memory\_overhead} \rfloor \) bytes. This does not include memory overhead incurred if the structure is allocated using new.
Definition at line 398 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(), and tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::memory_coefficient().
|
inlinestaticconstexprnoexceptinherited |
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 |
|
inlinestaticconstexprnoexcept |
Return the memory overhead of the structure.
Definition at line 405 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(), and tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::memory_overhead().
|
inlinestaticconstexprnoexceptinherited |
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 |
Check if two arrays differ.
| other | The array to compare against. |
|
inline |
Move elements from another array into this.
Note: This array is resized to the size of other.
| other | The array to copy from. |
|
inline |
Copy elements from another array into this.
Note: This array is resized to the size of other.
| other | The array to copy from. |
|
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. |
|
inline |
Compare if the other array has the same elements in the same order as this.
| other | The array to compare against. |
|
inline |
|
inline |
|
inline |
|
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 490 of file array.h.
Referenced by tpie::array< tpie::file_stream< element_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, std::less< T > >::free(), tpie::internal_queue< item_type >::internal_queue(), tpie::array< tpie::file_stream< element_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::disjoint_sets< value_t >::resize(), tpie::internal_priority_queue< tpie::ami::heap_ptr< REC >, comp >::resize(), tpie::compressor_buffer::set_capacity(), tpie::unserialize(), and tpie::array< tpie::file_stream< element_type > >::~array().
|
inline |
Return the size of the array.
Definition at line 531 of file array.h.
Referenced by tpie::array< tpie::file_stream< element_type > >::array(), tpie::array< tpie::file_stream< element_type > >::at(), tpie::internal_queue< item_type >::back(), tpie::array< tpie::file_stream< element_type > >::back(), tpie::compressor_buffer::capacity(), tpie::array< tpie::file_stream< element_type > >::empty(), tpie::array< tpie::file_stream< element_type > >::end(), tpie::merge_sorter< T, UseProgress, pred_t, store_t >::end(), tpie::array< tpie::file_stream< element_type > >::find(), tpie::internal_queue< item_type >::front(), tpie::internal_queue< item_type >::full(), tpie::array< tpie::file_stream< element_type > >::operator!=(), tpie::array< tpie::file_stream< element_type > >::operator=(), tpie::array< tpie::file_stream< element_type > >::operator==(), tpie::array< tpie::file_stream< element_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, std::less< T > >::push(), tpie::array< tpie::file_stream< element_type > >::rend(), tpie::array< tpie::file_stream< element_type > >::resize(), and tpie::serialize().
|
inline |
Swap two arrays.
Definition at line 504 of file array.h.
Referenced by tpie::merge_sorter< T, UseProgress, pred_t, store_t >::end(), and std::swap().