ConstDataList< DL > Class Template Reference

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

#include <ConstDataList.h>

List of all members.

Public Types

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

Public Member Functions

Constructors, destructors, assignment.



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



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_front (value_type pElem)
 Add an element at the beginning of the collection.
void push_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.
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.
List operations.



void splice (iterator position, ConstDataList &l)
 Insert contents of another list.
void splice (iterator position, ConstDataList &l, iterator i)
 Insert element from another list.
void splice (iterator position, ConstDataList &l, iterator first, iterator last)
 Insert range from another list.
void remove (const value_type &value)
 Remove all elements equal to value.
void merge (ConstDataList &l)
 Merge sorted lists.
template<typename COMPARE >
void merge (ConstDataList &l, COMPARE predicate)
 Merge sorted lists according to comparison function.
Non-standard operations.



void swapElement (iterator pos, value_type newElem, reference oldElem)
 Swap one element out of the container.
const DL * asDataList () const
 Return a pointer to this object, as a const DataList.
void resortAux (iterator beg, iterator end)
 Reset indices / reorder aux data after elements have been permuted.
Relational operators.



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

Static Public Attributes

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

Private helpers.



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

Swap and sort.



void swap (ConstDataList &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 DL>
class ConstDataList< DL >

DataList adapter that acts like it holds const pointers.


Member Typedef Documentation

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

template<class DL>
typedef std::reverse_iterator<iterator> ConstDataList< DL >::reverse_iterator

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

template<class DL>
typedef DL::const_value_type ConstDataList< DL >::value_type

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


Constructor & Destructor Documentation

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

Default constructor.

Parameters:
ownPolicy The ownership mode for the container.

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

template<class DL >
ConstDataList< DL >::ConstDataList ( 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 list constructor, you can't specify an initial value here. The container will be initialized with 0's.

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

template<class DL >
template<class InputIterator >
ConstDataList< DL >::ConstDataList ( 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 DataList 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 DL >
const DL * ConstDataList< DL >::asDataList (  )  const [inline]

Return a pointer to this object, as a const DataList.

Return a pointer to this object, as a const DataVector.

template<class DL >
template<class InputIterator >
void ConstDataList< DL >::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 DataList's ownership policy determines whether it will take ownership of the new elements.

template<class DL >
ConstDataList< DL >::ElementProxy ConstDataList< DL >::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 DL >
ConstDataList< DL >::iterator ConstDataList< DL >::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 DL >
ConstDataList< DL >::iterator ConstDataList< DL >::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 DL >
ConstDataList< DL >::iterator ConstDataList< DL >::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 DL >
ConstDataList< DL >::iterator ConstDataList< DL >::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 DL >
ConstDataList< DL >::ElementProxy ConstDataList< DL >::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 DL >
template<class InputIterator >
void ConstDataList< DL >::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 DataList in the hierarchy.

template<class DL >
ConstDataList< DL >::iterator ConstDataList< DL >::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 DataList in the hierarchy.

template<class DL >
void ConstDataList< DL >::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 DL >
template<typename COMPARE >
void ConstDataList< DL >::merge ( ConstDataList< DL > &  l,
COMPARE  predicate 
) [inline]

Merge sorted lists according to comparison function.

Parameters:
l Sorted list to merge.
predicate Comparison function defining a sort order (which must be strictly weak ordering).

Assumes that both l and this DataList are sorted according to COMPARE predicate. Merges elements of l into this list in sorted order, leaving l empty when complete. Elements in this list precede elements in x that are equivalent according to StrictWeakOrdering().

template<class DL >
void ConstDataList< DL >::merge ( ConstDataList< DL > &  l  )  [inline]

Merge sorted lists.

Parameters:
l Sorted list to merge.

Assumes that both l and this list are sorted according to operator<(). Merges elements of l into this list in sorted order, leaving l empty when complete. Elements in this list precede elements in l that are equal.

template<class DL >
bool ConstDataList< DL >::operator< ( const ConstDataList< DL > &  b  )  const [inline]

List ordering relation.

Parameters:
a A ConstDataList.
b A ConstDataList 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 lists. Comparisons are done on the pointer values of the elements.

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

template<class DL >
ConstDataList< DL > & ConstDataList< DL >::operator= ( const ConstDataList< DL > &  rhs  )  [inline]

Assignment operator.

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

This is a `shallow' copy; after the completion of this, the DataList 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 DataList in the hierarchy.

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

List equality comparison.

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

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

template<class DL >
void ConstDataList< DL >::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 DataList in the hierarchy.

template<class DL >
void ConstDataList< DL >::push_front ( value_type  pElem  )  [inline]

Add an element at the beginning 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 DataList in the hierarchy.

template<class DL >
ConstDataList< DL >::reverse_iterator ConstDataList< DL >::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 DL >
void ConstDataList< DL >::remove ( const value_type value  )  [inline]

Remove all elements equal to value.

Parameters:
value The value to remove.

Removes every element in the list equal to value. Remaining elements stay in list order.

template<class DL >
ConstDataList< DL >::reverse_iterator ConstDataList< DL >::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 DL >
void ConstDataList< DL >::resortAux ( iterator  beg,
iterator  end 
) [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 ConstDataList.

template<class DL >
void ConstDataList< DL >::splice ( iterator  position,
ConstDataList< DL > &  l,
iterator  first,
iterator  last 
) [inline]

Insert range from another list.

Parameters:
position Iterator referencing the element to insert before.
l Source list.
first Iterator referencing the start of range in l.
last Iterator referencing the end of range in l.

Removes elements in the range [first, last ) and inserts them before position in constant time.

Undefined if position is in [first, last ).

template<class DL >
void ConstDataList< DL >::splice ( iterator  position,
ConstDataList< DL > &  l,
iterator  i 
) [inline]

Insert element from another list.

Parameters:
position Iterator referencing the element to insert before.
l Source list.
i Iterator referencing the element to move.

Removes the element in list l referenced by i and inserts it into the current list before position.

template<class DL >
void ConstDataList< DL >::splice ( iterator  position,
ConstDataList< DL > &  l 
) [inline]

Insert contents of another list.

Parameters:
position Iterator referencing the element to insert before.
l Source list.

The elements of l are inserted in constant time in front of the element referenced by position. l becomes an empty list.

template<class DL >
void ConstDataList< DL >::swap ( ConstDataList< DL > &  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 DataList in the hierarchy. The rhs must also be referenced using the most-derived DataList.

template<class DL >
void ConstDataList< DL >::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.


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