Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
7faa1f07
Commit
7faa1f07
authored
Jan 16, 2012
by
antirez
Browse files
added a comment on top of the zslRandomLevel() function
parent
06312eed
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/t_zset.c
View file @
7faa1f07
...
@@ -64,6 +64,10 @@ void zslFree(zskiplist *zsl) {
...
@@ -64,6 +64,10 @@ void zslFree(zskiplist *zsl) {
zfree
(
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
zslRandomLevel
(
void
)
{
int
level
=
1
;
int
level
=
1
;
while
((
random
()
&
0xFFFF
)
<
(
ZSKIPLIST_P
*
0xFFFF
))
while
((
random
()
&
0xFFFF
)
<
(
ZSKIPLIST_P
*
0xFFFF
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment