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

crossbeam-skiplist: allows lookup to be customized. #1132

Merged
merged 13 commits into from
Dec 9, 2024
Prev Previous commit
Next Next commit
Optimize trait bounds
al8n committed Oct 10, 2024

Verified

This commit was signed with the committer’s verified signature.
al8n Al Liu
commit f76247b0c78153778af2dcb5997276c279c34966
2 changes: 1 addition & 1 deletion crossbeam-skiplist/Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ name = "crossbeam-skiplist"
# - Update CHANGELOG.md
# - Update README.md (when increasing major or minor version)
# - Run './tools/publish.sh crossbeam-skiplist <version>'
version = "0.1.3"
version = "0.1.4"
taiki-e marked this conversation as resolved.
Show resolved Hide resolved
edition = "2021"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
33 changes: 18 additions & 15 deletions crossbeam-skiplist/src/base.rs
Original file line number Diff line number Diff line change
@@ -1903,7 +1903,6 @@ where
/// An iterator over reference-counted subset of entries of a `SkipList`.
pub struct RefRange<'a, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
{
@@ -1916,23 +1915,21 @@ where

unsafe impl<Q, R, K, V> Send for RefRange<'_, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
{
}

unsafe impl<Q, R, K, V> Sync for RefRange<'_, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
{
}

impl<Q, R, K, V> fmt::Debug for RefRange<'_, Q, R, K, V>
where
K: Ord + fmt::Debug,
K: fmt::Debug,
V: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<K>,
@@ -1946,6 +1943,23 @@ where
}
}

impl<'a, Q, R, K: 'a, V: 'a> RefRange<'a, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
{
/// Decrements a reference count owned by this iterator.
pub fn drop_impl(&mut self, guard: &Guard) {
self.parent.check_guard(guard);
if let Some(e) = self.head.take() {
unsafe { e.node.decrement(guard) };
}
if let Some(e) = self.tail.take() {
unsafe { e.node.decrement(guard) };
}
}
}

impl<'a, Q, R, K: 'a, V: 'a> RefRange<'a, Q, R, K, V>
where
K: Ord,
@@ -2031,17 +2045,6 @@ where
None
}
}

/// Decrements a reference count owned by this iterator.
pub fn drop_impl(&mut self, guard: &Guard) {
self.parent.check_guard(guard);
if let Some(e) = self.head.take() {
unsafe { e.node.decrement(guard) };
}
if let Some(e) = self.tail.take() {
unsafe { e.node.decrement(guard) };
}
}
}

/// An owning iterator over the entries of a `SkipList`.
4 changes: 1 addition & 3 deletions crossbeam-skiplist/src/map.rs
Original file line number Diff line number Diff line change
@@ -715,7 +715,6 @@ impl<K, V> Drop for Iter<'_, K, V> {
/// An iterator over a subset of entries of a `SkipMap`.
pub struct Range<'a, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
{
@@ -750,7 +749,7 @@ where

impl<Q, R, K, V> fmt::Debug for Range<'_, Q, R, K, V>
where
K: Ord + fmt::Debug,
K: fmt::Debug,
V: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<K>,
@@ -766,7 +765,6 @@ where

impl<Q, R, K, V> Drop for Range<'_, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
{
3 changes: 1 addition & 2 deletions crossbeam-skiplist/src/set.rs
Original file line number Diff line number Diff line change
@@ -577,7 +577,6 @@ impl<T> fmt::Debug for Iter<'_, T> {
/// An iterator over a subset of entries of a `SkipSet`.
pub struct Range<'a, Q, R, T>
where
T: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<T>,
{
@@ -610,7 +609,7 @@ where

impl<Q, R, T> fmt::Debug for Range<'_, Q, R, T>
where
T: Ord + fmt::Debug,
T: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<T>,
{