X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fsset.c;h=04039a7c496b487ab43d30dcec6bab469d886ee7;hb=refs%2Fheads%2Fmanual;hp=ee4224a4fc73c83724e1a4ce9afed200f1f415d1;hpb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;p=openvswitch diff --git a/lib/sset.c b/lib/sset.c index ee4224a4..04039a7c 100644 --- a/lib/sset.c +++ b/lib/sset.c @@ -251,3 +251,22 @@ sset_equals(const struct sset *a, const struct sset *b) return true; } + +/* Returns the next node in 'set' in hash order, or NULL if no nodes remain in + * 'set'. Uses '*bucketp' and '*offsetp' to determine where to begin + * iteration, and stores new values to pass on the next iteration into them + * before returning. + * + * It's better to use plain SSET_FOR_EACH and related functions, since they are + * faster and better at dealing with ssets that change during iteration. + * + * Before beginning iteration, store 0 into '*bucketp' and '*offsetp'. + */ +struct sset_node * +sset_at_position(const struct sset *set, uint32_t *bucketp, uint32_t *offsetp) +{ + struct hmap_node *hmap_node; + + hmap_node = hmap_at_position(&set->map, bucketp, offsetp); + return SSET_NODE_FROM_HMAP_NODE(hmap_node); +}