added Vector_zeroEnd() function
[util-vserver.git] / util-vserver / ensc_vector / vector.h
1 // $Id$    --*- c++ -*--
2
3 // Copyright (C) 2002,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //  
18
19 #ifndef H_UTILVSERVER_VECTOR_VECTOR_H
20 #define H_UTILVSERVER_VECTOR_VECTOR_H
21
22 #include <stdlib.h>
23
24 struct Vector
25 {
26     void        *data;
27     size_t      count;
28     size_t      allocated;
29
30     size_t      elem_size;
31 };
32
33 void    Vector_init(struct Vector *, size_t elem_size);
34 void    Vector_free(struct Vector *);
35 void *  Vector_search(struct Vector *, void const *key, int (*compar)(const void *, const void *));
36 void    Vector_sort(struct Vector *, int (*compar)(const void *, const void *));
37 void    Vector_unique(struct Vector *, int (*compar)(const void *, const void *));
38 void *  Vector_pushback(struct Vector *);
39 void *  Vector_insert(struct Vector *, void const *key, int (*compar)(const void *, const void *));
40 void    Vector_popback(struct Vector *);
41 void    Vector_resize(struct Vector *vec);
42 void    Vector_clear(struct Vector *vec);
43 void    Vector_zeroEnd(struct Vector *vec);
44 static void const *     Vector_search_const(struct Vector const *, void const *key, int (*compar)(const void *, const void *));
45 static void *           Vector_begin(struct Vector *);
46 static void *           Vector_end(struct Vector *);
47 static void const *     Vector_begin_const(struct Vector const *);
48 static void const *     Vector_end_const(struct Vector const *);
49 static size_t           Vector_count(struct Vector const *vec);
50
51 #include "vector.hc"
52
53 #endif  //  H_UTILVSERVER_VECTOR_VECTOR_H