INGOR
|
Expandable array. More...
#include <ytArray.h>
Public Member Functions | |
#define | YTLIB__ARRAY_DEFAULT_EXPAND_SIZE 16 |
Expandable ytObject * Array. | |
ytArray * | ytArray_new () |
Creates a new ytArray instance. | |
void | ytArray_deleteAll (ytArray *this) |
Releases the array and all the elements in the array. | |
ytArray * | ytArray_clone (const ytArray *this) |
Returns the clone of this ytArray instance. | |
ytObject * | ytArray_cloneI (const ytObject *this) |
Returns the clone of this ytArray instance. | |
ytArray * | ytArray_arrayNew (size_t size) |
Creates the array of ytArray instances. | |
void | ytArray_arrayDelete (ytArray *this, size_t size) |
Deletes the array of ytArray instances. | |
size_t | ytArray_buffSize (const ytArray *this) |
Returns the current buffer size allocated. | |
ytArray * | ytArray_setBuffSize (ytArray *this, size_t new_size) |
Changes the size of buffer. | |
size_t | ytArray_memSize (const ytArray *this) |
Returns the size of memory where the specified instance occupies. | |
size_t | ytArray_arrayMemSize (const ytArray *this, size_t n) |
Returns the total size of memory used by the array of the array. | |
void | ytArray_clear (ytArray *this) |
Removes all the elements in the array. | |
void | ytArray_add (ytArray *this, ytObject *value) |
Adds a value. | |
void | ytArray_set (ytArray *this, size_t index, ytObject *value) |
Sets a value at the specified position. | |
void | ytArray_setSize (ytArray *this, size_t size) |
Changes the size of the array. | |
void | ytArray_insert (ytArray *this, size_t index, ytObject *value) |
Inserts a value at the specified position. | |
ytObject * | ytArray_remove (ytArray *this, size_t index) |
void | ytArray_copy (ytArray *this, const ytArray *src) |
Copies values in another array into this. | |
void | ytArray_copyArray (ytArray *this, size_t index, const ytObject **array, size_t size) |
Copies values in an array into this array. | |
ytObject * | ytArray_pop (ytArray *this) |
Returns the last element. | |
void | ytArray_sort (ytArray *this) |
Sorts the elements in ascending order. | |
size_t | ytArray_find (const ytArray *this, const ytObject *v) |
Returns the index of the value identical to the given one. | |
void | ytArray_print (const ytArray *this, FILE *fp, char *delim) |
Prints the elements in the array. | |
void | ytArray_MPI_Bcast (ytArray **pObject, int root, MPI_Comm comm) |
Broadcasts the array with MPI. | |
Expandable array.
void ytArray_arrayDelete | ( | ytArray * | this, |
size_t | size | ||
) |
Deletes the array of ytArray instances.
This deletes the array of the instances allocated by ytArray_arrayNew(). The users have to specify the same number to the size parameter as specified to ytArray_arrayNew().
this | pointer returned by ytArray_arrayNew(). |
size | the size of the array. |
ytArray * ytArray_arrayNew | ( | size_t | size | ) |
Creates the array of ytArray instances.
The i -th istance can be accecced by p +
i where p
is the pointer returned by this. For example:
Use ytArray_arrayDelete() to delete the allocated instances.
size | the number of instances to allocate. |
size_t ytArray_buffSize | ( | const ytArray * | this | ) |
Returns the current buffer size allocated.
this | pointer to the ytArray instance. |
void ytArray_clear | ( | ytArray * | this | ) |
Removes all the elements in the array.
This does not remove the element but set the number of elements in the array to be zero. No memory de-allocation occurs.
Copies values in another array into this.
this | |
src |
Copies values in an array into this array.
this | |
index | |
array | |
size |
Returns the index of the value identical to the given one.
this | |
v | Value to find. |
Inserts a value at the specified position.
this | |
index | |
value |
size_t ytArray_memSize | ( | const ytArray * | this | ) |
Returns the size of memory where the specified instance occupies.
this | pointer to the ytArray instance. |
void ytArray_MPI_Bcast | ( | ytArray ** | pObject, |
int | root, | ||
MPI_Comm | comm | ||
) |
Broadcasts the array with MPI.
This is available only for the MPI-enabled ytLib.
This allocates working memory whose size is the same as the total memory required for storing all the elements in the array.
This calls MPI_Ibcast() three times internally.
pObject | pointer to the array instance. in receiving ranks, the new instance is generated and set to the original pointer (*pObject ). |
ytArray * ytArray_new | ( | ) |
Returns the last element.
The last element is returned and removed from the array.
this |
void ytArray_print | ( | const ytArray * | this, |
FILE * | fp, | ||
char * | delim | ||
) |
Prints the elements in the array.
this | |
fp | FILE pointer to output. |
delim | delimitor |
\breif Removes the value at the specified position.
Sets a value at the specified position.
this | |
index | |
value |
void ytArray_setSize | ( | ytArray * | this, |
size_t | size | ||
) |
Changes the size of the array.
If the specified size is larger than the current size, new elements are not initialized.
If the specified size is less than the current size, this does not free the allocated memory. Instead, this simply changes the current size without changing any elements in the array.
this | |
size | =================================================== |
void ytArray_sort | ( | ytArray * | this | ) |
Sorts the elements in ascending order.
this |