X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ensc_vector%2Fvector.h;fp=ensc_vector%2Fvector.h;h=b374176cf7fa6f6058989a5d7d33191005ef0b69;hb=8cf13bb177d92c93eb73dc8939777150536c2d00;hp=0000000000000000000000000000000000000000;hpb=6bf3f95de36c804c97716b2d0bdf10680c559044;p=util-vserver.git diff --git a/ensc_vector/vector.h b/ensc_vector/vector.h new file mode 100644 index 0000000..b374176 --- /dev/null +++ b/ensc_vector/vector.h @@ -0,0 +1,66 @@ +// $Id: vector.h,v 1.4 2005/07/03 09:12:31 ensc Exp $ --*- c++ -*-- + +// Copyright (C) 2002,2004 Enrico Scholz +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// + +#ifndef H_UTILVSERVER_VECTOR_VECTOR_H +#define H_UTILVSERVER_VECTOR_VECTOR_H + +#include + +struct Vector +{ + void *data; + size_t count; + size_t allocated; + + size_t elem_size; +}; + +typedef enum { vecMOVE_FRONT, vecSHIFT_ONCE } VectorSelfOrgMethod; + +void Vector_init(struct Vector *, size_t elem_size); +void Vector_free(struct Vector *); +void * Vector_search(struct Vector *, void const *key, int (*compar)(const void *, const void *)); +void * Vector_searchSelfOrg(struct Vector *, void const *key, + int (*compar)(const void *, const void *), + VectorSelfOrgMethod method); +void Vector_sort(struct Vector *, int (*compar)(const void *, const void *)); +void Vector_unique(struct Vector *, int (*compar)(const void *, const void *)); +void * Vector_pushback(struct Vector *); +void * Vector_insert(struct Vector *, void const *key, int (*compar)(const void *, const void *)); +void Vector_popback(struct Vector *); +void Vector_resize(struct Vector *vec); +void Vector_clear(struct Vector *vec); +void Vector_zeroEnd(struct Vector *vec); +void Vector_foreach(struct Vector *vec, void (*func)(void *, void *), void *); + +static void Vector_foreach_const(struct Vector const *vec, + void (*func)(void const *, void *), + void *); +static void const * Vector_searchSelfOrg_const(struct Vector const *, void const *key, + int (*compar)(const void *, const void *), + VectorSelfOrgMethod method); +static void const * Vector_search_const(struct Vector const *, void const *key, int (*compar)(const void *, const void *)); +static void * Vector_begin(struct Vector *); +static void * Vector_end(struct Vector *); +static void const * Vector_begin_const(struct Vector const *); +static void const * Vector_end_const(struct Vector const *); +static size_t Vector_count(struct Vector const *vec); + +#include "vector.hc" + +#endif // H_UTILVSERVER_VECTOR_VECTOR_H