Expandable array. More...
#include <ytStrArray.h>
Public Member Functions | |
ytStrArray * | ytStrArray_new () |
Creates a new ytStrArray instance. | |
void | ytStrArray_deleteAll (ytStrArray *this) |
Releases the array and all the elements in the array. | |
ytStrArray * | ytStrArray_clone (const ytStrArray *this) |
Returns the clone of this ytStrArray instance. | |
ytObject * | ytStrArray_cloneI (const ytObject *this) |
Returns the clone of this ytStrArray instance. | |
ytStrArray * | ytStrArray_arrayNew (size_t size) |
Creates the array of ytStrArray instances. | |
void | ytStrArray_arrayDelete (ytStrArray *this, size_t size) |
Deletes the array of ytStrArray instances. | |
size_t | ytStrArray_buffSize (const ytStrArray *this) |
Returns the current buffer size allocated. | |
ytStrArray * | ytStrArray_setBuffSize (ytStrArray *this, size_t new_size) |
Changes the size of buffer. | |
size_t | ytStrArray_memSize (const ytStrArray *this) |
Returns the size of memory where the specified instance occupies. | |
size_t | ytStrArray_arrayMemSize (const ytStrArray *this, size_t n) |
Returns the total size of memory used by the array of the array. | |
void | ytStrArray_clear (ytStrArray *this) |
Removes all the elements in the array. | |
void | ytStrArray_add (ytStrArray *this, char *value) |
Adds a value. | |
void | ytStrArray_set (ytStrArray *this, size_t index, char *value) |
Sets a value at the specified position. | |
void | ytStrArray_setSize (ytStrArray *this, size_t size) |
Changes the size of the array. | |
void | ytStrArray_insert (ytStrArray *this, size_t index, char *value) |
Inserts a value at the specified position. | |
char * | ytStrArray_remove (ytStrArray *this, size_t index) |
void | ytStrArray_copy (ytStrArray *this, const ytStrArray *src) |
Copies values in another array into this. | |
void | ytStrArray_copyArray (ytStrArray *this, size_t index, const char **array, size_t size) |
Copies values in an array into this array. | |
char * | ytStrArray_pop (ytStrArray *this) |
Returns the last element. | |
void | ytStrArray_sort (ytStrArray *this) |
Sorts the elements in ascending order. | |
size_t | ytStrArray_find (const ytStrArray *this, const char *v) |
Returns the index of the value identical to the given one. | |
void | ytStrArray_print (const ytStrArray *this, FILE *fp, char *delim) |
Prints the elements in the array. | |
void | ytStrArray_MPI_Bcast (ytStrArray **pObject, int root, MPI_Comm comm) |
Broadcasts the array with MPI. | |
Related Symbols | |
(Note that these are not member symbols.) | |
#define | YTLIB_STR_ARRAY_DEFAULT_EXPAND_SIZE 16 |
Expandable char * Array. | |
Expandable array.
void ytStrArray_add | ( | ytStrArray * | this, |
char * | value ) |
Adds a value.
this | |
value |
void ytStrArray_arrayDelete | ( | ytStrArray * | this, |
size_t | size ) |
Deletes the array of ytStrArray instances.
This deletes the array of the instances allocated by ytStrArray_arrayNew(). The users have to specify the same number to the size parameter as specified to ytStrArray_arrayNew().
this | pointer returned by ytStrArray_arrayNew(). |
size | the size of the array. |
ytStrArray * ytStrArray_arrayNew | ( | size_t | size | ) |
Creates the array of ytStrArray instances.
The i -th istance can be accecced by p +
i where p
is the pointer returned by this. For example:
Use ytStrArray_arrayDelete() to delete the allocated instances.
size | the number of instances to allocate. |
size_t ytStrArray_buffSize | ( | const ytStrArray * | this | ) |
Returns the current buffer size allocated.
this | pointer to the ytStrArray instance. |
void ytStrArray_clear | ( | ytStrArray * | 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 ytStrArray_copy | ( | ytStrArray * | this, |
const ytStrArray * | src ) |
Copies values in another array into this.
this | |
src |
void ytStrArray_copyArray | ( | ytStrArray * | this, |
size_t | index, | ||
const char ** | array, | ||
size_t | size ) |
Copies values in an array into this array.
this | |
index | |
array | |
size |
size_t ytStrArray_find | ( | const ytStrArray * | this, |
const char * | v ) |
Returns the index of the value identical to the given one.
this | |
v | Value to find. |
void ytStrArray_insert | ( | ytStrArray * | this, |
size_t | index, | ||
char * | value ) |
Inserts a value at the specified position.
this | |
index | |
value |
size_t ytStrArray_memSize | ( | const ytStrArray * | this | ) |
Returns the size of memory where the specified instance occupies.
this | pointer to the ytStrArray instance. |
void ytStrArray_MPI_Bcast | ( | ytStrArray ** | 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 ). |
ytStrArray * ytStrArray_new | ( | ) |
Creates a new ytStrArray instance.
char * ytStrArray_pop | ( | ytStrArray * | this | ) |
Returns the last element.
The last element is returned and removed from the array.
this |
void ytStrArray_print | ( | const ytStrArray * | this, |
FILE * | fp, | ||
char * | delim ) |
Prints the elements in the array.
this | |
fp | FILE pointer to output. |
delim | delimitor |
char * ytStrArray_remove | ( | ytStrArray * | this, |
size_t | index ) |
\breif Removes the value at the specified position.
void ytStrArray_set | ( | ytStrArray * | this, |
size_t | index, | ||
char * | value ) |
Sets a value at the specified position.
this | |
index | |
value |
ytStrArray * ytStrArray_setBuffSize | ( | ytStrArray * | this, |
size_t | new_size ) |
void ytStrArray_setSize | ( | ytStrArray * | 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 ytStrArray_sort | ( | ytStrArray * | this | ) |
Sorts the elements in ascending order.
this |
|
related |
Expandable char * Array.