AvogadroLibs 1.100.0
Loading...
Searching...
No Matches
Array< T > Class Template Reference

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
iterator begin ()
const_iterator end () const
iterator end ()
const_reverse_iterator rbegin () const
reverse_iterator rbegin ()
const_reverse_iterator rend () const
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>
Arrayoperator= (const std::vector< OtherT > &v)
template<typename OtherT>
Arrayoperator= (const Array< OtherT > &v)
Arrayoperator= (const Array &v)
void swap (Array< ValueType > &other)
void swapAndPop (Index index)

Protected Attributes

Container * d

Detailed Description

template<typename T>
class Avogadro::QtGui::Array< T >

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.

Member Typedef Documentation

◆ value_type

template<typename T>
using value_type = typename Container::value_type

Typedefs for STL compatibility

◆ allocator_type

template<typename T>
using allocator_type = typename Container::allocator_type

Typedefs for STL compatibility

◆ reference

template<typename T>
using reference = typename Container::reference

Typedefs for STL compatibility

◆ const_reference

template<typename T>
using const_reference = typename Container::const_reference

Typedefs for STL compatibility

◆ pointer

template<typename T>
using pointer = typename Container::pointer

Typedefs for STL compatibility

◆ const_pointer

template<typename T>
using const_pointer = typename Container::const_pointer

Typedefs for STL compatibility

◆ iterator

template<typename T>
using iterator = typename Container::iterator

Typedefs for STL compatibility

◆ const_iterator

template<typename T>
using const_iterator = typename Container::const_iterator

Typedefs for STL compatibility

◆ reverse_iterator

template<typename T>
using reverse_iterator = typename Container::reverse_iterator

Typedefs for STL compatibility

◆ const_reverse_iterator

template<typename T>
using const_reverse_iterator = typename Container::const_reverse_iterator

Typedefs for STL compatibility

◆ difference_type

template<typename T>
using difference_type = typename Container::difference_type

Typedefs for STL compatibility

◆ size_type

template<typename T>
using size_type = typename Container::size_type

Typedefs for STL compatibility

Constructor & Destructor Documentation

◆ Array() [1/2]

template<typename T>
Array ( )

Constructors for new containers.

◆ Array() [2/2]

template<typename T>
Array ( const Array< T > & other)

Copy constructor, note the copy made of the internal data of other.

Member Function Documentation

◆ detachWithCopy()

template<typename T>
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.

◆ detach()

template<typename T>
void detach ( )

Explicitly detach from any other implicitly shared containers. This version does not copy the data.

◆ data()

template<typename T>
T * data ( )

Retrieve a pointer to the underlying data.

◆ swapAndPop()

template<typename T>
void swapAndPop ( Index index)
Parameters
indexarray 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.

The documentation for this class was generated from the following file: