Merge branch 'sg/travis-fixes'
[git.git] / iterator.h
blob0f6900e43ad68b6c06d46ea50f86d94487b94a1a
1 #ifndef ITERATOR_H
2 #define ITERATOR_H
4 /*
5 * Generic constants related to iterators.
6 */
8 /*
9 * The attempt to advance the iterator was successful; the iterator
10 * reflects the new current entry.
12 #define ITER_OK 0
15 * The iterator is exhausted and has been freed.
17 #define ITER_DONE -1
20 * The iterator experienced an error. The iteration has been aborted
21 * and the iterator has been freed.
23 #define ITER_ERROR -2
26 * Return values for selector functions for merge iterators. The
27 * numerical values of these constants are important and must be
28 * compatible with ITER_DONE and ITER_ERROR.
30 enum iterator_selection {
31 /* End the iteration without an error: */
32 ITER_SELECT_DONE = ITER_DONE,
34 /* Report an error and abort the iteration: */
35 ITER_SELECT_ERROR = ITER_ERROR,
38 * The next group of constants are masks that are useful
39 * mainly internally.
42 /* The LSB selects whether iter0/iter1 is the "current" iterator: */
43 ITER_CURRENT_SELECTION_MASK = 0x01,
45 /* iter0 is the "current" iterator this round: */
46 ITER_CURRENT_SELECTION_0 = 0x00,
48 /* iter1 is the "current" iterator this round: */
49 ITER_CURRENT_SELECTION_1 = 0x01,
51 /* Yield the value from the current iterator? */
52 ITER_YIELD_CURRENT = 0x02,
54 /* Discard the value from the secondary iterator? */
55 ITER_SKIP_SECONDARY = 0x04,
58 * The constants that a selector function should usually
59 * return.
62 /* Yield the value from iter0: */
63 ITER_SELECT_0 = ITER_CURRENT_SELECTION_0 | ITER_YIELD_CURRENT,
65 /* Yield the value from iter0 and discard the one from iter1: */
66 ITER_SELECT_0_SKIP_1 = ITER_SELECT_0 | ITER_SKIP_SECONDARY,
68 /* Discard the value from iter0 without yielding anything this round: */
69 ITER_SKIP_0 = ITER_CURRENT_SELECTION_1 | ITER_SKIP_SECONDARY,
71 /* Yield the value from iter1: */
72 ITER_SELECT_1 = ITER_CURRENT_SELECTION_1 | ITER_YIELD_CURRENT,
74 /* Yield the value from iter1 and discard the one from iter0: */
75 ITER_SELECT_1_SKIP_0 = ITER_SELECT_1 | ITER_SKIP_SECONDARY,
77 /* Discard the value from iter1 without yielding anything this round: */
78 ITER_SKIP_1 = ITER_CURRENT_SELECTION_0 | ITER_SKIP_SECONDARY
81 #endif /* ITERATOR_H */