OSDN Git Service

(no commit message)
[ccunit/ccunit.git] / src / ccunit / CCUnitList.h
1 /* -*- mode: C; -*- */
2 /* Copyright (C) 2003 TSUTSUMI Kikuo.
3    This file is part of the CCUnit Library.
4
5    The CCUnit Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public License
7    as published by the Free Software Foundation; either version 2.1 of
8    the License, or (at your option) any later version.
9
10    The CCUnit Library is distributed in the hope that it will be
11    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the CCUnit Library; see the file COPYING.LESSER.
17    If not, write to the Free Software Foundation, Inc., 59 Temple
18    Place - Suite 330, Boston, MA 02111-1307, USA.  
19 */
20
21 /*
22  * $Id$
23  */
24
25 /**
26  * @file
27  * List class.
28  */
29 #ifndef CCUNITLIST_H
30 #define CCUNITLIST_H
31
32 #include <ccunit/CCUnitConfig.h>
33
34 #if STDC_HEADERS
35 #include <stdlib.h>
36 #endif
37 #include <stdbool.h>
38
39 typedef struct CCUnitList
40 {
41   struct CCUnitListCell* head;
42   struct CCUnitListCell** tailp;
43   size_t length;
44   bool isAllocated;
45 } CCUnitList;
46
47 typedef struct CCUnitListIterator
48 {
49   struct CCUnitListCell* current;
50   bool isAllocated;
51 } CCUnitListIterator;
52
53 extern inline CCUnitList* ccunit_newList ();
54 extern void ccunit_addList (CCUnitList* list, void* contents);
55 extern CCUnitList* ccunit_initList (CCUnitList* list);
56 extern void ccunit_deleteList (CCUnitList* list, void (*deleteContents)(void*));
57
58 extern CCUnitListIterator* ccunit_newListIterator (const struct CCUnitList* list);
59 extern inline
60 CCUnitListIterator* ccunit_initListIterator (const struct CCUnitList* list,
61                                              struct CCUnitListIterator* it);
62 extern inline void ccunit_deleteListIterator (struct CCUnitListIterator* it);
63 extern void* ccunit_nextListIterator (struct CCUnitListIterator* it);
64 extern bool ccunit_hasNextListIterator (struct CCUnitListIterator* it);
65
66 #endif
67