INGOR
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ytStrArray Class Reference

Expandable array. More...

#include <ytStrArray.h>

Public Member Functions

#define YTLIB_STR_ARRAY_DEFAULT_EXPAND_SIZE   16
 Expandable char * Array.
 
ytStrArrayytStrArray_new ()
 Creates a new ytStrArray instance.
 
void ytStrArray_deleteAll (ytStrArray *this)
 Releases the array and all the elements in the array.
 
ytStrArrayytStrArray_clone (const ytStrArray *this)
 Returns the clone of this ytStrArray instance.
 
ytObjectytStrArray_cloneI (const ytObject *this)
 Returns the clone of this ytStrArray instance.
 
ytStrArrayytStrArray_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.
 
ytStrArrayytStrArray_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.
 

Detailed Description

Expandable array.

Member Function Documentation

◆ ytStrArray_add()

void ytStrArray_add ( ytStrArray this,
char *  value 
)

Adds a value.

Parameters
this
value

◆ ytStrArray_arrayDelete()

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().

Parameters
thispointer returned by ytStrArray_arrayNew().
sizethe size of the array.

◆ ytStrArray_arrayNew()

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:

;
ytStrArray_add(ar + i, value);
...
Expandable array.
ytStrArray * ytStrArray_arrayNew(size_t size)
Creates the array of ytStrArray instances.
Definition ytStrArray.c:155
void ytStrArray_add(ytStrArray *this, char *value)
Adds a value.
Definition ytStrArray.c:263

Use ytStrArray_arrayDelete() to delete the allocated instances.

Parameters
sizethe number of instances to allocate.
See also
ytStrArray_arrayDelete()

◆ ytStrArray_buffSize()

size_t ytStrArray_buffSize ( const ytStrArray this)

Returns the current buffer size allocated.

Parameters
thispointer to the ytStrArray instance.
Returns
the size of allocated buffer in bytes.

◆ ytStrArray_clear()

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.

◆ ytStrArray_copy()

void ytStrArray_copy ( ytStrArray this,
const ytStrArray src 
)

Copies values in another array into this.

Parameters
this
src

◆ ytStrArray_copyArray()

void ytStrArray_copyArray ( ytStrArray this,
size_t  index,
const char **  array,
size_t  size 
)

Copies values in an array into this array.

Parameters
this
index
array
size

◆ ytStrArray_find()

size_t ytStrArray_find ( const ytStrArray this,
const char *  v 
)

Returns the index of the value identical to the given one.

Parameters
this
vValue to find.
Returns
index, or ytStrArray_ERROR_VALUE if not found.

◆ ytStrArray_insert()

void ytStrArray_insert ( ytStrArray this,
size_t  index,
char *  value 
)

Inserts a value at the specified position.

Parameters
this
index
value

◆ ytStrArray_memSize()

size_t ytStrArray_memSize ( const ytStrArray this)

Returns the size of memory where the specified instance occupies.

Parameters
thispointer to the ytStrArray instance.
Returns
the size of occupied memory size by the instance.

◆ ytStrArray_MPI_Bcast()

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.

Parameters
pObjectpointer to the array instance. in receiving ranks, the new instance is generated and set to the original pointer (*pObject).

◆ ytStrArray_new()

ytStrArray * ytStrArray_new ( )

Creates a new ytStrArray instance.

Returns
pointer to the newly created ytStrArray instance.

◆ ytStrArray_pop()

char * ytStrArray_pop ( ytStrArray this)

Returns the last element.

The last element is returned and removed from the array.

Parameters
this
Returns
value at the end of the array.

◆ ytStrArray_print()

void ytStrArray_print ( const ytStrArray this,
FILE *  fp,
char *  delim 
)

Prints the elements in the array.

Parameters
this
fpFILE pointer to output.
delimdelimitor

◆ ytStrArray_remove()

char * ytStrArray_remove ( ytStrArray this,
size_t  index 
)

\breif Removes the value at the specified position.

Returns
element to be deleted from the array.

◆ ytStrArray_set()

void ytStrArray_set ( ytStrArray this,
size_t  index,
char *  value 
)

Sets a value at the specified position.

Parameters
this
index
value

◆ ytStrArray_setBuffSize()

ytStrArray * ytStrArray_setBuffSize ( ytStrArray this,
size_t  new_size 
)

Changes the size of buffer.

Parameters
this
new_size
Returns
this, or NULL if failed.

◆ ytStrArray_setSize()

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.

Parameters
this
size===================================================

◆ ytStrArray_sort()

void ytStrArray_sort ( ytStrArray this)

Sorts the elements in ascending order.

Parameters
this

The documentation for this class was generated from the following files: