-
Notifications
You must be signed in to change notification settings - Fork 43
🚧Immaturable skip list implement. #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great! Just need to be more ergonomic As a library user, the default constraint is way too limited. Also, the code could be more idiomatic, Rust provides lots of handy feature you can use without hardcoded or explicitly denoting.
In addition, have you ever tried implementing this with Rc? I think it might work to avoid any single line of unsafe Rust.
* up/master: (23 commits) fix: deque API doc link fix: non_fmt_panic warning doc: update collection description refactor: move deque into collections fix: api doc for deque doc: deque refactor(deque): polish doc refactor(deque): rename try_resize -> try_grow fix(deque): correct layout size to dealloc fix(deque): handel_alloc_error refactor(deque): polish API documentation refactor(deque): remove inline for simplification refactor(deque): move is_full next to private fn test(deque): complext heap allocation elements feat(deque): support zero-sized types feat(deque): Drop refactor(deque): move RawVec next to impl block fix: rustfmt fix(deque): panic on zero-sized allocation feat(deque): Debug ...
|
@weihanglo Thank you very much for taking the time to review my code, 😃 and I'm sorry for my poor simple mistakes. whereas, I have tried the implement the skiplist with struct SkipNode<K, V> {
entry: Entry<K, V>,
next_by_height: [Option<Rc<RefCell<SkipNode>>>; MAX_HEIGHT],
}
impl<K, V> SkipNode<K, V> {
pub fn iter() -> Iter<K, V> {
...//omittied
}
}
pub struct Iter<'a, K, V>
{
ptr: Option<Rc<RefCell<SkipNode<K, V>>>, // 1
_marker: marker::PhantomData<&'a K>,
}
impl<'a, K, V: 'a> Iterator for Iter<'a, K, V>
{
type Item = std::cell::Ref('a, (K, V)); //2
fn next(&mut self) -> Option<Self::Item> {
self.ptr.map(|node| node.as_ref().borrow()); //3
}
}Because the RefCell holds the SkipNode, and the |
Some basic fn, some test cases but document hasn't been written.
I'm not confident about the code. could you take a review 🔖 😄?