ZEDA  1.6.18
Data Structures | Macros | Typedefs | Functions
integer value array.

Data Structures

struct  zIndexStruct
 
struct  zIndex
 integer value array class More...
 

Macros

#define zIndexIncSize(i)   ( zArraySize(i)++ )
 increment size of an index vector. More...
 
#define zIndexDecSize(i)   ( zArraySize(i) -= ( zArraySize(i) > 0 ? 1 : 0 ) )
 decrement size of an index vector. More...
 
#define zIndexPosIsValid(i, n)   zArrayPosIsValid( i, n )
 check if the specified position is valid for an index vector. More...
 
#define zIndexElemNC(i, n)   zArrayBuf(i)[n]
 
#define zIndexElem(i, n)   ( zIndexPosIsValid(i,n) ? zIndexElemNC(i,n) : -1 )
 
#define zIndexSetElemNC(i, n, e)   ( zIndexElemNC(i,n) = (e) )
 
#define zIndexSetElem(i, n, e)   ( zIndexPosIsValid(i,n) ? zIndexSetElemNC(i,n,e) : -1 )
 
#define zIndexHead(idx)   ( *zArrayHead(idx) )
 
#define zIndexNeck(idx)   ( *zArrayNeck(idx) )
 
#define zIndexTail(idx)   ( *zArrayTail(idx) )
 
#define zIndexScan()   zIndexFScan( stdin )
 
#define zIndexPrint(i)   zIndexFPrint( stdout, i )
 
#define zIndexDataPrint(i)   zIndexDataFPrint( stdout, i )
 

Typedefs

typedef zIndexStructzIndex
 

Functions

zIndex zIndexAlloc (int size)
 allocate an array of integer values. More...
 
zIndex zIndexCreate (int size)
 create an array of integer values. More...
 
zIndex zIndexCreateList (int num,...)
 create an array of integer according to a specified list of arguments. More...
 
zIndex zIndexSetList (zIndex idx,...)
 set elements of an integer vector from argument list. More...
 
void zIndexFree (zIndex idx)
 free an array of integer values. More...
 
zIndex zIndexZero (zIndex idx)
 zero an array of integer values. More...
 
zIndex zIndexOrder (zIndex idx, int s)
 order an array of integer values. More...
 
bool zIndexIsEqual (zIndex idx1, zIndex idx2)
 check if two arrays of integer values are equal. More...
 
int zIndexSwap (zIndex idx, int p1, int p2)
 swap two elements of an array of integer values. More...
 
int zIndexMove (zIndex idx, int from, int to)
 move an element of an array of integer values. More...
 
zIndex zIndexFScan (FILE *fp)
 scan an array of integer values from a file. More...
 
void zIndexFPrint (FILE *fp, zIndex idx)
 print an array of integer values to a file. More...
 
void zIndexDataFPrint (FILE *fp, zIndex idx)
 print an array of integer values out to a file. More...
 
zIndex zIndexCreateFromList (zIntList *list)
 create an integer vector from a list of integers. More...
 

Detailed Description

Macro Definition Documentation

◆ zIndexIncSize

#define zIndexIncSize (   i)    ( zArraySize(i)++ )

increment size of an index vector.

◆ zIndexDecSize

#define zIndexDecSize (   i)    ( zArraySize(i) -= ( zArraySize(i) > 0 ? 1 : 0 ) )

decrement size of an index vector.

◆ zIndexPosIsValid

#define zIndexPosIsValid (   i,
 
)    zArrayPosIsValid( i, n )

check if the specified position is valid for an index vector.

◆ zIndexElemNC

#define zIndexElemNC (   i,
 
)    zArrayBuf(i)[n]

◆ zIndexElem

#define zIndexElem (   i,
 
)    ( zIndexPosIsValid(i,n) ? zIndexElemNC(i,n) : -1 )

◆ zIndexSetElemNC

#define zIndexSetElemNC (   i,
  n,
 
)    ( zIndexElemNC(i,n) = (e) )

◆ zIndexSetElem

#define zIndexSetElem (   i,
  n,
 
)    ( zIndexPosIsValid(i,n) ? zIndexSetElemNC(i,n,e) : -1 )

◆ zIndexHead

#define zIndexHead (   idx)    ( *zArrayHead(idx) )

◆ zIndexNeck

#define zIndexNeck (   idx)    ( *zArrayNeck(idx) )

◆ zIndexTail

#define zIndexTail (   idx)    ( *zArrayTail(idx) )

◆ zIndexScan

#define zIndexScan ( )    zIndexFScan( stdin )

◆ zIndexPrint

#define zIndexPrint (   i)    zIndexFPrint( stdout, i )

