Open CASCADE Technology 7.8.2.dev
NCollection_DynamicArray< TheItemType > Class Template Reference

Class NCollection_DynamicArray (dynamic array of objects) More...

#include <NCollection_DynamicArray.hxx>

Inheritance diagram for NCollection_DynamicArray< TheItemType >:

Public Types

typedef NCollection_OccAllocator< TheItemType > allocator_type
 Memory allocation.
 
typedef NCollection_BasePointerVector vector
 
using value_type = TheItemType
 
using size_type = size_t
 
using difference_type = size_t
 
using pointer = TheItemType*
 
using const_pointer = TheItemType&
 
using reference = TheItemType&
 
using const_reference = const TheItemType&
 
using iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_DynamicArray, value_type, false>
 
using const_iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_DynamicArray, value_type, true>
 
using Iterator = NCollection_Iterator<NCollection_DynamicArray<TheItemType>>
 

Public Member Functions

const_iterator begin () const
 
iterator begin ()
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 

public methods

friend iterator
 Copy constructor.
 
friend const_iterator
 Copy constructor.
 
vector myContainer
 Copy constructor.
 
allocator_type myAlloc
 Copy constructor.
 
size_t myInternalSize
 Copy constructor.
 
size_t myUsedSize
 Copy constructor.
 
 NCollection_DynamicArray (const Standard_Integer theIncrement=256)
 Copy constructor.
 
 NCollection_DynamicArray (const Standard_Integer theIncrement, const Handle< NCollection_BaseAllocator > &theAllocator)
 Copy constructor.
 
 NCollection_DynamicArray (const Standard_Integer theIncrement, const allocator_type &theAllocator)
 Copy constructor.
 
 NCollection_DynamicArray (const NCollection_DynamicArray &theOther)
 Copy constructor.
 
 NCollection_DynamicArray (NCollection_DynamicArray &&theOther) noexcept
 Copy constructor.
 
 ~NCollection_DynamicArray ()
 Copy constructor.
 
Standard_Integer Length () const
 Total number of items.
 
Standard_Integer Size () const
 Total number of items in the vector.
 
Standard_Integer Lower () const
 Method for consistency with other collections.
 
Standard_Integer Upper () const
 Method for consistency with other collections.
 
Standard_Boolean IsEmpty () const
 Empty query.
 
NCollection_DynamicArrayAssign (const NCollection_DynamicArray &theOther, const bool theOwnAllocator=true)
 Assignment to the collection of the same type.
 
NCollection_DynamicArrayAssign (NCollection_DynamicArray &&theOther)
 Copy constructor.
 
NCollection_DynamicArrayoperator= (const NCollection_DynamicArray &theOther)
 Assignment operator.
 
NCollection_DynamicArrayoperator= (NCollection_DynamicArray &&theOther) noexcept
 Assignment operator.
 
reference Append (const TheItemType &theValue)
 Append.
 
reference Append (TheItemType &&theValue)
 Append.
 
void EraseLast ()
 Copy constructor.
 
reference Appended ()
 Appends an empty value and returns the reference to it.
 
const_reference operator() (const Standard_Integer theIndex) const
 Operator() - query the const value.
 
const_reference operator[] (const Standard_Integer theIndex) const
 Operator[] - query the const value.
 
const_reference operator[] (const size_t theIndex) const
 Operator[] - query the const value.
 
const_reference Value (const Standard_Integer theIndex) const
 Copy constructor.
 
const_reference First () const
 
reference ChangeFirst ()
 
const_reference Last () const
 
reference ChangeLast ()
 
reference operator() (const Standard_Integer theIndex)
 Operator() - query the value.
 
reference operator[] (const Standard_Integer theIndex)
 Operator[] - query the value.
 
reference operator[] (const size_t theIndex)
 Operator[] - query the value.
 
reference ChangeValue (const Standard_Integer theIndex)
 Copy constructor.
 
reference SetValue (const Standard_Integer theIndex, const TheItemType &theValue)
 SetValue () - set or append a value.
 
reference SetValue (const Standard_Integer theIndex, TheItemType &&theValue)
 SetValue () - set or append a value.
 
void Clear (const bool theReleaseMemory=false)
 Copy constructor.
 
void SetIncrement (const Standard_Integer theIncrement)
 Copy constructor.
 
size_t availableSize () const
 Copy constructor.
 
TheItemType * expandArray ()
 Copy constructor.
 
reference at (const size_t theInd)
 Copy constructor.
 
const_reference at (const size_t theInd) const
 Copy constructor.
 
void copyDate ()
 Copy constructor.
 
TheItemType ** getArray () const
 Wrapper to extract array.
 

Detailed Description

template<class TheItemType>
class NCollection_DynamicArray< TheItemType >

Class NCollection_DynamicArray (dynamic array of objects)

The array's indices always start at 0.

The Vector is always created with 0 length. It can be enlarged by two means:

  1. Calling the method Append (val) - then "val" is added to the end of the vector (the vector length is incremented)
  2. Calling the method SetValue (i, val) - if "i" is greater than or equal to the current length of the vector, the vector is enlarged to accomo- date this index

