ZEDA
1.6.18
|
Macros | |
#define | zArray2Class(array_t, cell_t) |
generate two-dimensional array class. More... | |
#define | zArray2Size(a, i) (a)->size[i] |
#define | zArray2RowSize(a) (a)->size[0] |
#define | zArray2ColSize(a) (a)->size[1] |
#define | zArray2Buf(a) ( (a)->buf ) |
#define | zArray2PosIsValid(a, r, c) ( (r) < zArray2RowSize(a) && (r) >= 0 && (c) < zArray2ColSize(a) && (c) >= 0 ) |
#define | zArray2ElemSize(a) sizeof(*zArray2Buf(a)) |
#define | zArray2ElemNC(a, i, j) ( &zArray2Buf(a)[(i)*zArray2ColSize(a) + (j)] ) |
#define | zArray2Elem(a, i, j) ( zArray2PosIsValid(a,i,j) ? zArray2ElemNC(a,i,j) : NULL ) |
#define | zArray2SetElemNC(a, i, j, d) memcpy( zArray2ElemNC(a,i,j), (d), zArray2ElemSize(a) ) |
#define | zArray2SetElem(a, i, j, d) ( zArray2PosIsValid(a,i,j) ? zArray2SetElemNC(a,i,j,d) : NULL ) |
#define | zArray2Init(arr) |
#define | zArray2Alloc(arr, type, r, c) |
allocate an array. More... | |
#define | zArray2Free(arr) |
free an array. More... | |
#define zArray2Class | ( | array_t, | |
cell_t | |||
) |
generate two-dimensional array class.
A macro zArray2Class() can generate a new two-dimensional array class, which consists of the row and column sizes of the array and the pointer to the array buffer. array_t is the class name to be defined. cell_t is the class name of the data to be arrayed.
The row and column sizes of the array are acquired by zArray2Size(). zArray2RowSize() and zArray2ColSize() are also available. Each element can be accessed by zArray2Elem(). For a faster access to each element, zArray2ElemNC() is also available, which does not check the specified location.
The array can be freed by calling zArray2Free().
zArray2SetElem() is available in order to set each element, which works only if the specified location is valid. zArray2SetElemNC() is also available, which provides a faster access to each element without checking the validity of specified location.
#define zArray2Size | ( | a, | |
i | |||
) | (a)->size[i] |
#define zArray2RowSize | ( | a | ) | (a)->size[0] |
#define zArray2ColSize | ( | a | ) | (a)->size[1] |
#define zArray2Buf | ( | a | ) | ( (a)->buf ) |
#define zArray2PosIsValid | ( | a, | |
r, | |||
c | |||
) | ( (r) < zArray2RowSize(a) && (r) >= 0 && (c) < zArray2ColSize(a) && (c) >= 0 ) |
#define zArray2ElemSize | ( | a | ) | sizeof(*zArray2Buf(a)) |
#define zArray2ElemNC | ( | a, | |
i, | |||
j | |||
) | ( &zArray2Buf(a)[(i)*zArray2ColSize(a) + (j)] ) |
#define zArray2Elem | ( | a, | |
i, | |||
j | |||
) | ( zArray2PosIsValid(a,i,j) ? zArray2ElemNC(a,i,j) : NULL ) |
#define zArray2SetElemNC | ( | a, | |
i, | |||
j, | |||
d | |||
) | memcpy( zArray2ElemNC(a,i,j), (d), zArray2ElemSize(a) ) |
#define zArray2SetElem | ( | a, | |
i, | |||
j, | |||
d | |||
) | ( zArray2PosIsValid(a,i,j) ? zArray2SetElemNC(a,i,j,d) : NULL ) |
#define zArray2Init | ( | arr | ) |
#define zArray2Alloc | ( | arr, | |
type, | |||
r, | |||
c | |||
) |
allocate an array.
arr | array class instance to be allocated. |
type | the data type of the array cells. |
n | the number of cells. |
#define zArray2Free | ( | arr | ) |
free an array.
arr | a pointer to the array to be freed. |