Public Types | |
| typedef E | value_type |
| element type | |
| typedef E & | reference |
| element reference type | |
| typedef const E & | const_reference |
| ... constant version | |
Public Member Functions | |
| Array () | |
| Create an empty array. | |
| Array (int n) | |
| Create an array with n elements, initialized with the default constructor. | |
| Array (int n, const E &init) | |
| Create an array with n elements, initialized with the same value. | |
| template<typename Iterator> | |
| Array (int n, Iterator src, typename disable_if< void *, std::numeric_limits< Iterator >::is_specialized >::type=0) | |
| Create an array with n, initialized from a data sequence. | |
| template<size_t n> | |
| Array (const E(&a)[n]) | |
| Create an array with n elements, initialized from a built-in array. | |
| template<typename E2, size_t n> | |
| Array (const E2(&a)[n]) | |
| ... with explicit element conversion. | |
| int | size () const |
| number of elements | |
| bool | empty () const |
| true if empty | |
| void | clear () |
| truncate to zero size | |
| void | resize (int n) |
| void | resize (int n, const E &x) |
| Same as above, with explicit element construction. | |
| template<typename Iterator> | |
| void | append (int n, Iterator src) |
| Keep the old elements, add n new elements to the tail, assign them values from the data sequence. | |
| void | fill (const E &x) |
| Assign x to all elements. | |
| template<int n> | |
| Array & | operator= (const E(&a)[n]) |
| Resize to n elements, assign values from the built-in array. | |
| void | swap (Array &a) |
| Swap the contents of two arrays in a most efficient way. | |
| E & | operator[] (int i) |
| random access | |
| const E & | operator[] (int i) const |
| ... constant version | |
Protected Attributes | |
|
shared_array< E, typename concat_list< SharedParams, AliasHandler < shared_alias_handler > >::type > | data |
| data array | |
Offers practically the same as std::vector. The only significant differences are that the data array is attached via a smart pointer with reference counting, and the set of operations changing the size of the array is reduced to the minimum.
Array inplements STL's "Random Access Container" interface. The element index in the random access method should lie in the valid range, the array does not grow implicitly.
| void pm::Array< E, SharedParams >::resize | ( | int | n | ) | [inline] |
If n is less than the current array length, delete the trailing elements. If greater, add new elements initialized with the default constructor resp. the copies of the given value x.
Unlike std::vector, Array never allocates extra stock storage. Each resize operation causes the data area reallocation.