pelib  2.0.0
include/pelib/array.h File Reference
#include <pelib/template.h>
#include <pelib/structure.h>
Include dependency graph for array.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define array(elem)   PELIB_CONCAT_2(array_, elem)
#define array_t(elem)   PELIB_CONCAT_2(array(elem), _t)
#define pelib_array_loadfilename(elem)   PELIB_CONCAT_3(pelib_, array(elem), _loadfilename)
#define pelib_array_loadfilenamebinary(elem)   PELIB_CONCAT_3(pelib_, array(elem), _loadfilenamebinary)
#define pelib_array_preloadfilenamebinary(elem)   PELIB_CONCAT_3(pelib_, array(elem), _preloadfilenamebinary)
#define pelib_array_loadfilenamewindowbinary(elem)   PELIB_CONCAT_3(pelib_, array(elem), _loadfilenamewindowbinary)
#define pelib_array_storefilename(elem)   PELIB_CONCAT_3(pelib_, array(elem), _storefilename)
#define pelib_array_storefilenamebinary(elem)   PELIB_CONCAT_3(pelib_, array(elem), _storefilenamebinary)
#define pelib_array_checkascending(elem)   PELIB_CONCAT_3(pelib_, array(elem), _checkascending)
#define pelib_array_read(elem)   PELIB_CONCAT_3(pelib_, array(elem), _read)
#define pelib_array_write(elem)   PELIB_CONCAT_3(pelib_, array(elem), _write)
#define pelib_array_append(elem)   PELIB_CONCAT_3(pelib_, array(elem), _append)
#define pelib_array_length(elem)   PELIB_CONCAT_3(pelib_, array(elem), _length)
#define pelib_array_capacity(elem)   PELIB_CONCAT_3(pelib_, array(elem), _capacity)
#define pelib_array_compare(elem)   PELIB_CONCAT_3(pelib_, array(elem), _compare)
#define STRUCT_T   array_t(ARRAY_T)

Functions

struct array (ARRAY_T)
 array_t (ARRAY_T)*pelib_array_loadfilename(ARRAY_T)(char *)
int pelib_array_storefilename() ARRAY_T (array_t(ARRAY_T)*, char *)
int pelib_array_checkascending() ARRAY_T (array_t(ARRAY_T)*)
ARRAY_T pelib_array_read() ARRAY_T (array_t(ARRAY_T)*, size_t i)
int pelib_array_write() ARRAY_T (array_t(ARRAY_T)*, size_t i, ARRAY_T elem)
int pelib_array_append() ARRAY_T (array_t(ARRAY_T)*, ARRAY_T elem)
int pelib_array_compare() ARRAY_T (array_t(ARRAY_T)*a1, array_t(ARRAY_T)*a2)

Variables

size_t from
size_t size_t to

Define Documentation

#define array (   elem)    PELIB_CONCAT_2(array_, elem)

Definition at line 27 of file array.h.

#define array_t (   elem)    PELIB_CONCAT_2(array(elem), _t)

Definition at line 28 of file array.h.

#define pelib_array_append (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _append)

Definition at line 39 of file array.h.

#define pelib_array_capacity (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _capacity)

Definition at line 41 of file array.h.

#define pelib_array_checkascending (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _checkascending)

Definition at line 36 of file array.h.

#define pelib_array_compare (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _compare)

Definition at line 42 of file array.h.

#define pelib_array_length (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _length)

Definition at line 40 of file array.h.

#define pelib_array_loadfilename (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _loadfilename)

Definition at line 30 of file array.h.

#define pelib_array_loadfilenamebinary (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _loadfilenamebinary)

Definition at line 31 of file array.h.

#define pelib_array_loadfilenamewindowbinary (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _loadfilenamewindowbinary)

Definition at line 33 of file array.h.

#define pelib_array_preloadfilenamebinary (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _preloadfilenamebinary)

Definition at line 32 of file array.h.

#define pelib_array_read (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _read)

Definition at line 37 of file array.h.

#define pelib_array_storefilename (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _storefilename)

Definition at line 34 of file array.h.

#define pelib_array_storefilenamebinary (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _storefilenamebinary)

Definition at line 35 of file array.h.

#define pelib_array_write (   elem)    PELIB_CONCAT_3(pelib_, array(elem), _write)

Definition at line 38 of file array.h.

#define STRUCT_T   array_t(ARRAY_T)

Definition at line 53 of file array.h.


Function Documentation

struct array ( ARRAY_T  ) [read]

Generic static array

Maximum elements in the array

Number of elements currently stored in the array

Address where elements are stored

Definition at line 45 of file array.h.

Load an instance of array from a text file. The capacity of the array equals the number of elements loaded

Load an instance of array from a binary file. The capacity of the array equals the number of elements loaded

Load the number of elements in a array from a binary file, but not the data itself. The capacity of the array equals the number of elements loaded

Load only a portion of the data stored in a binary file. The capacity of the array equals the number of elements loaded

Parameters:
Indexof the first element to be loaded. This element is stored at offset 0 in this array instance
toIndex of the last element to be loaded

Stores an array in a text file

Stores an array in a binary file

Definition at line 442 of file array.c.

Returns 0 if elements in an array are not sorted in non-decreasing order

Returns the length of the array, that is the number of elements stored in it

Returns the maximum number of elements this array can hold

Definition at line 478 of file array.c.

Returns the i-th element in the array, starting at 0

Definition at line 518 of file array.c.

Places element elem at index i, starting at 0

Definition at line 538 of file array.c.

Write elem in array instance at index defined by the array's length

Returns:
0 if this array is already full

Definition at line 571 of file array.c.

Compares all elements of two arrays one by one

Returns:
If a1 and a2 have the same number of elements, for the first pair of elements from both arrays a1 and a2 that are different, return -1 if the element of a1 is lower than the element of a2, 1 otherwise. Returns 0 if all elements are identical. If a1 has less elements than a2, then returns -1 other wise returns 1.

Definition at line 587 of file array.c.


Variable Documentation

Definition at line 69 of file array.h.

Definition at line 69 of file array.h.