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

Expandable array. More...

#include <ytDoubleArray.h>

Public Member Functions

#define YTLIB_DOUBLE_ARRAY_DEFAULT_EXPAND_SIZE   16
 Expandable double Array.
 
ytDoubleArrayytDoubleArray_new ()
 Creates a new ytDoubleArray instance.
 
void ytDoubleArray_deleteAll (ytDoubleArray *this)
 Releases the array and all the elements in the array.
 
ytDoubleArrayytDoubleArray_clone (const ytDoubleArray *this)
 Returns the clone of this ytDoubleArray instance.
 
ytObjectytDoubleArray_cloneI (const ytObject *this)
 Returns the clone of this ytDoubleArray instance.
 
ytDoubleArrayytDoubleArray_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.
 
ytDoubleArrayytDoubleArray_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.
 

Detailed Description

Expandable array.

Member Function Documentation

◆ ytDoubleArray_add()

void ytDoubleArray_add ( ytDoubleArray this,
double  value 
)

Adds a value.

Parameters
this
value

◆ ytDoubleArray_arrayDelete()

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

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

◆ ytDoubleArray_arrayNew()

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:

;
ytDoubleArray_add(ar + i, value);
...
Expandable array.
ytDoubleArray * ytDoubleArray_arrayNew(size_t size)
Creates the array of ytDoubleArray instances.
Definition ytDoubleArray.c:154
void ytDoubleArray_add(ytDoubleArray *this, double value)
Adds a value.
Definition ytDoubleArray.c:262

Use ytDoubleArray_arrayDelete() to delete the allocated instances.

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

◆ ytDoubleArray_buffSize()

size_t ytDoubleArray_buffSize ( const ytDoubleArray this)

Returns the current buffer size allocated.

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

◆ ytDoubleArray_clear()

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.

◆ ytDoubleArray_copy()

void ytDoubleArray_copy ( ytDoubleArray this,
const ytDoubleArray src 
)

Copies values in another array into this.

Parameters
this
src

◆ ytDoubleArray_copyArray()

void ytDoubleArray_copyArray ( ytDoubleArray this,
size_t  index,
const double *  array,
size_t  size 
)

Copies values in an array into this array.

Parameters
this
index
array
size

◆ ytDoubleArray_find()

size_t ytDoubleArray_find ( const ytDoubleArray this,
const double  v 
)

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

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

◆ ytDoubleArray_insert()

void ytDoubleArray_insert ( ytDoubleArray this,
size_t  index,
double  value 
)

Inserts a value at the specified position.

Parameters
this
index
value

◆ ytDoubleArray_memSize()

size_t ytDoubleArray_memSize ( const ytDoubleArray this)

Returns the size of memory where the specified instance occupies.

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

◆ ytDoubleArray_MPI_Bcast()

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.

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

◆ ytDoubleArray_new()

ytDoubleArray * ytDoubleArray_new ( )

Creates a new ytDoubleArray instance.

Returns
pointer to the newly created ytDoubleArray instance.

◆ ytDoubleArray_pop()

double ytDoubleArray_pop ( ytDoubleArray 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.

◆ ytDoubleArray_print()

void ytDoubleArray_print ( const ytDoubleArray this,
FILE *  fp,
char *  delim 
)

Prints the elements in the array.

Parameters
this
fpFILE pointer to output.
delimdelimitor

◆ ytDoubleArray_remove()

double ytDoubleArray_remove ( ytDoubleArray this,
size_t  index 
)

\breif Removes the value at the specified position.

Returns
element to be deleted from the array.

◆ ytDoubleArray_set()

void ytDoubleArray_set ( ytDoubleArray this,
size_t  index,
double  value 
)

Sets a value at the specified position.

Parameters
this
index
value

◆ ytDoubleArray_setBuffSize()

ytDoubleArray * ytDoubleArray_setBuffSize ( ytDoubleArray this,
size_t  new_size 
)

Changes the size of buffer.

Parameters
this
new_size
Returns
this, or NULL if failed.

◆ ytDoubleArray_setSize()

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.

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

◆ ytDoubleArray_sort()

void ytDoubleArray_sort ( ytDoubleArray this)

Sorts the elements in ascending order.

Parameters
this

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