Switch/ext/ebtree/ebtree.h
static inline struct eb_node *eb_next_unique(struct eb_node *node)
{
	eb_troot_t *t = node->leaf_p;

	while (1) {
		if (eb_gettag(t) == EB_LEFT) {
			if (unlikely(eb_clrtag((eb_untag(t, EB_LEFT))->b[EB_RGHT]) == NULL))
				return NULL;	/* we reached root */
			node = eb_root_to_node(eb_untag(t, EB_LEFT));
			/* if we're left and not in duplicates, stop here */
			if (node->bit >= 0)
				break;
			t = node->node_p;
		}
		else {
			/* Walking up from right branch, so we cannot be below root */
			t = (eb_root_to_node(eb_untag(t, EB_RGHT)))->node_p;
		}
	}

	/* Note that <t> cannot be NULL at this stage */
	t = (eb_untag(t, EB_LEFT))->b[EB_RGHT];
	if (eb_clrtag(t) == NULL)
		return NULL;
	return eb_walk_down(t, EB_LEFT);
}
/* Return next leaf node after an existing leaf node, skipping duplicates, or
 * NULL if none.
 */
Return next leaf node after an existing leaf node, skipping duplicates, or
NULL if none.
Return next leaf node after an existing leaf node skipping duplicates or NULL if none .
static inline struct eb_node *eb_next_unique(struct eb_node *node)
{
	eb_troot_t *t = node->leaf_p;
	while (1) {
		if (eb_gettag(t) == EB_LEFT) {
			if (unlikely(eb_clrtag((eb_untag(t, EB_LEFT))->b[EB_RGHT]) == NULL))
				return NULL;	
			node = eb_root_to_node(eb_untag(t, EB_LEFT));
			if (node->bit >= 0)
				break;
			t = node->node_p;
		}
		else {
			t = (eb_root_to_node(eb_untag(t, EB_RGHT)))->node_p;
		}
	}
	t = (eb_untag(t, EB_LEFT))->b[EB_RGHT];
	if (eb_clrtag(t) == NULL)
		return NULL;
	return eb_walk_down(t, EB_LEFT);
}
static inline struct eb_node * eb_next_unique ( struct eb_node * node ) { eb_troot_t * t = node -> leaf_p ; while ( 1 ) { if ( eb_gettag ( t ) == EB_LEFT ) { if ( unlikely ( eb_clrtag ( ( eb_untag ( t , EB_LEFT ) ) -> b [ EB_RGHT ] ) == NULL ) ) return NULL ; node = eb_root_to_node ( eb_untag ( t , EB_LEFT ) ) ; if ( node -> bit >= 0 ) break ; t = node -> node_p ; } else { t = ( eb_root_to_node ( eb_untag ( t , EB_RGHT ) ) ) -> node_p ; } } t = ( eb_untag ( t , EB_LEFT ) ) -> b [ EB_RGHT ] ; if ( eb_clrtag ( t ) == NULL ) return NULL ; return eb_walk_down ( t , EB_LEFT ) ; }
Return next leaf node after an existing leaf node, skipping duplicates, or
 NULL if none.
Return next leaf node after an existing leaf node skipping duplicates or NULL if none .
/* we reached root */ /* if we're left and not in duplicates, stop here */ /* Walking up from right branch, so we cannot be below root */ /* Note that <t> cannot be NULL at this stage */