40 #ifndef GEOGRAM_BASIC_PACKED_ARRAYS
41 #define GEOGRAM_BASIC_PACKED_ARRAYS
130 bool static_mode =
false
161 return Z1_[array_index * Z1_stride_];
181 lock_array(array_index);
183 array.resize(array_size(array_index));
184 if(array.
size() != 0) {
185 get_array(array_index, &array[0],
false);
188 unlock_array(array_index);
261 if(array.
size() == 0) {
262 set_array(array_index, 0,
nullptr, lock);
265 array_index,
index_t(array.
size()), &array[0], lock
303 Z1_spinlocks_.acquire_spinlock(array_index);
316 Z1_spinlocks_.release_spinlock(array_index);
335 return ZV_ ==
nullptr;
Assertion checking mechanism.
#define geo_debug_assert(x)
Verifies that a condition is met.
Efficient storage for array of arrays.
index_t array_size(index_t array_index) const
Gets the size of a sub-array.
void get_array(index_t array_index, vector< index_t > &array, bool lock=true) const
Gets a sub-array as a vector.
void show_stats()
Displays array statistics.
void set_array(index_t array_index, const vector< index_t > &array, bool lock=true)
Sets a sub-array from a vector.
void get_array(index_t array_index, index_t *array, bool lock=true) const
Gets a sub-array.
void lock_array(index_t array_index) const
Locks a sub-array.
void clear()
Clears the packed array.
void init(index_t nb_arrays, index_t Z1_block_size, bool static_mode=false)
Initializes a packed array.
PackedArrays()
Creates a new empty packed array.
void unlock_array(index_t array_index) const
Unlocks a sub-array.
void set_thread_safe(bool flag)
Sets the thread-safety mode.
void resize_array(index_t array_index, index_t array_size, bool lock)
Resizes a sub-array.
index_t nb_arrays() const
Get the number of arrays.
bool static_mode() const
Checks if the array is in static mode.
~PackedArrays()
Deletes a packed array.
bool thread_safe() const
Checks the thread-safety mode.
void set_array(index_t array_index, index_t array_size, const index_t *array_elements, bool lock=true)
Sets a sub-array.
An array of light-weight synchronisation primitives (spinlocks).
index_t size() const
Gets the number of elements.
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Types and functions for numbers manipulation.
Function and classes for process manipulation.