◆ zIndexDataPrint

#define zIndexDataPrint (   i)    zIndexDataFPrint( stdout, i )

Typedef Documentation

◆ zIndex

typedef zIndexStruct* zIndex

Function Documentation

◆ zIndexAlloc()

zIndex zIndexAlloc ( int  size)

allocate an array of integer values.

zIndexAlloc() allocates a vector of integer values with a size size.

Returns
zIndexAlloc() returns a pointer to the allocated memory if it succeeds. Otherwise, the null pointer is returned.

◆ zIndexCreate()

zIndex zIndexCreate ( int  size)

create an array of integer values.

zIndexCreate() creates an array of integer values with a size size. It initializes all values of the array as { 0, 1, 2, ..., size -1 }.

Returns
zIndexCreate() returns a pointer to the allocated array if it succeeds. Otherwise, the null pointer is returned.

◆ zIndexCreateList()

zIndex zIndexCreateList ( int  num,
  ... 
)

create an array of integer according to a specified list of arguments.

zIndexCreateList() creates an array of integer values from the specified list of arguments. num is the number of values.

Returns
a pointer to the zIndex instance newly allocated. Or, the null pointer when failing to allocate new zIndex instance.
Note
zIndexCreateList() is not available in the kernel space.

◆ zIndexSetList()

zIndex zIndexSetList ( zIndex  idx,
  ... 
)

set elements of an integer vector from argument list.

zIndexSetList() sets elements of an array of integer values idx from the specified list of arguments.

Return values

◆ zIndexFree()

void zIndexFree ( zIndex  idx)

free an array of integer values.

zIndexFree() frees a zIndex instance idx, freeing the assigned memory space.

◆ zIndexZero()

zIndex zIndexZero ( zIndex  idx)

zero an array of integer values.

zIndexZero() sets all components of an array of index values idex for zeros.

Return values
apointer idx.

◆ zIndexOrder()

zIndex zIndexOrder ( zIndex  idx,
int  s 
)

order an array of integer values.

zIndexOrder() sets all components of idx in order, beginning from s as { s, s+1, s+2, ... }.

Return values
apointer idx.

◆ zIndexIsEqual()

bool zIndexIsEqual ( zIndex  idx1,
zIndex  idx2 
)

check if two arrays of integer values are equal.

zIndexIsEqual() checks if two arrays of integer values idx1 and idx2 are equal.

Returns
the true value if idx1 and idx2 are equal, or the false values, otherwise.

◆ zIndexSwap()

int zIndexSwap ( zIndex  idx,
int  p1,
int  p2 
)

swap two elements of an array of integer values.

zIndexSwap() swaps two components of a zIndex instance idx at the positions of p1 and p2.

Returns
a newly swapped value at p2.
Note
if p1 or p2 is invalid, anything might happen.

◆ zIndexMove()

int zIndexMove ( zIndex  idx,
int  from,
int  to 
)

move an element of an array of integer values.

zIndexMove() moves a component at from' of a zIndex instance idx to another position to. The components between from and to are slided to make a space to insert the component.

Returns
a newly replaced value at to.
Note
if from or to is invalid, anything might happen.

◆ zIndexFScan()

zIndex zIndexFScan ( FILE *  fp)

scan an array of integer values from a file.

zIndexFScan() scans a sequence of integer values from the current position of a file fp, and create a new zIndex instance. The format to be scanned by zIndexFScan() is as follows:

n ( x1 x2 x3 ... xn )

where n is the number of values.

zIndexScan() is also available to scan values from the standard input.

Returns
a pointer to the newly allocated zIndex instance.
See also
zIndexScan, zIndexFPrint

◆ zIndexFPrint()

void zIndexFPrint ( FILE *  fp,
zIndex  idx 
)

print an array of integer values to a file.

zIndexFPrint() prints an array of integer values in a zIndex instance idx out to the current position of a file fp in the following format:

n ( x1 x2 x3 ... xn )

where n is the number of values.

zIndexPrint() is also available to print values out to the standard output.

See also
zIndexFScan, zIndexPrint, zIndexDataFPrint

◆ zIndexDataFPrint()

void zIndexDataFPrint ( FILE *  fp,
zIndex  idx 
)

print an array of integer values out to a file.

zIndexDataFPrint() prints an array of integer values in a zIndex instance idx out to the current position of a file fp in the following format:

x1 x2 x3 ... xn

zIndexDataPrint() is also available to print values out to the standard output.

See also
zIndexFScan, zIndexFPrint, zIndexDataPrint

◆ zIndexCreateFromList()

zIndex zIndexCreateFromList ( zIntList list)

create an integer vector from a list of integers.