oaArray Class Template Reference

Inheritance diagram for oaArray:

oaArrayBase oaAnalysisPointArray oaAntennaAreaArray oaAssignedNetSpec oaBoxArray oaBuildInfoArray oaByteArray oaComplexArray oaConstraintParamArray oaDerivedLayerParamArray oaDesignArray oaDMAttrArray oaDualIntArray oaFeatureArray oaIntRangeArray oaLayerArray oaLayerHeaderArray oaLayerMapArray oaLayerNameArray oaMfgLayerArray oaModTermArray oaObjectArray oaOccTermArray oaParamArray oaPointArray oaPurposeArray oaRouteObjectArray oaSitePattern oaStringArray oaSubset oaSubset<oaGroupDef *> oaSubset<oaManagedType> oaTechArray oaTechHeaderArray oaTermArray oaValueArray oaViaDefArray oaViaDefNameArray oaViaTopologyArray


Public Methods

 oaArray (oaUInt4 size=0)
 oaArray (const oaArray< T > &arrayIn)
 oaArray (const T arrayIn[], oaUInt4 numElementsIn)
virtual ~oaArray ()
oaUInt4 find (const T &element) const
void append (const T &element)
void append (const oaArray< T > &arrayIn)
void remove (const T &element)
void sort (int(*compare)(const T *, const T *))
oaArray< T > & operator= (const oaArray< T > &arrayIn)
virtual oaBoolean operator== (const oaArray< T > &other) const
oaBoolean operator!= (const oaArray< T > &other) const

Detailed Description

template<class T>
class oaArray< T >

The oaArray class is an abstract class that is the base for many of the array classes used in the OpenAccess API. The oaArray<> template extends the oaArrayBase<> template with some higher-level operations that allow it to function more like a typical container. It supports the basic management facilities for an array of a specified element type. This includes sizing of the array and operators to access and manipulate the data it contains.

Different objects derive an array class that is specific to what they need to manipulate with the array, such as the oaTermArray and oaModTermArray classes. These object specific arrays may add to the basic capabilities provided by the oaArray class.


Constructor & Destructor Documentation

template<class T>
oaArray< T >::oaArray oaUInt4    size = 0 [inline]
 

This is the constructor for the oaArray template class that constructs an array allocated with enough storage to hold the number of elements specified by size.

Parameters:
size Specifies the storage to allocate for size elements

template<class T>
oaArray< T >::oaArray const oaArray< T > &    arrayIn [inline]
 

This is the constructor for the oaArray template class that constructs an array by making a copy of the specified arrayIn.

Parameters:
arrayIn The array to be copied

template<class T>
oaArray< T >::oaArray const T    array[],
oaUInt4    numElementsIn
[inline]
 

This is the constructor for the oaArray template that uses a C-style array[] of T elements to specify the initial contents of the array.

Parameters:
array[] C-style array of T elements
numElementsIn number of elements

template<class T>
oaArray< T >::~oaArray   [inline, virtual]
 

This is the destructor for the oaArray class. It frees the storage associated with this oaArray.


Member Function Documentation

template<class T>
void oaArray< T >::append const oaArray< T > &    arrayIn [inline]
 

This function appends the specified array to the end of this array. This function will increase the size of the array if necessary to fit the specified array contents and will update the number of elements in this array.

Parameters:
arrayIn The array of elements to append to this array

template<class T>
void oaArray< T >::append const T &    element [inline]
 

This function appends the specified element to the end of this array. This function will increase the size of the array if necessary and will increment the number of elements in the array.

Parameters:
element The element to append to this array

template<class T>
oaUInt4 oaArray< T >::find const T &    element const [inline]
 

This function searches this array for the specified element. The position of the element in the array is returned if found. Otherwise, the value oacNullIndex is returned.

Parameters:
element The element to search for in this array

Reimplemented in oaParamArray.

template<class T>
oaBoolean oaArray< T >::operator!= const oaArray< T > &    other const [inline]
 

This is the inequality operator for this array. This function returns a boolean indicating whether this array is not equivalent to the specified array.

Parameters:
other The array containing the contents to be compared

template<class T>
oaArray & oaArray< T >::operator= const oaArray< T > &    arrayIn [inline]
 

This is the assignment operator for this array. It copies the given array into this array, resizing the array if necessary.

Parameters:
arrayIn The array containing the contents to be copied

template<class T>
oaBoolean oaArray< T >::operator== const oaArray< T > &    other const [virtual]
 

This is the equality operator for this array. This function returns a boolean indicating whether this array is equivalent to the specified array.

Parameters:
other The array containing the contents to be compared

Reimplemented in oaParamArray.

template<class T>
void oaArray< T >::remove const T &    element [inline]
 

This function removes the specified element from this array, shifting the remaining elements up to fill in the gap. The number of elements is decremented accordingly.

Parameters:
element The element to remove from this array

template<class T>
void oaArray< T >::sort int(*    compare)(const T *, const T *)
 

This function sorts the elements of the array in-place, using qsort() and a user-supplied comparison function that is called by qsort to compare two successive elements in the array. sort() takes one argument -- a pointer to the user-supplied compare function. Users supply the name of the compare function to sort() to pass this pointer as shown in the sample code, below).

The user-supplied compare routine, which is used by qsort(), should take pointers to two elements in the oaArray<T> of type <T> and, for an ascending sort, return the following values for each compare operation:

Return Value Description
< 0 elem1 less than elem2
0 elem1 equivalent to elem2
> 0 elem1 greater than elem2

Example Sort of Integer Array


// user-supplied compare function

static
int
compareIntsForQsort(const int *elem1, const int *elem2)
{
        return *elem1 - *elem2;
}

// main routine

oaArray<int> intArray(3);
intArray[0] = 1;
intArray[1] = 3;
intArray[2] = 2;
intArray.sort(compareIntsForQsort);

// check for ordered array
assert(intArray[0] == 1);
assert(intArray[1] == 2);
assert(intArray[2] == 3);



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

Return to top of page