AvogadroLibs 1.100.0
|
Base class for array containers. More...
#include <avogadro/core/array.h>
Public Types | |
using | Container = internal::ArrayRefContainer<T> |
using | ValueType = T |
using | value_type = typename Container::value_type |
using | allocator_type = typename Container::allocator_type |
using | reference = typename Container::reference |
using | const_reference = typename Container::const_reference |
using | pointer = typename Container::pointer |
using | const_pointer = typename Container::const_pointer |
using | iterator = typename Container::iterator |
using | const_iterator = typename Container::const_iterator |
using | reverse_iterator = typename Container::reverse_iterator |
using | const_reverse_iterator = typename Container::const_reverse_iterator |
using | difference_type = typename Container::difference_type |
using | size_type = typename Container::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.
using value_type = typename Container::value_type |
Typedefs for STL compatibility
using allocator_type = typename Container::allocator_type |
Typedefs for STL compatibility
using reference = typename Container::reference |
Typedefs for STL compatibility
using const_reference = typename Container::const_reference |
Typedefs for STL compatibility
using pointer = typename Container::pointer |
Typedefs for STL compatibility
using const_pointer = typename Container::const_pointer |
Typedefs for STL compatibility
using iterator = typename Container::iterator |
Typedefs for STL compatibility
using const_iterator = typename Container::const_iterator |
Typedefs for STL compatibility
using reverse_iterator = typename Container::reverse_iterator |
Typedefs for STL compatibility
using const_reverse_iterator = typename Container::const_reverse_iterator |
Typedefs for STL compatibility
using difference_type = typename Container::difference_type |
Typedefs for STL compatibility
using size_type = typename Container::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. |