OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
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... | |
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.
oofem::AList< T >::AList | ( | int | s = 0 , |
int | sizeIncrement = 0 |
||
) |
Creates list of size s.
s | Initial size. |
sizeIncrement | Increases 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.
oofem::AList< T >::~AList | ( | ) |
|
inline |
i | Index of object. |
Definition at line 270 of file alist.h.
References OOFEM_ERROR, and oofem::AList< T >::values.
void oofem::AList< T >::clear | ( | bool | deleteObjectFlag = true | ) |
Clears receiver.
Objects are deleted if depending on the delete flag.
deleteObjectFlag | Shows 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().
|
inline |
void oofem::AList< T >::growTo | ( | int | newSize | ) |
Expands the receiver from its current size to newSize, in order to accommodate new entries.
newSize | Size 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().
bool oofem::AList< T >::includes | ( | int | i | ) | const |
Checks if receiver includes object as given position.
i | Index of object. |
Definition at line 281 of file alist.h.
References OOFEM_ERROR, oofem::AList< T >::size, and oofem::AList< T >::values.
|
inline |
|
inline |
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().
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().
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.
i | Index to put object |
anObject | Object 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().
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.
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.
newSize | Size 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.
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.
i | Index where to unlink. |
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().
|
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().
|
protected |
Array or list size (number of components to store).
Definition at line 61 of file alist.h.
Referenced by oofem::AList< T >::AList(), oofem::AList< T >::clear(), oofem::AList< T >::giveSize(), oofem::AList< T >::growTo(), oofem::AList< T >::includes(), oofem::AList< T >::printYourself(), oofem::AList< T >::put(), oofem::AList< T >::remove(), oofem::AList< T >::resize(), and oofem::AList< T >::unlink().
|
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().
|
protected |
Array of pointers to particular components.
Definition at line 67 of file alist.h.
Referenced by oofem::AList< T >::AList(), oofem::AList< T >::at(), oofem::AList< T >::clear(), oofem::AList< T >::growTo(), oofem::AList< T >::includes(), oofem::AList< T >::printYourself(), oofem::AList< T >::put(), oofem::AList< T >::remove(), oofem::AList< T >::resize(), and oofem::AList< T >::unlink().