RAVE
rave_list.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2009 Swedish Meteorological and Hydrological Institute, SMHI,
3
4This file is part of RAVE.
5
6RAVE is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11RAVE is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with RAVE. If not, see <http://www.gnu.org/licenses/>.
18------------------------------------------------------------------------*/
26#ifndef RAVE_LIST_H
27#define RAVE_LIST_H
28#include "rave_object.h"
29
33typedef struct _RaveList_t RaveList_t;
34
39
46int RaveList_add(RaveList_t* list, void* ob);
47
56int RaveList_insert(RaveList_t* list, int index, void* ob);
57
64
71void* RaveList_get(RaveList_t* list, int index);
72
79
86void* RaveList_remove(RaveList_t* list, int index);
87
94
101void RaveList_removeObject(RaveList_t* list, void* object);
102
114void* RaveList_find(RaveList_t* list, void* expected, int (*findfunc)(void*, void*));
115
125void RaveList_sort(RaveList_t* list, int (*sortfun)(const void*, const void*));
126
136
137#endif /* RAVE_LIST_H */
void * RaveList_removeLast(RaveList_t *list)
Removes the last item.
Definition rave_list.c:177
int RaveList_insert(RaveList_t *list, int index, void *ob)
Inserts the object at the specified index, if index < 0 or index > size, then this function will add ...
Definition rave_list.c:111
int RaveList_add(RaveList_t *list, void *ob)
Add one instance to the list.
Definition rave_list.c:105
int RaveList_size(RaveList_t *list)
Returns the number of items in this list.
Definition rave_list.c:137
void * RaveList_get(RaveList_t *list, int index)
Returns the item at the specified position.
Definition rave_list.c:143
void * RaveList_find(RaveList_t *list, void *expected, int(*findfunc)(void *, void *))
Finds the object in the list.
Definition rave_list.c:203
void * RaveList_remove(RaveList_t *list, int index)
Removes the item at the specified position and returns it.
Definition rave_list.c:161
RaveCoreObjectType RaveList_TYPE
Type definition to use when creating a rave object.
Definition rave_list.c:237
void * RaveList_getLast(RaveList_t *list)
Returns the item at the end.
Definition rave_list.c:152
void RaveList_sort(RaveList_t *list, int(*sortfun)(const void *, const void *))
Sorts the list according to the provided sort function.
Definition rave_list.c:218
void RaveList_removeObject(RaveList_t *list, void *object)
Removes the object that is equal to the provided object.
Definition rave_list.c:187
void RaveList_freeAndDestroy(RaveList_t **list)
This is a specialized version that can be used to destroy the list when it contains single pointers a...
Definition rave_list.c:224
Generic implementation of an object that is used within rave.
Represents a list.
Definition rave_list.c:36
RAVE_OBJECT_HEAD void ** list
Always on top.
Definition rave_list.c:38
The rave object type definition.
Definition rave_object.h:52