base/list/m_llist.c
/*! The number of levels a node should appear in. */
The number of levels a node should appear in.
The number of levels a node should appear in .
static size_t M_llist_node_calc_level(M_llist_t *d)
{
	M_uint64 r     = 0;
	M_bool   found = M_FALSE;
	size_t   level = 1;
	size_t   new_max_level;
	new_max_level = M_MIN(d->head.sorted.levels+1, M_llist_max_level(d));
	for (level=0; !found; level++) {
		if (r == 0) {
			r = M_rand(d->head.sorted.rand_state);
		}
		found = (r%2)==0?M_FALSE:M_TRUE;
		r     = r / 2;
	}
	if (level > new_max_level)
		level = new_max_level;
	return level;
}
static size_t M_llist_node_calc_level ( M_llist_t * d ) { M_uint64 r = 0 ; M_bool found = M_FALSE ; size_t level = 1 ; size_t new_max_level ; new_max_level = M_MIN ( d -> head . sorted . levels + 1 , M_llist_max_level ( d ) ) ; for ( level = 0 ; ! found ; level ++ ) { if ( r == 0 ) { r = M_rand ( d -> head . sorted . rand_state ) ; } found = ( r % 2 ) == 0 ? M_FALSE : M_TRUE ; r = r / 2 ; } if ( level > new_max_level ) level = new_max_level ; return level ; }
The number of levels a node should appear in.
The number of levels a node should appear in .