61 sp->
seed = 0xdeaddabe;
77 int level, comp_result;
95 _vec_len (sp->
path) = level + 1;
99 u32 next_index_this_level;
106 prefetch_elt = sp->
elts +
112 comp_result = (search_elt == head_elt) ? 1 :
137 if (comp_result == 0)
144 if (need_full_path && level > 0)
151 sp->
path[level] = search_elt - sp->
elts;
152 _vec_len (sp->
path) = level + 1;
159 sp->
path[level] = search_elt - sp->
elts;
162 next_index_this_level =
164 if (next_index_this_level == (
u32) ~ 0)
214 for (level = 0; level <
vec_len (sp->
path); level++)
217 u32 prev_elt_next_index_this_level;
222 (prev_elt_this_level, level);
259 return search_result;
264 for (level = 0; level <
vec_len (sp->
path) - 1; level++)
267 u32 path_elt_next_index;
273 if (path_elt_next_index == del_elt - sp->
elts)
282 if (!(del_elt->
n.
next0[0] & 1))
292 int verbose = va_arg (*args,
int);
296 s =
format (s,
"slist 0x%x, %u items, branching_factor %.2f\n", sl,
306 s =
format (s,
"level %d: %d elts\n", i,
309 if (verbose && head_elt->
n.
nexts[i] != (
u32) ~ 0)
318 ASSERT (next_index != 0x7fffffff);
319 if (next_index == (
u32) ~ 0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
clib_error_t * clib_slist_init(clib_slist_t *sp, f64 branching_factor, clib_slist_key_compare_function_t compare, format_function_t format_user_element)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
word() clib_slist_key_compare_function_t(void *key, u32 elt_pool_index)
clib_slist_key_compare_function_t * compare
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
clib_slist_search_result_t
static u32 clib_slist_get_next_at_level(clib_slist_elt_t *elt, int level)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define pool_put(P, E)
Free an object E in pool P.
static clib_slist_search_result_t slist_search_internal(clib_slist_t *sp, void *key, int need_full_path)
format_function_t * format_user_element
#define CLIB_PREFETCH(addr, size, type)
u8 * format_slist(u8 *s, va_list *args)
#define vec_free(V)
Free vector's memory (no header).
void clib_slist_add(clib_slist_t *sp, void *key, u32 user_pool_index)
static void clib_slist_set_next_at_level(clib_slist_elt_t *elt, u32 index, int level)
u32 clib_slist_search(clib_slist_t *sp, void *key, u32 *ncompares)
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
union clib_slist_elt_t::@23 n
clib_slist_search_result_t clib_slist_del(clib_slist_t *sp, void *key)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define CLIB_CACHE_LINE_BYTES
static uword pool_elts(void *v)
Number of active elements in a pool.