The methods Append and SetValue return a non-const reference to the copied object inside the vector. This reference is guaranteed to be valid until the vector is destroyed. It can be used to access the vector member directly or to pass its address to other data structures.

The vector iterator remembers the length of the vector at the moment of the creation or initialisation of the iterator. Therefore the iteration begins at index 0 and stops at the index equal to (remembered_length-1). It is OK to enlarge the vector during the iteration.

Member Typedef Documentation

◆ allocator_type

template<class TheItemType >
NCollection_OccAllocator<TheItemType> NCollection_DynamicArray< TheItemType >::allocator_type

Memory allocation.

◆ const_iterator

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::const_iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_DynamicArray, value_type, true>

◆ const_pointer

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::const_pointer = TheItemType&

◆ const_reference

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::const_reference = const TheItemType&

◆ difference_type

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::difference_type = size_t

◆ Iterator

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::Iterator = NCollection_Iterator<NCollection_DynamicArray<TheItemType>>

◆ iterator

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_DynamicArray, value_type, false>

◆ pointer

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::pointer = TheItemType*

◆ reference

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::reference = TheItemType&

◆ size_type

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::size_type = size_t

◆ value_type

template<class TheItemType >
using NCollection_DynamicArray< TheItemType >::value_type = TheItemType

◆ vector

template<class TheItemType >
NCollection_BasePointerVector NCollection_DynamicArray< TheItemType >::vector

Constructor & Destructor Documentation

◆ NCollection_DynamicArray() [1/5]

template<class TheItemType >
NCollection_DynamicArray< TheItemType >::NCollection_DynamicArray ( const Standard_Integer theIncrement = 256)
inline

Copy constructor.

◆ NCollection_DynamicArray() [2/5]

template<class TheItemType >
NCollection_DynamicArray< TheItemType >::NCollection_DynamicArray ( const Standard_Integer theIncrement,
const Handle< NCollection_BaseAllocator > & theAllocator )
inlineexplicit

Copy constructor.

◆ NCollection_DynamicArray() [3/5]

template<class TheItemType >
NCollection_DynamicArray< TheItemType >::NCollection_DynamicArray ( const Standard_Integer theIncrement,
const allocator_type & theAllocator )
inlineexplicit

Copy constructor.

◆ NCollection_DynamicArray() [4/5]

template<class TheItemType >
NCollection_DynamicArray< TheItemType >::NCollection_DynamicArray ( const NCollection_DynamicArray< TheItemType > & theOther)
inline

Copy constructor.

◆ NCollection_DynamicArray() [5/5]

template<class TheItemType >
NCollection_DynamicArray< TheItemType >::NCollection_DynamicArray ( NCollection_DynamicArray< TheItemType > && theOther)
inlinenoexcept

Copy constructor.

◆ ~NCollection_DynamicArray()

template<class TheItemType >
NCollection_DynamicArray< TheItemType >::~NCollection_DynamicArray ( )
inline

Copy constructor.

Member Function Documentation

◆ Append() [1/2]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::Append ( const TheItemType & theValue)
inline

Append.

◆ Append() [2/2]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::Append ( TheItemType && theValue)
inline

Append.

◆ Appended()

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::Appended ( )
inline

Appends an empty value and returns the reference to it.

◆ Assign() [1/2]

template<class TheItemType >
NCollection_DynamicArray & NCollection_DynamicArray< TheItemType >::Assign ( const NCollection_DynamicArray< TheItemType > & theOther,
const bool theOwnAllocator = true )
inline

Assignment to the collection of the same type.

◆ Assign() [2/2]

template<class TheItemType >
NCollection_DynamicArray & NCollection_DynamicArray< TheItemType >::Assign ( NCollection_DynamicArray< TheItemType > && theOther)
inline

Copy constructor.

◆ at() [1/2]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::at ( const size_t theInd)
inlineprotected

Copy constructor.

◆ at() [2/2]

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::at ( const size_t theInd) const
inlineprotected

Copy constructor.

◆ availableSize()

template<class TheItemType >
size_t NCollection_DynamicArray< TheItemType >::availableSize ( ) const
inlineprotected

Copy constructor.

◆ begin() [1/2]

template<class TheItemType >
iterator NCollection_DynamicArray< TheItemType >::begin ( )
inline

◆ begin() [2/2]

template<class TheItemType >
const_iterator NCollection_DynamicArray< TheItemType >::begin ( ) const
inline

◆ cbegin()

template<class TheItemType >
const_iterator NCollection_DynamicArray< TheItemType >::cbegin ( ) const
inline

◆ cend()

template<class TheItemType >
const_iterator NCollection_DynamicArray< TheItemType >::cend ( ) const
inline

◆ ChangeFirst()

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::ChangeFirst ( )
inline
Returns
first element

◆ ChangeLast()

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::ChangeLast ( )
inline
Returns
last element

◆ ChangeValue()

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::ChangeValue ( const Standard_Integer theIndex)
inline

