Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何找到大于 score 的第一个 element? #14

Closed
someblue opened this issue Sep 22, 2021 · 3 comments
Closed

请问如何找到大于 score 的第一个 element? #14

someblue opened this issue Sep 22, 2021 · 3 comments

Comments

@someblue
Copy link

我想实现一个类似于 redis 的 ZRANGEBYSCORE key min max 的功能,找出 score 位于 [min, max] 的 elements,查看 API 文档好像没有找到相关的 API,请问是否有理解错误?

@huandu
Copy link
Owner

huandu commented Sep 22, 2021

暂时没有封装查询类的接口,确实有点不太方便,或许应该封装一下。如果需要查找,假设当前 skip list 是升序排列,那么从 Front 开始,从最上面一个 level 开始寻找 Element 的 value,找到第一个比 min 小的 level,然后访问 next element 并重复这个过程。

要不我抽空实现一个吧,感觉确实是个缺憾。之前只实现了 kv 访问,并没有实现完整的功能。

someblue pushed a commit to someblue/skiplist that referenced this issue Sep 22, 2021
Change-Id: Iac0725a351c0efb24319a95e39d4fbf5e329d6a3
@someblue
Copy link
Author

@huandu 我刚刚实现了一个 FindFirstElementGreaterOrEqualToKey 的接口,有空请麻烦看看哈,感谢作者~ #15

@huandu
Copy link
Owner

huandu commented Sep 23, 2021

我在 PR 上进行了 review,非常感谢提交这些代码呀,设计方面的问题我们可在这个 issue 里面讨论~

someblue pushed a commit to someblue/skiplist that referenced this issue Sep 23, 2021
Change-Id: Id2b9a018b2700133fbd5186f60a03c45fd18d80d
someblue pushed a commit to someblue/skiplist that referenced this issue Sep 23, 2021
Change-Id: Id2b9a018b2700133fbd5186f60a03c45fd18d80d
@huandu huandu closed this as completed in 1b870b1 Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants