LibRCG  3.1.1
array.h
Go to the documentation of this file.
1 
15 #ifndef _ARRAY_H_
16 #define _ARRAY_H_
17 
18 #include "iterator.h"
19 
23 typedef struct sArray
24 {
26  int capacity;
28  int size;
30  void** array;
31 }SArray;
32 
36 typedef SArray* Array;
37 
38 //==============================================================================
39 
51 Array newArray(int size);
52 
62 void arrayDelete(Array array);
63 
90 int arrayInsert(Array array,int index,void* elem,int replace);
91 
110 int arrayRemove(Array array,int index,void** elem);
111 
130 int arrayAt(Array array,int index,void** elem);
131 
145 int arrayResize(Array array,int size);
146 
155 int arraySize(Array array);
156 
165 int arrayCapacity(Array array);
166 
179 int arrayMap(Array array,void(*fun)(void*));
180 
193 
194 #endif
int arrayAt(Array array, int index, void **elem)
Provides the element at the specified position of an array.
Definition: array.c:95
void arrayDelete(Array array)
Deletes an array.
Definition: array.c:35
Array newArray(int size)
Creates an empty array, with the specified initial capacity.
Definition: array.c:12
int arrayInsert(Array array, int index, void *elem, int replace)
Inserts an new element at the specified position of an array.
Definition: array.c:43
int arrayMap(Array array, void(*fun)(void *))
Applies a function to the elements of an array.
Definition: array.c:149
SArray * Array
Array definition.
Definition: array.h:36
Iterator structure.
Definition: iterator.h:17
int arrayRemove(Array array, int index, void **elem)
Removes the element at the specified position of an array.
Definition: array.c:71
void ** array
Array of pointers to this array's elements.
Definition: array.h:30
int size
Number of element of this array.
Definition: array.h:28
int capacity
Current capacity of this array.
Definition: array.h:26
Implementation of an iterator.
int arrayCapacity(Array array)
Return the capacity of an array.
Definition: array.c:142
int arraySize(Array array)
Returns the size of an array.
Definition: array.c:135
int arrayResize(Array array, int size)
Increases the capacity of an array.
Definition: array.c:114
Array structure.
Definition: array.h:23
Iterator arrayIterator(Array array)
Creates an iterator from an array.
Definition: array.c:169

LibRCG © 2004-2015   Rui Carlos Gonçalves