2008-04-24 11:07:47 -07:00
|
|
|
#ifndef VECTOR_H_
|
|
|
|
#define VECTOR_H_
|
|
|
|
|
|
|
|
typedef struct _vector vector;
|
2008-07-02 16:18:32 -07:00
|
|
|
typedef void (*mapCallback) (void *object);
|
2008-04-24 11:07:47 -07:00
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
* Creates a new vector.
|
|
|
|
*
|
|
|
|
* @param destroyCb The callback function to call whenever an element is deleted
|
|
|
|
* or replaced.
|
|
|
|
* @return A pointer to the newly created vector on success; otherwise NULL.
|
|
|
|
*/
|
2008-07-02 16:18:32 -07:00
|
|
|
vector *vectorCreate(void);
|
2008-04-24 11:07:47 -07:00
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
* Destroys the vector v. This is done by first calling the destroy callback
|
|
|
|
* function on each element in the vector then free'ing the vector itself.
|
|
|
|
*
|
|
|
|
* @param v The vector to destroy.
|
|
|
|
*/
|
2008-04-24 11:07:47 -07:00
|
|
|
void vectorDestroy(vector *v);
|
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
* Adds object to the vector v.
|
|
|
|
*
|
|
|
|
* @param v The vector to add the object onto.
|
|
|
|
* @param object The object to add.
|
|
|
|
* @return A pointer to object.
|
|
|
|
*/
|
2008-04-24 11:07:47 -07:00
|
|
|
void *vectorAdd(vector *v, void *object);
|
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-04-24 11:07:47 -07:00
|
|
|
void *vectorAt(vector *v, int index);
|
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-04-24 11:07:47 -07:00
|
|
|
void *vectorSetAt(vector *v, int index, void *object);
|
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-04-24 11:07:47 -07:00
|
|
|
void vectorRemoveAt(vector *v, int index);
|
|
|
|
|
2008-07-02 16:18:32 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void vectorMap(vector *v, mapCallback cb);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void vectorMapAndDestroy(vector *v, mapCallback cb);
|
|
|
|
|
2008-06-24 03:11:03 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2008-04-24 11:07:47 -07:00
|
|
|
int vectorSize(vector *v);
|
|
|
|
|
|
|
|
#endif /*VECTOR_H_*/
|