Copy constructor.

◆ Clear()

template<class TheItemType >
void NCollection_DynamicArray< TheItemType >::Clear ( const bool theReleaseMemory = false)
inline

Copy constructor.

◆ copyDate()

template<class TheItemType >
void NCollection_DynamicArray< TheItemType >::copyDate ( )
inlineprotected

Copy constructor.

◆ end() [1/2]

template<class TheItemType >
iterator NCollection_DynamicArray< TheItemType >::end ( )
inline

◆ end() [2/2]

template<class TheItemType >
const_iterator NCollection_DynamicArray< TheItemType >::end ( ) const
inline

◆ EraseLast()

template<class TheItemType >
void NCollection_DynamicArray< TheItemType >::EraseLast ( )
inline

Copy constructor.

◆ expandArray()

template<class TheItemType >
TheItemType * NCollection_DynamicArray< TheItemType >::expandArray ( )
inlineprotected

Copy constructor.

◆ First()

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::First ( ) const
inline
Returns
first element

◆ getArray()

template<class TheItemType >
TheItemType ** NCollection_DynamicArray< TheItemType >::getArray ( ) const
inlineprotected

Wrapper to extract array.

◆ IsEmpty()

template<class TheItemType >
Standard_Boolean NCollection_DynamicArray< TheItemType >::IsEmpty ( ) const
inline

Empty query.

◆ Last()

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::Last ( ) const
inline
Returns
last element

◆ Length()

template<class TheItemType >
Standard_Integer NCollection_DynamicArray< TheItemType >::Length ( ) const
inline

Total number of items.

◆ Lower()

template<class TheItemType >
Standard_Integer NCollection_DynamicArray< TheItemType >::Lower ( ) const
inline

Method for consistency with other collections.

Returns
Lower bound (inclusive) for iteration.

◆ operator()() [1/2]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::operator() ( const Standard_Integer theIndex)
inline

Operator() - query the value.

◆ operator()() [2/2]

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::operator() ( const Standard_Integer theIndex) const
inline

Operator() - query the const value.

◆ operator=() [1/2]

template<class TheItemType >
NCollection_DynamicArray & NCollection_DynamicArray< TheItemType >::operator= ( const NCollection_DynamicArray< TheItemType > & theOther)
inline

Assignment operator.

◆ operator=() [2/2]

template<class TheItemType >
NCollection_DynamicArray & NCollection_DynamicArray< TheItemType >::operator= ( NCollection_DynamicArray< TheItemType > && theOther)
inlinenoexcept

Assignment operator.

◆ operator[]() [1/4]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::operator[] ( const size_t theIndex)
inline

Operator[] - query the value.

◆ operator[]() [2/4]

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::operator[] ( const size_t theIndex) const
inline

Operator[] - query the const value.

◆ operator[]() [3/4]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::operator[] ( const Standard_Integer theIndex)
inline

Operator[] - query the value.

◆ operator[]() [4/4]

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::operator[] ( const Standard_Integer theIndex) const
inline

Operator[] - query the const value.

◆ SetIncrement()

template<class TheItemType >
void NCollection_DynamicArray< TheItemType >::SetIncrement ( const Standard_Integer theIncrement)
inline

Copy constructor.

◆ SetValue() [1/2]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::SetValue ( const Standard_Integer theIndex,
const TheItemType & theValue )
inline

SetValue () - set or append a value.

◆ SetValue() [2/2]

template<class TheItemType >
reference NCollection_DynamicArray< TheItemType >::SetValue ( const Standard_Integer theIndex,
TheItemType && theValue )
inline

SetValue () - set or append a value.

◆ Size()

template<class TheItemType >
Standard_Integer NCollection_DynamicArray< TheItemType >::Size ( ) const
inline

Total number of items in the vector.

◆ Upper()

template<class TheItemType >
Standard_Integer NCollection_DynamicArray< TheItemType >::Upper ( ) const
inline

Method for consistency with other collections.

Returns
Upper bound (inclusive) for iteration.

◆ Value()

template<class TheItemType >
const_reference NCollection_DynamicArray< TheItemType >::Value ( const Standard_Integer theIndex) const
inline

Copy constructor.

Field Documentation

◆ const_iterator

template<class TheItemType >
friend NCollection_DynamicArray< TheItemType >::const_iterator

Copy constructor.

◆ iterator

template<class TheItemType >
friend NCollection_DynamicArray< TheItemType >::iterator

Copy constructor.

◆ myAlloc

template<class TheItemType >
allocator_type NCollection_DynamicArray< TheItemType >::myAlloc
protected

Copy constructor.

◆ myContainer

template<class TheItemType >
vector NCollection_DynamicArray< TheItemType >::myContainer
protected

Copy constructor.

◆ myInternalSize

template<class TheItemType >
size_t NCollection_DynamicArray< TheItemType >::myInternalSize
protected

Copy constructor.

◆ myUsedSize

template<class TheItemType >
size_t NCollection_DynamicArray< TheItemType >::myUsedSize
protected

Copy constructor.


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