OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::AList< T > Class Template Reference

Class implementing generic list (or more precisely array). More...

#include <alist.h>

Public Member Functions

 AList (int s=0, int sizeIncrement=0)
 Creates list of size s. More...
 
 ~AList ()
 Destructor. More...
 
T * at (int i) const
 
void growTo (int newSize)
 Expands the receiver from its current size to newSize, in order to accommodate new entries. More...
 
void resize (int newSize)
 Resize the receiver from its current size to newSize, in order to accommodate new entries. More...
 
bool includes (int i) const
 Checks if receiver includes object as given position. More...
 
int giveSize () const
 
int isEmpty () const
 
int isNotEmpty () const
 
void printYourself () const
 Prints the receiver on screen. More...
 
void put (int i, T *anObject)
 Stores anObject at position i. More...
 
void clear (bool deleteObjectFlag=true)
 Clears receiver. More...
 
void remove (int i)
 Deletes the object at i-th position. More...
 
T * unlink (int i)
 Unlinks the object a i-th position. More...
 

Protected Attributes

int size
 Array or list size (number of components to store). More...
 
int allocatedSize
 Real allocated size (may be larger than size, to prevent often reallocation). More...
 
int sizeIncrement
 List size allocation increment. More...
 
T ** values
 Array of pointers to particular components. More...
 

Detailed Description

template<class T>
class oofem::AList< T >

Class implementing generic list (or more precisely array).

It maintains the array of generic pointers to objects of type T using 1-based numbering.

This class maintains only the links (pointers) to particular objects, objects themselves are not contained within this array. They have to be created outside (in memory, usually on heap) and then their pointers can be added to array. This is sometimes called non-intrusive approach. When destructor is called, the linked objects are deleted. To prevent the deletion, objects should be unlinked before deconstructor is called.

The links to particular objects in array are stored in pointer array, therefore the access to particular component is very efficient. On the other hand, the resizing of array is relative time expensive (the whole existing pointer table must be transferred) and is recommended to set size of the array to the final size.

Definition at line 57 of file alist.h.

Constructor & Destructor Documentation

template<class T >
oofem::AList< T >::AList ( int  s = 0,
int  sizeIncrement = 0 
)

Creates list of size s.

Parameters
sInitial size.
sizeIncrementIncreases array in blocks of this size when necessary.

Definition at line 136 of file alist.h.

References oofem::AList< T >::allocatedSize, oofem::AList< T >::size, oofem::AList< T >::sizeIncrement, and oofem::AList< T >::values.

template<class T >
oofem::AList< T >::~AList ( )

Destructor.

Definition at line 159 of file alist.h.

References oofem::AList< T >::clear().

Member Function Documentation

template<class T >
T * oofem::AList< T >::at ( int  i) const
inline
Parameters
iIndex of object.
Returns
Object at given index.

Definition at line 270 of file alist.h.

References OOFEM_ERROR, and oofem::AList< T >::values.

template<class T >
void oofem::AList< T >::clear ( bool  deleteObjectFlag = true)

Clears receiver.

Objects are deleted if depending on the delete flag.

Parameters
deleteObjectFlagShows if objects should be deleted.

Definition at line 165 of file alist.h.

References oofem::AList< T >::allocatedSize, oofem::AList< T >::size, and oofem::AList< T >::values.

Referenced by oofem::AList< T >::isNotEmpty(), and oofem::AList< T >::~AList().

template<class T >
int oofem::AList< T >::giveSize ( ) const
inline
Returns
Size of array.

Definition at line 103 of file alist.h.

References oofem::AList< T >::size.

template<class T >
void oofem::AList< T >::growTo ( int  newSize)

Expands the receiver from its current size to newSize, in order to accommodate new entries.

Parameters
newSizeSize that receiver must fit.

Definition at line 184 of file alist.h.

References oofem::AList< T >::allocatedSize, OOFEM_ERROR, oofem::AList< T >::size, oofem::AList< T >::sizeIncrement, and oofem::AList< T >::values.

Referenced by oofem::AList< T >::put().

template<class T >
bool oofem::AList< T >::includes ( int  i) const

Checks if receiver includes object as given position.

Parameters
iIndex of object.
Returns
true if object is non-null at i-th entry, otherwise false.

Definition at line 281 of file alist.h.

References OOFEM_ERROR, oofem::AList< T >::size, and oofem::AList< T >::values.

template<class T >
int oofem::AList< T >::isEmpty ( ) const
inline
Returns
True if receiver is empty, otherwise false.

Definition at line 105 of file alist.h.

template<class T >
int oofem::AList< T >::isNotEmpty ( ) const
inline
Returns
True if receiver is not empty, otherwise false.

Definition at line 107 of file alist.h.

References oofem::AList< T >::clear(), oofem::AList< T >::printYourself(), oofem::AList< T >::put(), and oofem::AList< T >::unlink().

template<class T >
void oofem::AList< T >::printYourself ( ) const

Prints the receiver on screen.

Definition at line 298 of file alist.h.

References oofem::AList< T >::size, and oofem::AList< T >::values.

Referenced by oofem::AList< T >::isNotEmpty().

template<class T >
void oofem::AList< T >::put ( int  i,
T *  anObject 
)

Stores anObject at position i.

Enlarges the receiver if too small and deletes the old value if it exists.

Parameters
iIndex to put object
anObjectObject to put as position i.

Definition at line 307 of file alist.h.

References oofem::AList< T >::growTo(), OOFEM_ERROR, oofem::AList< T >::size, and oofem::AList< T >::values.

Referenced by oofem::AList< T >::isNotEmpty().

template<class T >
void oofem::AList< T >::remove ( int  i)

Deletes the object at i-th position.

Definition at line 327 of file alist.h.

References OOFEM_ERROR, oofem::AList< T >::size, and oofem::AList< T >::values.

template<class T >
void oofem::AList< T >::resize ( int  newSize)

Resize the receiver from its current size to newSize, in order to accommodate new entries.

If existing size is larger than new size, existing elements at postions exceeding newSize will be deleted.

Parameters
newSizeSize that receiver must fit.

Definition at line 228 of file alist.h.

References oofem::AList< T >::allocatedSize, oofem::AList< T >::size, oofem::AList< T >::sizeIncrement, and oofem::AList< T >::values.

template<class T >
T * oofem::AList< T >::unlink ( int  i)

Unlinks the object a i-th position.

The object is returned, and its entry is unlinked, so there will be no further reference to this object. Does not delete the object, its pointer is returned.

Parameters
iIndex where to unlink.
Returns
Object at index i.

Definition at line 346 of file alist.h.

References OOFEM_ERROR, oofem::AList< T >::size, and oofem::AList< T >::values.

Referenced by oofem::AList< T >::isNotEmpty().

Member Data Documentation

template<class T >
int oofem::AList< T >::allocatedSize
protected

Real allocated size (may be larger than size, to prevent often reallocation).

Definition at line 63 of file alist.h.

Referenced by oofem::AList< T >::AList(), oofem::AList< T >::clear(), oofem::AList< T >::growTo(), and oofem::AList< T >::resize().

template<class T >
int oofem::AList< T >::sizeIncrement
protected

List size allocation increment.

Definition at line 65 of file alist.h.

Referenced by oofem::AList< T >::AList(), oofem::AList< T >::growTo(), and oofem::AList< T >::resize().


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

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:33 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011