HermesCommon
2.0
|
A generic, inflatable array. More...
#include <array.h>
Public Member Functions | |
Array (Array &array) | |
void | copy (const Array &array) |
Makes this array to hold a copy of another one. | |
void | free () |
Removes all elements from the array. | |
void | set_append_only (bool append_only) |
int | add (TYPE item) |
Wrapper function for Hermes::vector::add() for compatibility purposes. | |
TYPE * | add () |
void | remove (int id) |
int | first (int idx=0) |
int | next (int idx=0) |
int | last (int idx=INT_MAX) |
int | prev (int idx=INT_MAX) |
bool | exists (int idx) |
Checks whether an element exists at position idx. | |
void | force_size (int size) |
void | post_load_scan (int start=0) |
void | skip_slot () |
int | get_size () const |
int | get_num_items () const |
TYPE & | get (int id) const |
TYPE & | operator[] (int id) const |
Protected Attributes | |
Hermes::vector< TYPE * > | pages |
Hermes::vector< int > | unused |
int | size |
int | nitems |
bool | append_only |
Static Protected Attributes | |
static const int | HERMES_PAGE_BITS = 10 |
static const int | HERMES_PAGE_SIZE = 1 << HERMES_PAGE_BITS |
static const int | HERMES_PAGE_MASK = HERMES_PAGE_SIZE-1 |
A generic, inflatable array.
This class is a generic dynamic array for storing nodes and elements of a mesh. All items contained in the array are assigned a unique id number. Internally, a list of unused items is maintained. Unused items (and their id numbers) are reused when new items are added to the array. The type 'TYPE' must contain the members 'id' and 'unused' in order to be usable by this class.
|
inline |
Adds a new item to the array: either it is appended at the end or an unused item is reused.
Definition at line 114 of file array.h.
Referenced by Hermes::Hermes2D::Array< TYPE >::add().
|
inline |
Get the first index that is present and is equal to or greater than the passed idx
. Typically used to begin an iteration over all indices present in the array.
[in] | idx | Optional, default value 0 (finds the first present index). |
idx
(if found), INVALID_IDX
(if not found).
|
inline |
|
inline |
Get the last index present in the array that is equal to or less than the passed idx
. Typically used to begin a reverse iteration over all indices present in the array.
[in] | idx | Optional, default value (Word_t) -1 (finds the last index present in the array). |
idx
(if found), INVALID_IDX
(if not found).
|
inline |
Get the first index that is present and is greater than the passed idx
. Typically used to continue an iteration over all indices present in the array.
[in] | idx | Index whose succesor we want to find. Optional, default value 0 . |
idx
(if found), INVALID_IDX
(if not found).
|
inline |
|
inline |
Get the last index present in the array that is less than the passed idx
. Typically used to continue a reverse iteration over all indices present in the array.
[in] | idx | Index whose predecessor we want to find. Optional, default value (Word_t) -1 . |
idx
(if found), INVALID_IDX
(if not found).
|
inline |
|
inline |
Sets or resets the append-only mode. In append-only mode new elements are only added to the end of the array. This can be useful eg. when refining all elements of a mesh in which case the newly added elements must not be processed again by the for-loop. Normally this option should be off.
|
inline |
|
protected |
Definition at line 43 of file array.h.
Referenced by Hermes::Hermes2D::Array< TYPE >::add(), Hermes::Hermes2D::Array< TYPE >::copy(), Hermes::Hermes2D::Array< TYPE >::force_size(), Hermes::Hermes2D::Array< TYPE >::free(), Hermes::Hermes2D::Array< TYPE >::remove(), and Hermes::Hermes2D::Array< TYPE >::skip_slot().