ConstDataVector< DV > Class Template Reference

DataVector adapter that acts like it holds const pointers. More...

#include <ConstDataVector.h>

List of all members.

Public Types

typedef DV::size_type size_type
 Basic types, forwarded from the base.
typedef DV::difference_type difference_type
typedef DV::allocator_type allocator_type
typedef DV::base_value_type base_value_type
typedef DV::BaseContainer BaseContainer
typedef DV::DVL_BASE DVL_BASE
typedef DV::const_iterator const_iterator
typedef DV::const_reverse_iterator const_reverse_iterator
typedef DataVector
< base_value_type > 
base_data_vector
typedef DV::const_value_type value_type
typedef DV::const_value_type const_value_type
typedef DV::const_value_type & reference
typedef DV::const_value_type
const & 
const_reference
typedef DV::const_value_type * pointer
typedef DV::const_value_type
const * 
const_pointer
typedef
DataModel_detail::ElementProxy
< ConstDataVector
ElementProxy
typedef
DataModel_detail::iterator
< ConstDataVector
iterator
 The iterator for this type.
typedef std::reverse_iterator
< iterator
reverse_iterator

Public Member Functions

Constructors, destructors, assignment.



 ConstDataVector (SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
 Default constructor.
 ConstDataVector (size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
 Sized constructor.
template<class InputIterator >
 ConstDataVector (InputIterator first, InputIterator last, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
 Constructor from iterators.
ConstDataVectoroperator= (const ConstDataVector &rhs)
 Copy constructor.
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 Assign from iterators.
Element access.



ElementProxy operator[] (size_type n)
 Access an element, as an lvalue.
ElementProxy at (size_type n)
 Access an element, as an lvalue.
ElementProxy front ()
 Access the first element in the collection as an lvalue.
ElementProxy back ()
 Access the last element in the collection as an lvalue.
Iterator creation.



iterator begin ()
 Return an iterator pointing at the beginning of the collection.
iterator end ()
 Return an iterator pointing past the end of the collection.
reverse_iterator rbegin ()
 Return a reverse_iterator pointing past the end of the collection.
reverse_iterator rend ()
 Return a reverse_iterator pointing at the beginning of the collection.
Insertion operations.



void push_back (value_type pElem)
 Add an element to the end of the collection.
void emplace_back (value_type pElem)
 Add an element to the end of the collection.
iterator insert (iterator position, value_type pElem)
 Add a new element to the collection.
iterator emplace (iterator position, value_type pElem)
 Add a new element to the collection.
template<class InputIterator >
void insert (iterator position, InputIterator first, InputIterator last)
 Add a group of new elements to the collection.
Erasure operations.



iterator erase (iterator position)
 Remove element at a given position.
iterator erase (iterator first, iterator last)
 Remove a range of elements.
void clear ()
 Erase all the elements in the collection.
Non-standard operations.



void swapElement (size_type index, value_type newElem, reference oldElem)
 Swap one element out of the container.
void swapElement (iterator pos, value_type newElem, reference oldElem)
 Swap one element out of the container.
const DV * asDataVector () const
 Return a pointer to this object, as a const DataVector.
void resortAux (iterator, iterator)
 Reset indices / reorder aux data after elements have been permuted.
void clear (SG::OwnershipPolicy ownPolicy)
 Erase all the elements in the collection, and reset the ownership mode.
const SG::AuxVectorBaseauxbase () const
 Convert to AuxVectorBase.
Relational operators.



bool operator< (const ConstDataVector &b) const
 Vector ordering relation.
bool operator> (const ConstDataVector &b) const
 Based on operator<.
bool operator<= (const ConstDataVector &b) const
 Based on operator<.
bool operator>= (const ConstDataVector &b) const
 Based on operator<.
bool operator== (const ConstDataVector &b) const
 Vector equality comparison.
bool operator!= (const ConstDataVector &b) const
 Based on operator==.

Static Public Attributes

static const bool has_virtual = DV::has_virtual
 This needs to be forwarded from the base as well.

Private helpers.



class DataModel_detail::ElementProxy< ConstDataVector >
void test2_assignelement1 ()

Swap and sort.



void swap (ConstDataVector &rhs)
 Swap this collection with another.
static void iter_swap (iterator a, iterator b)
 Swap the referents of two DataVector iterators.

Detailed Description

template<class DV>
class ConstDataVector< DV >

DataVector adapter that acts like it holds const pointers.


Member Typedef Documentation

This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.

template<class DV>
typedef std::reverse_iterator<iterator> ConstDataVector< DV >::reverse_iterator

Standard reverse_iterator. Note that lvalue references here will yield an ElementProxy, not a reference.

template<class DV>
typedef DV::const_value_type ConstDataVector< DV >::value_type

These types get modified so that the base's const_value_type becomes our value_type.


Constructor & Destructor Documentation

template<class DV >
ConstDataVector< DV >::ConstDataVector ( SG::OwnershipPolicy  ownPolicy = SG::OWN_ELEMENTS  )  [inline, explicit]

Default constructor.

Parameters:
ownPolicy The ownership mode for the container.

By default, a DataVector will own its elements. To avoid this, pass SG::VIEW_ELEMENTS for ownPolicy.

template<class DV >
ConstDataVector< DV >::ConstDataVector ( size_type  n,
SG::OwnershipPolicy  ownPolicy = SG::OWN_ELEMENTS 
) [inline, explicit]

Sized constructor.

Parameters:
n The size of the container.
ownPolicy The ownership mode for the container.

Note that unlike the standard vector constructor, you can't specify an initial value here. The container will be initialized with 0's.

By default, a DataVector will own its elements. To avoid this, pass SG::VIEW_ELEMENTS for ownPolicy.

template<class DV >
template<class InputIterator >
ConstDataVector< DV >::ConstDataVector ( InputIterator  first,
InputIterator  last,
SG::OwnershipPolicy  ownPolicy = SG::VIEW_ELEMENTS 
) [inline]

Constructor from iterators.

Parameters:
first The start of the range to put in the new container.
last The end of the range to put in the new container.
ownPolicy The ownership mode for the container.

By default, a DataVector will own its elements (and take ownership of the pointers passed to this constructor). To avoid this, pass SG::VIEW_ELEMENTS for ownPolicy.


Member Function Documentation

template<class DV >
template<class InputIterator >
void ConstDataVector< DV >::assign ( InputIterator  first,
InputIterator  last 
) [inline]

Assign from iterators.

Parameters:
first The start of the range to put in the container.
last The end of the range to put in the container.

Any existing owned elements will be released. The DataVector's ownership policy determines whether it will take ownership of the new elements.

template<class DV >
ConstDataVector< DV >::ElementProxy ConstDataVector< DV >::at ( size_type  n  )  [inline]

Access an element, as an lvalue.

Parameters:
n Array index to access.
Returns:
Proxy to the element at n.

Will raise std::out_of_range if the index is out-of-bounds. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
const SG::AuxVectorBase & ConstDataVector< DV >::auxbase (  )  const [inline]

Convert to AuxVectorBase.

Needed to get AuxVectorBase from a ConstDataVector. Present in DataVector as well for consistency.

template<class DV >
ConstDataVector< DV >::ElementProxy ConstDataVector< DV >::back (  )  [inline]

Access the last element in the collection as an lvalue.

Returns:
Proxy to the last element in the collection.

No checking is done to ensure that the container is not empty. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
ConstDataVector< DV >::iterator ConstDataVector< DV >::begin (  )  [inline]

Return an iterator pointing at the beginning of the collection.

Returns:
An iterator.

Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
void ConstDataVector< DV >::clear ( SG::OwnershipPolicy  ownPolicy  )  [inline]

Erase all the elements in the collection, and reset the ownership mode.

Parameters:
ownPolicy The new ownership policy of the container.

If the container owns its elements, then the removed elements will be deleted. Any duplicates will be removed in this process, but don't rely on this.

template<class DV >
void ConstDataVector< DV >::clear (  )  [inline]

Erase all the elements in the collection.

clear()

If the container owns its elements, then the removed elements will be deleted. Any duplicates will be removed in this process, but don't rely on this.

Erase all the elements in the collection. If the container owns its elements, then the removed elements will be deleted. Any duplicates will be removed in this process, but don't rely on this.

template<class DV >
ConstDataVector< DV >::iterator ConstDataVector< DV >::emplace ( iterator  position,
value_type  pElem 
) [inline]

Add a new element to the collection.

Parameters:
position Iterator before which the element will be added.
pElem The element to add to the collection.
Returns:
An iterator that points to the inserted data.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

For DataVector, this is just the same as insert. It's included just for interface compatibility with `stdvector`.

template<class DV >
void ConstDataVector< DV >::emplace_back ( value_type  pElem  )  [inline]

Add an element to the end of the collection.

Parameters:
pElem The element to add to the collection.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

For DataVector, this is just the same as push_back. It's included just for interface compatibility with `stdvector`.

template<class DV >
ConstDataVector< DV >::iterator ConstDataVector< DV >::end (  )  [inline]

Return an iterator pointing past the end of the collection.

Returns:
An iterator.

Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
ConstDataVector< DV >::iterator ConstDataVector< DV >::erase ( iterator  first,
iterator  last 
) [inline]

Remove a range of elements.

Parameters:
first Iterator pointing to the first element to be removed.
last Iterator pointing one past the last element to be removed.
Returns:
An iterator pointing to the element pointed to by last prior to erasing (or end()).

If the container owns its elements, then the removed elements will be deleted. Any duplicates will be removed in this process, but don't rely on this.

template<class DV >
ConstDataVector< DV >::iterator ConstDataVector< DV >::erase ( iterator  position  )  [inline]

Remove element at a given position.

Parameters:
position Iterator pointing to the element to be removed.
Returns:
An iterator pointing to the next element (or end()).

If the container owns its elements, then the pointed-to element will be deleted.

template<class DV >
ConstDataVector< DV >::ElementProxy ConstDataVector< DV >::front (  )  [inline]

Access the first element in the collection as an lvalue.

Returns:
Proxy to the first element in the collection.

No checking is done to ensure that the container is not empty. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
template<class InputIterator >
void ConstDataVector< DV >::insert ( iterator  position,
InputIterator  first,
InputIterator  last 
) [inline]

Add a group of new elements to the collection.

Parameters:
position Iterator before which the element will be added.
first The start of the range to put in the container.
last The end of the range to put in the container.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

template<class DV >
ConstDataVector< DV >::iterator ConstDataVector< DV >::insert ( iterator  position,
value_type  pElem 
) [inline]

Add a new element to the collection.

Parameters:
position Iterator before which the element will be added.
pElem The element to add to the collection.
Returns:
An iterator that points to the inserted data.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

template<class DV >
void ConstDataVector< DV >::iter_swap ( iterator  a,
iterator  b 
) [inline, static]

Swap the referents of two DataVector iterators.

Parameters:
a The first iterator for the swap.
b The second iterator for the swap/
template<class DV >
bool ConstDataVector< DV >::operator< ( const ConstDataVector< DV > &  b  )  const [inline]

Vector ordering relation.

Parameters:
a A ConstDataVector.
b A ConstDataVector of the same type as x.
Returns:
True iff x is lexicographically less than y.

This is a total ordering relation. It is linear in the size of the vectors. Comparisons are done on the pointer values of the elements.

See std::lexicographical_compare() for how the determination is made.

template<class DV >
ConstDataVector< DV > & ConstDataVector< DV >::operator= ( const ConstDataVector< DV > &  rhs  )  [inline]

Copy constructor.

Assignment operator.

Parameters:
rhs The container from which to copy.

This is a `shallow' copy; the new container will not own its elements. Assignment operator.

Parameters:
rhs The DataVector from which to assign.
Returns:
This object.

This is a `shallow' copy; after the completion of this, the DataVector will not own its elements. Any elements it owned prior to this call will be released.

Note: this method may only be called using the most derived DataVector in the hierarchy.

Parameters:
rhs The DataVector from which to assign.
Returns:
This object.

This is a `shallow' copy; after the completion of this, the DataVector will not own its elements. Any elements it owned prior to this call will be released.

Note: this method may only be called using the most derived DataVector in the hierarchy.

template<class DV >
bool ConstDataVector< DV >::operator== ( const ConstDataVector< DV > &  b  )  const [inline]

Vector equality comparison.

Parameters:
a A ConstDataVector.
b A ConstDataVector of the same type as x.
Returns:
True iff the size and elements of the vectors are equal.

This is an equivalence relation. It is linear in the size of the vectors. Vectors are considered equivalent if their sizes are equal, and if corresponding elements compare equal.

template<class DV >
ConstDataVector< DV >::ElementProxy ConstDataVector< DV >::operator[] ( size_type  n  )  [inline]

Access an element, as an lvalue.

Parameters:
n Array index to access.
Returns:
Proxy to the element at n.

No bounds checking is done. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
void ConstDataVector< DV >::push_back ( value_type  pElem  )  [inline]

Add an element to the end of the collection.

Parameters:
pElem The element to add to the collection.

The container's ownership policy will determine if it takes ownership of the new element.

Note: this method may only be called using the most derived DataVector in the hierarchy.

template<class DV >
ConstDataVector< DV >::reverse_iterator ConstDataVector< DV >::rbegin (  )  [inline]

Return a reverse_iterator pointing past the end of the collection.

Returns:
A reverse_iterator.

Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
ConstDataVector< DV >::reverse_iterator ConstDataVector< DV >::rend (  )  [inline]

Return a reverse_iterator pointing at the beginning of the collection.

Returns:
A reverse_iterator.

Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.

template<class DV >
void ConstDataVector< DV >::resortAux ( iterator  ,
iterator   
) [inline]

Reset indices / reorder aux data after elements have been permuted.

Parameters:
beg Start of the range of elements to process.
end End of the range of elements to process.

This is a no-op for ConstDataVector.

template<class DV >
void ConstDataVector< DV >::swap ( ConstDataVector< DV > &  rhs  )  [inline]

Swap this collection with another.

Parameters:
rhs The collection with which to swap.

Ownership is swapped along with the collection content.

Note: this method may only be called using the most-derived DataVector in the hierarchy. The rhs must also be referenced using the most-derived DataVector.

template<class DV >
void ConstDataVector< DV >::swapElement ( iterator  pos,
value_type  newElem,
reference  oldElem 
) [inline]

Swap one element out of the container.

Parameters:
pos The element in the container to swap.
newElem New element to put in the container. May be 0.
oldElem Reference to receive the element removed from the container.

Reference oldElem is initialized with element pos of the collection (no bounds checking). Then element index is set to newElem. If the collection owns its elements, then it will take ownership of newElem and release (without deleting) the element returned through oldElem.

Note: this method may only be called using the most derived DataList in the hierarchy.

template<class DV >
void ConstDataVector< DV >::swapElement ( size_type  index,
value_type  newElem,
reference  oldElem 
) [inline]

Swap one element out of the container.

Parameters:
index Index of the element in the container to swap.
newElem New element to put in the container. May be 0.
oldElem Reference to receive the element removed from the container.

Reference oldElem is initialized with element index of the collection (no bounds checking). Then element index is set to newElem. If the collection owns its elements, then it will take ownership of newElem and release (without deleting) the element returned through oldElem.

Note: this method may only be called using the most derived DataVector in the hierarchy.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1