#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <pelib/size_t.h>
Go to the source code of this file.
Defines |
#define | min(elem) PELIB_CONCAT_2(min_, elem) |
#define | array_length_debug printf("[PELIB:%s:%s:%d] i = %d\n", __FILE__, __FUNCTION__, __LINE__, i); |
#define | array_length_pre_debug printf("[PELIB:%s:%s:%d] length = %d\n", __FILE__, __FUNCTION__, __LINE__, pelib_array_length(ARRAY_T)(&array)); |
Functions |
| array_t (ARRAY_T) |
int | pelib_alloc_buffer (array_t(ARRAY_T)) |
int | pelib_set_buffer (array_t(ARRAY_T)) |
int | pelib_init (array_t(ARRAY_T)) |
int | pelib_copy (array_t(ARRAY_T)) |
char * | pelib_string (array_t(ARRAY_T)) |
char * | pelib_string_detail (array_t(ARRAY_T)) |
FILE * | pelib_printf (array_t(ARRAY_T)) |
FILE * | pelib_printf_detail (array_t(ARRAY_T)) |
int pelib_array_storefilename() | ARRAY_T (array_t(ARRAY_T)*array, char *filename) |
int pelib_array_checkascending() | ARRAY_T (array_t(ARRAY_T)*array) |
int | pelib_free_buffer (array_t(ARRAY_T)) |
int | pelib_free (array_t(ARRAY_T)) |
int | pelib_free_struct (array_t(ARRAY_T)) |
ARRAY_T pelib_array_read() | ARRAY_T (array_t(ARRAY_T)*array, size_t pos) |
int pelib_array_write() | ARRAY_T (array_t(ARRAY_T)*array, size_t pos, ARRAY_T val) |
int pelib_array_append() | ARRAY_T (array_t(ARRAY_T)*array, ARRAY_T val) |
int pelib_array_compare() | ARRAY_T (array_t(ARRAY_T)*a1, array_t(ARRAY_T)*a2) |
Define Documentation
#define array_length_debug printf("[PELIB:%s:%s:%d] i = %d\n", __FILE__, __FUNCTION__, __LINE__, i); |
Function Documentation
Reads length value_t elements from filename, and skip the offset first elements.
- Parameters:
-
filename,: | File to open and read values from |
offset,: | number of elements of value_t to skip before reading the values |
length,: | number of elements to read. If length < 0, then reads the remaining number of elements available in the file |
- Returns:
- : an array of capacity of length, or the number or elements stored in the array file if length below 0. If not enough elements could be skipped, then returns NULL
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:
-
Index | of the first element to be loaded. This element is stored at offset 0 in this array instance |
to | Index of the last element to be loaded |
Definition at line 68 of file array.c.
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.