Open CASCADE Technology  7.2.0
Data Structures | Public Types | Public Member Functions | Protected Attributes
NCollection_Array1< TheItemType > Class Template Reference

#include <NCollection_Array1.hxx>

Data Structures

class  Iterator
 Implementation of the Iterator interface. More...
 

Public Types

typedef TheItemType value_type
 STL-compliant typedef for value type. More...
 
typedef NCollection_StlIterator< std::random_access_iterator_tag, Iterator, TheItemType, false > iterator
 Shorthand for a regular iterator type. More...
 
typedef NCollection_StlIterator< std::random_access_iterator_tag, Iterator, TheItemType, true > const_iterator
 Shorthand for a constant iterator type. More...
 

Public Member Functions

iterator begin () const
 Returns an iterator pointing to the first element in the array. More...
 
iterator end () const
 Returns an iterator referring to the past-the-end element in the array. More...
 
const_iterator cbegin () const
 Returns a const iterator pointing to the first element in the array. More...
 
const_iterator cend () const
 Returns a const iterator referring to the past-the-end element in the array. More...
 
 NCollection_Array1 ()
 Empty constructor; should be used with caution. More...
 
 NCollection_Array1 (const Standard_Integer theLower, const Standard_Integer theUpper)
 Constructor. More...
 
 NCollection_Array1 (const NCollection_Array1 &theOther)
 Copy constructor. More...
 
 NCollection_Array1 (NCollection_Array1 &&theOther)
 Move constructor. More...
 
 NCollection_Array1 (const TheItemType &theBegin, const Standard_Integer theLower, const Standard_Integer theUpper)
 C array-based constructor. More...
 
void Init (const TheItemType &theValue)
 Initialise the items with theValue. More...
 
Standard_Integer Size (void) const
 Size query. More...
 
Standard_Integer Length (void) const
 Length query (the same) More...
 
Standard_Boolean IsEmpty () const
 Return TRUE if array has zero length. More...
 
Standard_Integer Lower (void) const
 Lower bound. More...
 
Standard_Integer Upper (void) const
 Upper bound. More...
 
Standard_Boolean IsDeletable (void) const
 myDeletable flag More...
 
Standard_Boolean IsAllocated (void) const
 IsAllocated flag - for naming compatibility. More...
 
NCollection_Array1Assign (const NCollection_Array1 &theOther)
 Assignment. More...
 
NCollection_Array1Move (NCollection_Array1 &&theOther)
 Move assignment. More...
 
NCollection_Array1operator= (const NCollection_Array1 &theOther)
 Assignment operator. More...
 
NCollection_Array1operator= (NCollection_Array1 &&theOther)
 Move assignment operator. More...
 
const TheItemType & First () const
 
TheItemType & ChangeFirst ()
 
const TheItemType & Last () const
 
TheItemType & ChangeLast ()
 
const TheItemType & Value (const Standard_Integer theIndex) const
 Constant value access. More...
 
const TheItemType & operator() (const Standard_Integer theIndex) const
 operator() - alias to Value More...
 
TheItemType & ChangeValue (const Standard_Integer theIndex)
 Variable value access. More...
 
TheItemType & operator() (const Standard_Integer theIndex)
 operator() - alias to ChangeValue More...
 
void SetValue (const Standard_Integer theIndex, const TheItemType &theItem)
 Set value. More...
 
void Resize (const Standard_Integer theLower, const Standard_Integer theUpper, const Standard_Boolean theToCopyData)
 Resizes the array to specified bounds. No re-allocation will be done if length of array does not change, but existing values will not be discarded if theToCopyData set to FALSE. More...
 
 ~NCollection_Array1 (void)
 Destructor - releases the memory. More...
 

Protected Attributes

Standard_Integer myLowerBound
 
Standard_Integer myUpperBound
 
Standard_Boolean myDeletable
 Flag showing who allocated the array. More...
 
TheItemType * myData
 Pointer to '0'th array item. More...
 

Detailed Description

template<class TheItemType>
class NCollection_Array1< TheItemType >

Purpose: The class Array1 represents unidimensional arrays of fixed size known at run time. The range of the index is user defined. An array1 can be constructed with a "C array". This functionality is useful to call methods expecting an Array1. It allows to carry the bounds inside the arrays.

Examples: Item tab[100]; // An example with a C array Array1OfItem ttab (tab[0],1,100);

Array1OfItem tttab (ttab(10),10,20); // a slice of ttab

If you want to reindex an array from 1 to Length do :

Array1 tab1(tab(tab.Lower()),1,tab.Length());

Warning: Programs client of such a class must be independant of the range of the first element. Then, a C++ for loop must be written like this

for (i = A.Lower(); i <= A.Upper(); i++)

Changes: In comparison to TCollection the flag isAllocated was renamed into myDeletable (alike in the Array2). For naming compatibility the method IsAllocated remained in class along with IsDeletable.

Member Typedef Documentation

◆ const_iterator

template<class TheItemType>
typedef NCollection_StlIterator<std::random_access_iterator_tag, Iterator, TheItemType, true> NCollection_Array1< TheItemType >::const_iterator

Shorthand for a constant iterator type.

◆ iterator

template<class TheItemType>
typedef NCollection_StlIterator<std::random_access_iterator_tag, Iterator, TheItemType, false> NCollection_Array1< TheItemType >::iterator

Shorthand for a regular iterator type.

◆ value_type

template<class TheItemType>
typedef TheItemType NCollection_Array1< TheItemType >::value_type

STL-compliant typedef for value type.

