LibCapy - array

Generic array class.

Macros:

Iterator for generic array structure. Declaration macro for an iterator structure named 'name' ## Iterator, associated to an array named 'name' containing elements of type 'type'

Create an iterator on a generic array

Input argument(s):

arr: the generic array on which to iterate
type: the type of iterator

Output and side effect(s):

Return the iterator

Allocate memory and create an iterator on a generic array

Input argument(s):

arr: the generic array on which to iterate
type: the type of iterator

Output and side effect(s):

Return the iterator

Free the memory used by an iterator.

Input argument(s):

that: the iterator to free

Free the memory used by a pointer to an iterator and reset '*that' to NULL

Input argument(s):

that: a pointer to the iterator to free

Reset the iterator

Output and side effect(s):

Return the first element of the iteration

Move the iterator to the previous element

Output and side effect(s):

Return the previous element of the iteration

Move the iterator to the next element

Output and side effect(s):

Return the next element of the iteration

Move the iterator to the last element

Check if the iterator is on a valid element

Output and side effect(s):

Return true if the iterator is on a valid element, else false

Get the current element of the iteration

Output and side effect(s):

Return a pointer to the current element

Set the type of the iterator and reset it

Input argument(s):

type: the new type of the iterator

Definition macro calling all the submacros at once for an iterator on an array structure named 'name', containing elements of type 'type'

Fixed size generic array structure. Declaration macro for an array structure named 'name', containing 'size_' elements of type 'type'

Fixed size generic array structure. Definition macro and submacros for an array structure named 'name', containing 'size_' elements of type 'type' Create an array

Output and side effect(s):

Return an array containing 'size_' elements of type 'type'

Allocate memory for a new array and create it

Output and side effect(s):

Return an array containing 'size_' elements of type 'type'

Exception(s):

May raise CapyExc_MallocFailed.

Clone an array

Output and side effect(s):

Return a clone of the array

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by an array.

Input argument(s):

that: the array to free

Free the memory used by a pointer to an array and reset '*that' to NULL

Input argument(s):

that: a pointer to the array to free

Get the size of the array

Output and side effect(s):

Return the size

Set an element of the array

Input argument(s):

idx: the index of the element to set
val: the value to set

Get an element of the array

Input argument(s):

idx: the index of the element to get

Output and side effect(s):

Return the element value

Get a pointer to an element of the array

Input argument(s):

idx: the index of the element to get

Output and side effect(s):

Return the pointer to the element

Initialise the iterator of the array, must be called after the creation of the array when it is created with Create(), Alloc() automatically initialise the iterator.

Shuffle the array given a pseudo-random number generator. Fisher-Yates algorithm.

Shuffle the array given a pseudo-random number generator. Fisher-Yates and Lemire algorithm. The size of the array must be less than 2^32. Faster than Shuffle.

Sort the array using the qsort function given a comparator.

Return the minimum element given a comparator

Return the maximum element given a comparator

Return the index of the value, searched using binary search, or raise CapyExc_InvalidElemIdx if the value is not found

Definition macro calling all the submacros at once for an array structure named 'name', containing 'size_' elements of type 'type'

---------------------------------------------------------------------------- Resizable generic array structure. Declaration macro for an array structure named 'name', containing elements of type 'type'

Resizable generic array structure. Definition macro and submacros for an array structure named 'name', containing elements of type 'type' Create an array

Input argument(s):

size: the new size of the array, may be zero

Output and side effect(s):

Return an array containing elements of type 'type'

Exception(s):

May raise CapyExc_MallocFailed.

Allocate memory for a new array and create it

Input argument(s):

size: the new size of the array, may be zero

Output and side effect(s):

Return an array containing elements of type 'type'

Exception(s):

May raise CapyExc_MallocFailed.

Clone an array

Output and side effect(s):

Return a clone of the array

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by an array.

Input argument(s):

that: the array to free

Free the memory used by a pointer to an array and reset '*that' to NULL

Input argument(s):

that: a pointer to the array to free

Get the size of the array

Output and side effect(s):

Return the size

Set an element of the array

Input argument(s):

idx: the index of the element to set
val: the value to set

Get an element of the array

Input argument(s):

idx: the index of the element to get

Output and side effect(s):

Return the element value

Get a pointer to an element of the array

Input argument(s):

idx: the index of the element to get

Output and side effect(s):

Return the pointer to the element

Resize the array. If the new size of the array is bigger than the current size, new element are not initialised. If the new size of the array is smaller than the old size, elements after the new size are lost.

Input argument(s):

size: the new size of the array, may be zero, in number of element

Exception(s):

May raise CapyExc_MallocFailed.

Initialise the iterator of the array, must be called after the creation of the array when it is created with Create(), Alloc() automatically initialise the iterator.

Shuffle the array given a pseudo-random number generator. Fisher-Yates algorithm.

Shuffle the array given a pseudo-random number generator. Fisher-Yates and Lemire algorithm. The array must be less than 2^32 in size. Faster than shuffle.

Sort the array using the qsort function given a comparator.

Return the minimum element given a comparator

Return the maximum element given a comparator

Return the index of the value, searched using binary search, or raise CapyExc_InvalidElemIdx if the value is not found

Definition macro calling all the submacros at once for an array structure named 'name', containing elements of type 'type'

Enumerations:

Enumeration for the types of iterator on generic array

Typedefs:

Predeclaration of the Random class used by the shuffle method (can't include due to loop dependency with DistributionDiscrete)

Functions:

None.

2021-11-06
in LibCapy,
85 views
Copyright 2021-2024 Baillehache Pascal