Debian Codegraph @

src/basic/iterator.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "basic-forward.h"
5
6 /* Ideally the Iterator would be an opaque struct, but it is instantiated
7 * by hashmap users, so the definition has to be here. Do not use its fields
8 * directly. */
9 typedef struct Iterator {
10 const void *next_key; /* expected value of that entry's key pointer */
11 unsigned idx; /* index of an entry to be iterated next */
12 #if ENABLE_DEBUG_HASHMAP
13 unsigned put_count; /* hashmap's put_count recorded at start of iteration */
14 unsigned rem_count; /* hashmap's rem_count in previous iteration */
15 unsigned prev_idx; /* idx in previous iteration */
16 #endif
17 } Iterator;
18
19 #define _IDX_ITERATOR_FIRST (UINT_MAX - 1)
20 #define ITERATOR_FIRST ((Iterator) { .idx = _IDX_ITERATOR_FIRST, .next_key = NULL })
21 #define ITERATOR_IS_FIRST(i) ((i).idx == _IDX_ITERATOR_FIRST)