debuggers.hg

view tools/blktap2/drivers/hashtable_itr.h @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 01a941f2c9f5
children
line source
1 /* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
3 #ifndef __HASHTABLE_ITR_CWC22__
4 #define __HASHTABLE_ITR_CWC22__
5 #include "hashtable.h"
6 #include "hashtable_private.h" /* needed to enable inlining */
8 struct hashtable_itr;
10 /*****************************************************************************/
11 /* hashtable_iterator
12 */
14 struct hashtable_itr *
15 hashtable_iterator(struct hashtable *h);
17 /*****************************************************************************/
18 /* hashtable_iterator_key
19 * - return the value of the (key,value) pair at the current position */
21 void *
22 hashtable_iterator_key(struct hashtable_itr *i);
24 /*****************************************************************************/
25 /* value - return the value of the (key,value) pair at the current position */
27 void *
28 hashtable_iterator_value(struct hashtable_itr *i);
30 /*****************************************************************************/
31 /* advance - advance the iterator to the next element
32 * returns zero if advanced to end of table */
34 int
35 hashtable_iterator_advance(struct hashtable_itr *itr);
37 /*****************************************************************************/
38 /* remove - remove current element and advance the iterator to the next element
39 * NB: if you need the value to free it, read it before
40 * removing. ie: beware memory leaks!
41 * returns zero if advanced to end of table */
43 int
44 hashtable_iterator_remove(struct hashtable_itr *itr);
46 /*****************************************************************************/
47 /* search - overwrite the supplied iterator, to point to the entry
48 * matching the supplied key.
49 h points to the hashtable to be searched.
50 * returns zero if not found. */
51 int
52 hashtable_iterator_search(struct hashtable_itr *itr,
53 struct hashtable *h, void *k);
55 #define DEFINE_HASHTABLE_ITERATOR_SEARCH(fnname, keytype) \
56 int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \
57 { \
58 return (hashtable_iterator_search(i,h,k)); \
59 }
63 #endif /* __HASHTABLE_ITR_CWC22__*/
65 /*
66 * Copyright (c) 2002, 2004, Christopher Clark
67 * All rights reserved.
68 *
69 * Redistribution and use in source and binary forms, with or without
70 * modification, are permitted provided that the following conditions
71 * are met:
72 *
73 * * Redistributions of source code must retain the above copyright
74 * notice, this list of conditions and the following disclaimer.
75 *
76 * * Redistributions in binary form must reproduce the above copyright
77 * notice, this list of conditions and the following disclaimer in the
78 * documentation and/or other materials provided with the distribution.
79 *
80 * * Neither the name of the original author; nor the names of any contributors
81 * may be used to endorse or promote products derived from this software
82 * without specific prior written permission.
83 *
84 *
85 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
86 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
87 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
88 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
89 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
91 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
92 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
93 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
94 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
95 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */