AvogadroLibs 1.98.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
Array< T > Class Template Reference

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 >
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

Containerd
 

Detailed Description

template<typename T>
class Avogadro::Core::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 >
typedef Container::value_type value_type

Typedefs for STL compatibility

◆ allocator_type

template<typename T >
typedef Container::allocator_type allocator_type

Typedefs for STL compatibility

◆ reference

template<typename T >
typedef Container::reference reference

Typedefs for STL compatibility

◆ const_reference

template<typename T >
typedef Container::const_reference const_reference

Typedefs for STL compatibility

◆ pointer

template<typename T >
typedef Container::pointer pointer

Typedefs for STL compatibility

◆ const_pointer

template<typename T >
typedef Container::const_pointer const_pointer

Typedefs for STL compatibility

◆ iterator

template<typename T >
typedef Container::iterator iterator

Typedefs for STL compatibility

◆ const_iterator

template<typename T >
typedef Container::const_iterator const_iterator

Typedefs for STL compatibility

◆ reverse_iterator

template<typename T >
typedef Container::reverse_iterator reverse_iterator

Typedefs for STL compatibility

◆ const_reverse_iterator

template<typename T >
typedef Container::const_reverse_iterator const_reverse_iterator

Typedefs for STL compatibility

◆ difference_type

template<typename T >
typedef Container::difference_type difference_type

Typedefs for STL compatibility

◆ size_type

template<typename T >
typedef Container::size_type 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: