AvogadroLibs 1.98.1
|
Base class for array containers. More...
#include <avogadro/core/array.h>
Public Types | |
typedef internal::ArrayRefContainer< T > | Container |
typedef T | ValueType |
typedef Container::value_type | value_type |
typedef Container::allocator_type | allocator_type |
typedef Container::reference | reference |
typedef Container::const_reference | const_reference |
typedef Container::pointer | pointer |
typedef Container::const_pointer | const_pointer |
typedef Container::iterator | iterator |
typedef Container::const_iterator | const_iterator |
typedef Container::reverse_iterator | reverse_iterator |
typedef Container::const_reverse_iterator | const_reverse_iterator |
typedef Container::difference_type | difference_type |
typedef Container::size_type | size_type |
Public Member Functions | |
Array () | |
Array (const size_t n, const ValueType &value=ValueType()) | |
template<typename InputIterator > | |
Array (InputIterator first, InputIterator last) | |
Array (const Array &other) | |
void | detachWithCopy () |
void | detach () |
T * | data () |
const T * | data () const |
const T * | constData () const |
size_t | size () const |
size_t | max_size () const |
bool | empty () const |
size_t | capacity () const |
void | reserve (const size_t &sz) |
void | resize (const size_t &sz, const ValueType &t=ValueType()) |
void | clear () |
const_iterator | begin () const |
const_iterator | end () const |
iterator | begin () |
iterator | end () |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
reference | front () |
const_reference | front () const |
reference | back () |
const_reference | back () const |
template<class InputIterator > | |
void | assign (InputIterator first, InputIterator last) |
void | assign (size_type n, const value_type &val) |
void | push_back (const ValueType &v) |
void | pop_back () |
iterator | insert (iterator position, const value_type &val) |
void | insert (iterator position, size_type n, const value_type &val) |
template<class InputIterator > | |
void | insert (iterator position, InputIterator first, InputIterator last) |
iterator | erase (iterator position) |
iterator | erase (iterator first, iterator last) |
const ValueType & | operator[] (const std::size_t &idx) const |
ValueType & | operator[] (const std::size_t &idx) |
ValueType | at (const std::size_t &idx) const |
template<typename OtherT > | |
Array & | operator= (const std::vector< OtherT > &v) |
template<typename OtherT > | |
Array & | operator= (const Array< OtherT > &v) |
Array & | operator= (const Array &v) |
void | swap (Array< ValueType > &other) |
void | swapAndPop (Index index) |
Protected Attributes | |
Container * | d |
This templated class gives us a container with copy-on-write semantics, allowing for functions to effectively share data without exposing access or copying large amounts of data until the container is changed.
All const functions can be called without copying any data, but a call to a non-const function will trigger a detach call. This is a no-op when the reference count is 1, and will perform a deep copy when the reference count is greater than 1.
typedef Container::value_type value_type |
Typedefs for STL compatibility
typedef Container::allocator_type allocator_type |
Typedefs for STL compatibility
typedef Container::reference reference |
Typedefs for STL compatibility
typedef Container::const_reference const_reference |
Typedefs for STL compatibility
typedef Container::pointer pointer |
Typedefs for STL compatibility
typedef Container::const_pointer const_pointer |
Typedefs for STL compatibility
typedef Container::iterator iterator |
Typedefs for STL compatibility
typedef Container::const_iterator const_iterator |
Typedefs for STL compatibility
typedef Container::reverse_iterator reverse_iterator |
Typedefs for STL compatibility
typedef Container::const_reverse_iterator const_reverse_iterator |
Typedefs for STL compatibility
typedef Container::difference_type difference_type |
Typedefs for STL compatibility
typedef Container::size_type size_type |
Typedefs for STL compatibility
Array | ( | ) |
Constructors for new containers.
Copy constructor, note the copy made of the internal data of other.
void detachWithCopy | ( | ) |
Explicitly detach from any other implicitly shared containers. This is not normally necessary, but can be useful when you want to ensure you have a copy of all data.
void detach | ( | ) |
Explicitly detach from any other implicitly shared containers. This version does not copy the data.
T * data | ( | ) |
Retrieve a pointer to the underlying data.
void swapAndPop | ( | Index | index | ) |
index | array position to delete if the index is valid swap it with the last position and pop back. This function does not preserve the elements order. |