Coder Social home page Coder Social logo

crossbeam-skiplist's People

Contributors

amanieu avatar bcko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crossbeam-skiplist's Issues

Support for no_std

As a first step, I'm thinking we should publicly expose base::SkipList and present it as the 'advanced' skip list implementation targeted at expert users who want to use the skip list in no_std, control garbage collection more precisely, pass Guards to methods, squeeze out every ounce of performance, and so on.

Secondly, in no_std we don't have access to epoch::pin() so one should use Handle::pin() instead and pass a guard to methods that work with the SkipList.

When passing a guard to a skip list method, we must make sure that the guard belongs to the same Collector the skip list is using. In other words, every method taking a &Guard should have a check at the beginning like in the following snippet:

fn insert(&self, key: K, value: V, guard: &Guard) {
    assert!(
        self.collector == guard.collector(),
        "the guard doesn't belong to this collector used by this skip list",
    );

    // ...
}

In order to be able to make such checks, we'll have to first implement fn Guard::collector(&self) -> &Collector in crossbeam-epoch.

In addition to that, SkipList would probably need a similar method returning a reference to its own Collector.

With such an interface, I envision the skip list might be used like this:

let s = SkipList::new();
let handle = s.collector().handle();

let guard = &handle.pin();
s.insert("foo", 42, guard);

@Amanieu What do you think about all this - would this interface work for you? Any better ideas for supporting no_std?

Range search API

A more general alternative to the existing search function.

#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum Bound<T> {
    /// An inclusive bound.
    Included(T),
    /// An exclusive bound.
    Excluded(T),
    /// An infinite endpoint. Indicates that there is no bound in this direction.
    Unbounded,
}

impl<K, V> SkipMap<K, V>
where
    K: Ord,
{
    /// Returns an `Entry` pointing to the lowest element whose key is above
    /// the given bound. If no such element is found then `None` is
    /// returned.
    pub fn lower_bound<Q>(&self, bound: Bound<&Q>) -> Option<Entry<K, V>>
    where
        K: Borrow<Q>,
        Q: Ord + ?Sized,
    {}

    /// Returns an `Entry` pointing to the highest element whose key is below
    /// the given bound. If no such element is found then `None` is
    /// returned.
    pub fn upper_bound<Q>(&self, bound: Bound<&Q>) -> Option<Entry<K, V>>
    where
        K: Borrow<Q>,
        Q: Ord + ?Sized,
    {}
}

Rename Entry to Cursor?

One of the questions raised in the RFC discussion was whether we should rename Entry to Cursor (suggested by @Amanieu).

I'm slightly leaning towards Entry, but don't feel strongly about it. Any other opinions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.