2008-08-06 11:15:24 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2008 Cedric Bail
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-07-30 09:34:54 -07:00
|
|
|
#ifndef EINA_ARRAY_H_
|
|
|
|
#define EINA_ARRAY_H_
|
|
|
|
|
2008-08-01 05:26:35 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2008-07-30 09:34:54 -07:00
|
|
|
#include "eina_types.h"
|
2008-08-11 09:30:16 -07:00
|
|
|
#include "eina_iterator.h"
|
|
|
|
#include "eina_accessor.h"
|
2008-07-30 09:34:54 -07:00
|
|
|
|
|
|
|
typedef struct _Eina_Array Eina_Array; /**< A generic vector */
|
2008-08-11 09:30:16 -07:00
|
|
|
typedef void** Eina_Array_Iterator;
|
|
|
|
|
2008-07-30 09:34:54 -07:00
|
|
|
struct _Eina_Array /** An array of data */
|
|
|
|
{
|
|
|
|
void **data; /**< Pointer to a vector of pointer to payload */
|
|
|
|
unsigned int total; /**< Total number of slot in the vector */
|
|
|
|
unsigned int count; /**< Number of activ slot in the vector */
|
|
|
|
unsigned int step; /**< How much must we grow the vector When it is full */
|
|
|
|
};
|
|
|
|
|
2008-08-08 07:20:11 -07:00
|
|
|
EAPI int eina_array_init (void);
|
|
|
|
EAPI int eina_array_shutdown (void);
|
|
|
|
|
|
|
|
EAPI Eina_Array * eina_array_new (unsigned int step);
|
|
|
|
EAPI void eina_array_setup (Eina_Array *array, unsigned int step);
|
|
|
|
EAPI void eina_array_free (Eina_Array *array);
|
|
|
|
EAPI void eina_array_clean (Eina_Array *array);
|
|
|
|
EAPI void eina_array_flush (Eina_Array *array);
|
|
|
|
EAPI void eina_array_remove (Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata), void *gdata);
|
|
|
|
|
2008-08-11 09:30:16 -07:00
|
|
|
EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array *array);
|
|
|
|
EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array);
|
2008-08-08 07:20:11 -07:00
|
|
|
|
2008-08-11 09:30:16 -07:00
|
|
|
static inline void * eina_array_get (const Eina_Array *array, unsigned int index);
|
2008-08-26 03:23:45 -07:00
|
|
|
static inline void eina_array_push (Eina_Array *array, const void *data);
|
|
|
|
static inline void * eina_array_pop (Eina_Array *array);
|
2008-08-11 09:30:16 -07:00
|
|
|
static inline unsigned int eina_array_count (const Eina_Array *array);
|
2008-08-08 07:20:11 -07:00
|
|
|
|
2008-08-11 09:30:16 -07:00
|
|
|
#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
|
|
|
|
for (index = 0, iterator = (array)->data, item = iterator != NULL ? *(iterator) : NULL; \
|
|
|
|
index < eina_array_count(array); \
|
|
|
|
++(index), item = *(++(iterator)))
|
2008-08-01 05:26:35 -07:00
|
|
|
|
|
|
|
#include "eina_inline_array.x"
|
|
|
|
|
2008-07-30 09:34:54 -07:00
|
|
|
#endif
|