Constructor & Destructor Documentation

◆ NCollection_Array1() [1/5]

template<class TheItemType>
NCollection_Array1< TheItemType >::NCollection_Array1 ( )
inline

Empty constructor; should be used with caution.

◆ NCollection_Array1() [2/5]

template<class TheItemType>
NCollection_Array1< TheItemType >::NCollection_Array1 ( const Standard_Integer  theLower,
const Standard_Integer  theUpper 
)
inline

Constructor.

◆ NCollection_Array1() [3/5]

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

Copy constructor.

◆ NCollection_Array1() [4/5]

template<class TheItemType>
NCollection_Array1< TheItemType >::NCollection_Array1 ( NCollection_Array1< TheItemType > &&  theOther)
inline

Move constructor.

◆ NCollection_Array1() [5/5]

template<class TheItemType>
NCollection_Array1< TheItemType >::NCollection_Array1 ( const TheItemType &  theBegin,
const Standard_Integer  theLower,
const Standard_Integer  theUpper 
)
inline

C array-based constructor.

◆ ~NCollection_Array1()

template<class TheItemType>
NCollection_Array1< TheItemType >::~NCollection_Array1 ( void  )
inline

Destructor - releases the memory.

Member Function Documentation

◆ Assign()

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

Assignment.

◆ begin()

template<class TheItemType>
iterator NCollection_Array1< TheItemType >::begin ( ) const
inline

Returns an iterator pointing to the first element in the array.

◆ cbegin()

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

Returns a const iterator pointing to the first element in the array.

◆ cend()

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

Returns a const iterator referring to the past-the-end element in the array.

◆ ChangeFirst()

template<class TheItemType>
TheItemType& NCollection_Array1< TheItemType >::ChangeFirst ( )
inline
Returns
first element

◆ ChangeLast()

template<class TheItemType>
TheItemType& NCollection_Array1< TheItemType >::ChangeLast ( )
inline
Returns
last element

◆ ChangeValue()

template<class TheItemType>
TheItemType& NCollection_Array1< TheItemType >::ChangeValue ( const Standard_Integer  theIndex)
inline

Variable value access.

◆ end()

template<class TheItemType>
iterator NCollection_Array1< TheItemType >::end ( ) const
inline

Returns an iterator referring to the past-the-end element in the array.

◆ First()

template<class TheItemType>
const TheItemType& NCollection_Array1< TheItemType >::First ( ) const
inline
Returns
first element

◆ Init()

template<class TheItemType>
void NCollection_Array1< TheItemType >::Init ( const TheItemType &  theValue)
inline

Initialise the items with theValue.

◆ IsAllocated()

template<class TheItemType>
Standard_Boolean NCollection_Array1< TheItemType >::IsAllocated ( void  ) const
inline

IsAllocated flag - for naming compatibility.

◆ IsDeletable()

template<class TheItemType>
Standard_Boolean NCollection_Array1< TheItemType >::IsDeletable ( void  ) const
inline

myDeletable flag

◆ IsEmpty()

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

Return TRUE if array has zero length.

◆ Last()

template<class TheItemType>
const TheItemType& NCollection_Array1< TheItemType >::Last ( ) const
inline
Returns
last element

◆ Length()

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

Length query (the same)

◆ Lower()

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

Lower bound.

◆ Move()

template<class TheItemType>
NCollection_Array1& NCollection_Array1< TheItemType >::Move ( NCollection_Array1< TheItemType > &&  theOther)
inline

Move assignment.

◆ operator()() [1/2]

template<class TheItemType>
const TheItemType& NCollection_Array1< TheItemType >::operator() ( const Standard_Integer  theIndex) const
inline

operator() - alias to Value

◆ operator()() [2/2]

template<class TheItemType>
TheItemType& NCollection_Array1< TheItemType >::operator() ( const Standard_Integer  theIndex)
inline

operator() - alias to ChangeValue

◆ operator=() [1/2]

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

Assignment operator.

◆ operator=() [2/2]

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

Move assignment operator.

◆ Resize()

template<class TheItemType>
void NCollection_Array1< TheItemType >::Resize ( const Standard_Integer  theLower,
const Standard_Integer  theUpper,
const Standard_Boolean  theToCopyData 
)
inline

Resizes the array to specified bounds. No re-allocation will be done if length of array does not change, but existing values will not be discarded if theToCopyData set to FALSE.

Parameters
theLowernew lower bound of array
theUppernew upper bound of array
theToCopyDataflag to copy existing data into new array

◆ SetValue()

template<class TheItemType>
void NCollection_Array1< TheItemType >::SetValue ( const Standard_Integer  theIndex,
const TheItemType &  theItem 
)
inline

Set value.

◆ Size()

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

Size query.

◆ Upper()

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

Upper bound.

◆ Value()

template<class TheItemType>
const TheItemType& NCollection_Array1< TheItemType >::Value ( const Standard_Integer  theIndex) const
inline

Constant value access.

Field Documentation

◆ myData

template<class TheItemType>
TheItemType* NCollection_Array1< TheItemType >::myData
protected

Pointer to '0'th array item.

◆ myDeletable

template<class TheItemType>
Standard_Boolean NCollection_Array1< TheItemType >::myDeletable
protected

Flag showing who allocated the array.

◆ myLowerBound

template<class TheItemType>
Standard_Integer NCollection_Array1< TheItemType >::myLowerBound
protected

◆ myUpperBound

template<class TheItemType>
Standard_Integer NCollection_Array1< TheItemType >::myUpperBound
protected

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