Open CASCADE Technology 7.8.0
Public Types | Public Member Functions
NCollection_DynamicArray< TheItemType > Class Template Reference

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

#include <NCollection_DynamicArray.hxx>

Inheritance diagram for NCollection_DynamicArray< TheItemType >:
Inheritance graph
[legend]

Public Types

typedef NCollection_OccAllocator< TheItemTypeallocator_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)
 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.
 
TheItemTypeexpandArray ()
 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

Memory allocation.

◆ const_iterator

◆ const_pointer

◆ const_reference

◆ difference_type

◆ iterator

◆ Iterator

◆ pointer

◆ reference

◆ size_type

◆ value_type

◆ vector

Constructor & Destructor Documentation

◆ NCollection_DynamicArray() [1/5]

Copy constructor.

◆ NCollection_DynamicArray() [2/5]

Copy constructor.

◆ NCollection_DynamicArray() [3/5]

Copy constructor.

◆ NCollection_DynamicArray() [4/5]

Copy constructor.

◆ NCollection_DynamicArray() [5/5]

Copy constructor.

◆ ~NCollection_DynamicArray()

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]

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]

◆ 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()

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

◆ end() [2/2]

◆ 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()

Returns
last element

◆ Length()

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

Total number of items.

◆ Lower()

Method for consistency with other collections.

Returns
Lower bound (inclusive) for iteration.

◆ operator()() [1/2]

Operator() - query the value.

◆ operator()() [2/2]

Operator() - query the const value.

◆ operator=() [1/2]

Assignment operator.

◆ operator=() [2/2]

Assignment operator.

◆ operator[]() [1/4]

Operator[] - query the value.

◆ operator[]() [2/4]

Operator[] - query the const value.

◆ operator[]() [3/4]

Operator[] - query the value.

◆ operator[]() [4/4]

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

Total number of items in the vector.

◆ Upper()

Method for consistency with other collections.

Returns
Upper bound (inclusive) for iteration.

◆ Value()

Copy constructor.

Field Documentation

◆ const_iterator

Copy constructor.

◆ iterator

Copy constructor.

◆ myAlloc

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: