2 /* Copyright (C) 2003 TSUTSUMI Kikuo.
3 This file is part of the CCUnit Library.
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.
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.
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.
32 #include <ccunit/CCUnitConfig.h>
35 * @ingroup ModuleHierarchy
36 * @defgroup CCUnitList List
37 * Linked list container.
44 typedef struct CCUnitList
46 struct CCUnitListCell* head; /**< first cell of a linked list */
47 struct CCUnitListCell** tailp; /**< address of pointer to last cell*/
48 size_t length; /**< size of linked list */
49 bool isAllocated; /**< flag of allocated object */
53 * Create new list object.
54 * @return new list object.
56 extern inline CCUnitList* ccunit_newList ();
59 * Add element to list object.
60 * @param list List object.
61 * @param contents A pointer to an object to register in the list.
63 extern void ccunit_addList (CCUnitList* list, void* contents);
66 * Initialize list object.
67 * @param list initializing list.
68 * @return initialized list.
70 extern CCUnitList* ccunit_initList (CCUnitList* list);
75 * @param list Deleting list.
76 * @param deleteContents A pointer to the function which the object
77 * registered in the list is deleted from.
79 extern void ccunit_deleteList (CCUnitList* list, void (*deleteContents)(void*));
82 * @defgroup CCUnitListIterator ListIterator
90 typedef struct CCUnitListIterator
92 struct CCUnitListCell* current; /**< current list cell */
93 bool isAllocated; /**< flag of allocated object */
97 * create new list iterator.
99 * @param list An owner list of iterator.
100 * @return New iterator.
102 extern CCUnitListIterator* ccunit_newListIterator (const struct CCUnitList* list);
105 * initialize list iterator.
106 * @param list An owner list of iterator.
107 * @param it Iterator to initialize.
108 * @return Initialized iterator.
111 CCUnitListIterator* ccunit_initListIterator (const struct CCUnitList* list,
112 struct CCUnitListIterator* it);
115 * delete list iterator.
117 * @param it iterator to delete.
119 extern inline void ccunit_deleteListIterator (struct CCUnitListIterator* it);
123 * @param it An Iterator.
124 * @return pointer to next element object.
126 extern void* ccunit_nextListIterator (struct CCUnitListIterator* it);
129 * Check is there next element of iterator.
130 * @param it An iterator.
131 * @return true if there is next element, or false.
133 extern bool ccunit_hasNextListIterator (struct CCUnitListIterator* it);
136 * end group CCUnitListIterator
140 * end group CCUnitList