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

Expandable array. More...

#include <ytIntArray.h>

Public Member Functions

#define YTLIB_INT_ARRAY_DEFAULT_EXPAND_SIZE   16
 Expandable int Array.
 
ytIntArrayytIntArray_new ()
 Creates a new ytIntArray instance.
 
void ytIntArray_deleteAll (ytIntArray *this)
 Releases the array and all the elements in the array.
 
ytIntArrayytIntArray_clone (const ytIntArray *this)
 Returns the clone of this ytIntArray instance.
 
ytObjectytIntArray_cloneI (const ytObject *this)
 Returns the clone of this ytIntArray instance.
 
ytIntArrayytIntArray_arrayNew (size_t size)
 Creates the array of ytIntArray instances.
 
void ytIntArray_arrayDelete (ytIntArray *this, size_t size)
 Deletes the array of ytIntArray instances.
 
size_t ytIntArray_buffSize (const ytIntArray *this)
 Returns the current buffer size allocated.
 
ytIntArrayytIntArray_setBuffSize (ytIntArray *this, size_t new_size)
 Changes the size of buffer.
 
size_t ytIntArray_memSize (const ytIntArray *this)
 Returns the size of memory where the specified instance occupies.
 
size_t ytIntArray_arrayMemSize (const ytIntArray *this, size_t n)
 Returns the total size of memory used by the array of the array.
 
void ytIntArray_clear (ytIntArray *this)
 Removes all the elements in the array.
 
void ytIntArray_add (ytIntArray *this, int value)
 Adds a value.
 
void ytIntArray_set (ytIntArray *this, size_t index, int value)
 Sets a value at the specified position.
 
void ytIntArray_setSize (ytIntArray *this, size_t size)
 Changes the size of the array.
 
void ytIntArray_insert (ytIntArray *this, size_t index, int value)
 Inserts a value at the specified position.
 
int ytIntArray_remove (ytIntArray *this, size_t index)
 
void ytIntArray_copy (ytIntArray *this, const ytIntArray *src)
 Copies values in another array into this.
 
void ytIntArray_copyArray (ytIntArray *this, size_t index, const int *array, size_t size)
 Copies values in an array into this array.
 
int ytIntArray_pop (ytIntArray *this)
 Returns the last element.
 
void ytIntArray_sort (ytIntArray *this)
 Sorts the elements in ascending order.
 
size_t ytIntArray_find (const ytIntArray *this, const int v)
 Returns the index of the value identical to the given one.
 
void ytIntArray_print (const ytIntArray *this, FILE *fp, char *delim)
 Prints the elements in the array.
 
void ytIntArray_MPI_Bcast (ytIntArray **pObject, int root, MPI_Comm comm)
 Broadcasts the array with MPI.
 

Detailed Description

Expandable array.

Member Function Documentation

◆ ytIntArray_add()

void ytIntArray_add ( ytIntArray this,
int  value 
)

Adds a value.

Parameters
this
value

◆ ytIntArray_arrayDelete()

void ytIntArray_arrayDelete ( ytIntArray this,
size_t  size 
)

Deletes the array of ytIntArray instances.

This deletes the array of the instances allocated by ytIntArray_arrayNew(). The users have to specify the same number to the size parameter as specified to ytIntArray_arrayNew().

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

◆ ytIntArray_arrayNew()

ytIntArray * ytIntArray_arrayNew ( size_t  size)

Creates the array of ytIntArray instances.

The i -th istance can be accecced by p + i where p is the pointer returned by this. For example:

;
ytIntArray_add(ar + i, value);
...
Expandable array.
ytIntArray * ytIntArray_arrayNew(size_t size)
Creates the array of ytIntArray instances.
Definition ytIntArray.c:181
void ytIntArray_add(ytIntArray *this, int value)
Adds a value.
Definition ytIntArray.c:289

Use ytIntArray_arrayDelete() to delete the allocated instances.

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

◆ ytIntArray_buffSize()

size_t ytIntArray_buffSize ( const ytIntArray this)

Returns the current buffer size allocated.

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

◆ ytIntArray_clear()

void ytIntArray_clear ( ytIntArray 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.

◆ ytIntArray_copy()

void ytIntArray_copy ( ytIntArray this,
const ytIntArray src 
)

Copies values in another array into this.

Parameters
this
src

◆ ytIntArray_copyArray()

void ytIntArray_copyArray ( ytIntArray this,
size_t  index,
const int *  array,
size_t  size 
)

Copies values in an array into this array.

Parameters
this
index
array
size

◆ ytIntArray_find()

size_t ytIntArray_find ( const ytIntArray this,
const int  v 
)

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

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

◆ ytIntArray_insert()

void ytIntArray_insert ( ytIntArray this,
size_t  index,
int  value 
)

Inserts a value at the specified position.

Parameters
this
index
value

◆ ytIntArray_memSize()

size_t ytIntArray_memSize ( const ytIntArray this)

Returns the size of memory where the specified instance occupies.

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

◆ ytIntArray_MPI_Bcast()

void ytIntArray_MPI_Bcast ( ytIntArray **  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).

◆ ytIntArray_new()

ytIntArray * ytIntArray_new ( )

Creates a new ytIntArray instance.

Returns
pointer to the newly created ytIntArray instance.

◆ ytIntArray_pop()

int ytIntArray_pop ( ytIntArray 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.

◆ ytIntArray_print()

void ytIntArray_print ( const ytIntArray this,
FILE *  fp,
char *  delim 
)

Prints the elements in the array.

Parameters
this
fpFILE pointer to output.
delimdelimitor

◆ ytIntArray_remove()

int ytIntArray_remove ( ytIntArray this,
size_t  index 
)

\breif Removes the value at the specified position.

Returns
element to be deleted from the array.

◆ ytIntArray_set()

void ytIntArray_set ( ytIntArray this,
size_t  index,
int  value 
)

Sets a value at the specified position.

Parameters
this
index
value

◆ ytIntArray_setBuffSize()

ytIntArray * ytIntArray_setBuffSize ( ytIntArray this,
size_t  new_size 
)

Changes the size of buffer.

Parameters
this
new_size
Returns
this, or NULL if failed.

◆ ytIntArray_setSize()

void ytIntArray_setSize ( ytIntArray 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===================================================

◆ ytIntArray_sort()

void ytIntArray_sort ( ytIntArray this)

Sorts the elements in ascending order.

Parameters
this

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