From 7faa1f075b14882696af22d0613255018416ac92 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 16 Jan 2012 09:39:04 +0100 Subject: [PATCH] added a comment on top of the zslRandomLevel() function --- src/t_zset.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/t_zset.c b/src/t_zset.c index fe65bf75..d2535c72 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -64,6 +64,10 @@ void zslFree(zskiplist *zsl) { zfree(zsl); } +/* Returns a random level for the new skiplist node we are going to create. + * The return value of this function is between 1 and ZSKIPLIST_MAXLEVEL + * (both inclusive), with a powerlaw-alike distribution where higher + * levels are less likely to be returned. */ int zslRandomLevel(void) { int level = 1; while ((random()&0xFFFF) < (ZSKIPLIST_P * 0xFFFF)) -- 2.47.2