AVIR
High-quality pro image resizing library
 
Loading...
Searching...
No Matches
avir::CStructArray< T > Class Template Reference

Array of structured objects. More...

#include <avir.h>

Public Member Functions

 CStructArray (const CStructArray &Source)
 Copies the specified array element-by-element.
 
T & add ()
 Creates a new object of type T with the default constructor, and adds this object to the array.
 
void clear ()
 Erases all items of this array.
 
int getItemCount () const
 Returns the number of allocated items.
 
CStructArrayoperator= (const CStructArray &Source)
 Copies the specified array element-by-element.
 
T & operator[] (const int Index)
 Returns writable reference to the specified element.
 
const T & operator[] (const int Index) const
 Returns const reference to the specified element.
 
void setItemCount (const int NewCount)
 Changes the number of allocated items.
 

Detailed Description

template<class T>
class avir::CStructArray< T >

Array of structured objects.

Implements allocation of a linear array of objects of class T (which are initialized), addressable via operator[]. Each object is created via the operator new. New object insertions are quick since implementation uses prior space allocation (capacity), thus not requiring frequent memory block reallocations.

Template Parameters
TArray element's type.

Constructor & Destructor Documentation

◆ CStructArray()

template<class T>
avir::CStructArray< T >::CStructArray ( const CStructArray< T > & Source)

Copies the specified array element-by-element.

Parameters
SourceSource array.

Member Function Documentation

◆ add()

template<class T>
T & avir::CStructArray< T >::add ( )

Creates a new object of type T with the default constructor, and adds this object to the array.

Returns
Reference to a newly added object.

◆ operator=()

template<class T>
CStructArray & avir::CStructArray< T >::operator= ( const CStructArray< T > & Source)

Copies the specified array element-by-element.

Parameters
SourceSource array.
Returns
Reference to this object after the copy operation.

◆ operator[]() [1/2]

template<class T>
T & avir::CStructArray< T >::operator[] ( const int Index)

Returns writable reference to the specified element.

Parameters
IndexElement's index.

◆ operator[]() [2/2]

template<class T>
const T & avir::CStructArray< T >::operator[] ( const int Index) const

Returns const reference to the specified element.

Parameters
IndexElement's index.

◆ setItemCount()

template<class T>
void avir::CStructArray< T >::setItemCount ( const int NewCount)

Changes the number of allocated items.

New items are created with the default constructor. If NewCount is below the current item count, items that are above NewCount range will be destructed.

Parameters
NewCountNew requested item count.