Skip to content

Instantly share code, notes, and snippets.

@antirez
Last active November 13, 2017 23:40
Show Gist options
  • Save antirez/e3d1d761942dfc99e57d813688d1dc7c to your computer and use it in GitHub Desktop.
Save antirez/e3d1d761942dfc99e57d813688d1dc7c to your computer and use it in GitHub Desktop.
void somefunc(rax *mytree) {
raxIterator iter;
raxStart(&iter,mytree);
/* As seek operator you can use >, <, >=, <=, == */
raxSeek(&iter,(unsigned char*)"chromo",6,"<="); /* Seek key <= "chromo" */
while(raxNext(&iter,NULL,0,NULL)) { /* or raxPrev() */
printf("Current key: %.*s, val %p\n",
(int)iter.key_len, (char*)iter.key, iter.data);
}
/* ... More complex example ... */
raxSeek(&iter,(unsigned char*)"foo",3,">"); /* Seek key > "foo" */
while(raxNext(&iter,"zap",3,"<=")) { /* Return elements up to "zap" */
printf("Current key: %.*s, val %p\n",
(int)iter.key_len, (char*)iter.key, iter.data);
}
raxStop(&iter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment