INGOR
|
Expandable array. More...
#include <ytDoubleArray.h>
Public Member Functions | |
#define | YTLIB_DOUBLE_ARRAY_DEFAULT_EXPAND_SIZE 16 |
Expandable double Array. | |
ytDoubleArray * | ytDoubleArray_new () |
Creates a new ytDoubleArray instance. | |
void | ytDoubleArray_deleteAll (ytDoubleArray *this) |
Releases the array and all the elements in the array. | |
ytDoubleArray * | ytDoubleArray_clone (const ytDoubleArray *this) |
Returns the clone of this ytDoubleArray instance. | |
ytObject * | ytDoubleArray_cloneI (const ytObject *this) |
Returns the clone of this ytDoubleArray instance. | |
ytDoubleArray * | ytDoubleArray_arrayNew (size_t size) |
Creates the array of ytDoubleArray instances. | |
void | ytDoubleArray_arrayDelete (ytDoubleArray *this, size_t size) |
Deletes the array of ytDoubleArray instances. | |
size_t | ytDoubleArray_buffSize (const ytDoubleArray *this) |
Returns the current buffer size allocated. | |
ytDoubleArray * | ytDoubleArray_setBuffSize (ytDoubleArray *this, size_t new_size) |
Changes the size of buffer. | |
size_t | ytDoubleArray_memSize (const ytDoubleArray *this) |
Returns the size of memory where the specified instance occupies. | |
size_t | ytDoubleArray_arrayMemSize (const ytDoubleArray *this, size_t n) |
Returns the total size of memory used by the array of the array. | |
void | ytDoubleArray_clear (ytDoubleArray *this) |
Removes all the elements in the array. | |
void | ytDoubleArray_add (ytDoubleArray *this, double value) |
Adds a value. | |
void | ytDoubleArray_set (ytDoubleArray *this, size_t index, double value) |
Sets a value at the specified position. | |
void | ytDoubleArray_setSize (ytDoubleArray *this, size_t size) |
Changes the size of the array. | |
void | ytDoubleArray_insert (ytDoubleArray *this, size_t index, double value) |
Inserts a value at the specified position. | |
double | ytDoubleArray_remove (ytDoubleArray *this, size_t index) |
void | ytDoubleArray_copy (ytDoubleArray *this, const ytDoubleArray *src) |
Copies values in another array into this. | |
void | ytDoubleArray_copyArray (ytDoubleArray *this, size_t index, const double *array, size_t size) |
Copies values in an array into this array. | |
double | ytDoubleArray_pop (ytDoubleArray *this) |
Returns the last element. | |
void | ytDoubleArray_sort (ytDoubleArray *this) |
Sorts the elements in ascending order. | |
size_t | ytDoubleArray_find (const ytDoubleArray *this, const double v) |
Returns the index of the value identical to the given one. | |
void | ytDoubleArray_print (const ytDoubleArray *this, FILE *fp, char *delim) |
Prints the elements in the array. | |
void | ytDoubleArray_MPI_Bcast (ytDoubleArray **pObject, int root, MPI_Comm comm) |
Broadcasts the array with MPI. | |
Expandable array.
void ytDoubleArray_add | ( | ytDoubleArray * | this, |
double | value | ||
) |
Adds a value.
this | |
value |
void ytDoubleArray_arrayDelete | ( | ytDoubleArray * | this, |
size_t | size | ||
) |
Deletes the array of ytDoubleArray instances.
This deletes the array of the instances allocated by ytDoubleArray_arrayNew(). The users have to specify the same number to the size parameter as specified to ytDoubleArray_arrayNew().
this | pointer returned by ytDoubleArray_arrayNew(). |
size | the size of the array. |
ytDoubleArray * ytDoubleArray_arrayNew | ( | size_t | size | ) |
Creates the array of ytDoubleArray instances.
The i -th istance can be accecced by p +
i where p
is the pointer returned by this. For example:
Use ytDoubleArray_arrayDelete() to delete the allocated instances.
size | the number of instances to allocate. |
size_t ytDoubleArray_buffSize | ( | const ytDoubleArray * | this | ) |
Returns the current buffer size allocated.
this | pointer to the ytDoubleArray instance. |
void ytDoubleArray_clear | ( | ytDoubleArray * | 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.
void ytDoubleArray_copy | ( | ytDoubleArray * | this, |
const ytDoubleArray * | src | ||
) |
Copies values in another array into this.
this | |
src |
void ytDoubleArray_copyArray | ( | ytDoubleArray * | this, |
size_t | index, | ||
const double * | array, | ||
size_t | size | ||
) |
Copies values in an array into this array.
this | |
index | |
array | |
size |
size_t ytDoubleArray_find | ( | const ytDoubleArray * | this, |
const double | v | ||
) |
Returns the index of the value identical to the given one.
this | |
v | Value to find. |
void ytDoubleArray_insert | ( | ytDoubleArray * | this, |
size_t | index, | ||
double | value | ||
) |
Inserts a value at the specified position.
this | |
index | |
value |
size_t ytDoubleArray_memSize | ( | const ytDoubleArray * | this | ) |
Returns the size of memory where the specified instance occupies.
this | pointer to the ytDoubleArray instance. |
void ytDoubleArray_MPI_Bcast | ( | ytDoubleArray ** | 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 ). |
ytDoubleArray * ytDoubleArray_new | ( | ) |
Creates a new ytDoubleArray instance.
double ytDoubleArray_pop | ( | ytDoubleArray * | this | ) |
Returns the last element.
The last element is returned and removed from the array.
this |
void ytDoubleArray_print | ( | const ytDoubleArray * | this, |
FILE * | fp, | ||
char * | delim | ||
) |
Prints the elements in the array.
this | |
fp | FILE pointer to output. |
delim | delimitor |
double ytDoubleArray_remove | ( | ytDoubleArray * | this, |
size_t | index | ||
) |
\breif Removes the value at the specified position.
void ytDoubleArray_set | ( | ytDoubleArray * | this, |
size_t | index, | ||
double | value | ||
) |
Sets a value at the specified position.
this | |
index | |
value |
ytDoubleArray * ytDoubleArray_setBuffSize | ( | ytDoubleArray * | this, |
size_t | new_size | ||
) |
void ytDoubleArray_setSize | ( | ytDoubleArray * | 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 ytDoubleArray_sort | ( | ytDoubleArray * | this | ) |
Sorts the elements in ascending order.
this |