Skip to content

Commit

Permalink
Remove Ord bounds for Q
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Oct 14, 2024
1 parent f76247b commit 26ab5c3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
42 changes: 21 additions & 21 deletions crossbeam-skiplist/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,15 @@ where
/// Returns `true` if the map contains a value for the specified key.
pub fn contains_key<Q>(&self, key: &Q, guard: &Guard) -> bool
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
self.get(key, guard).is_some()
}

/// Returns an entry with the specified `key`.
pub fn get<'a: 'g, 'g, Q>(&'a self, key: &Q, guard: &'g Guard) -> Option<Entry<'a, 'g, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
self.check_guard(guard);
let n = self.search_bound(Bound::Included(key), false, guard)?;
Expand All @@ -441,7 +441,7 @@ where
guard: &'g Guard,
) -> Option<Entry<'a, 'g, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
self.check_guard(guard);
let n = self.search_bound(bound, false, guard)?;
Expand All @@ -461,7 +461,7 @@ where
guard: &'g Guard,
) -> Option<Entry<'a, 'g, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
self.check_guard(guard);
let n = self.search_bound(bound, true, guard)?;
Expand Down Expand Up @@ -521,7 +521,7 @@ where
where
K: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
self.check_guard(guard);
Range {
Expand All @@ -539,7 +539,7 @@ where
pub fn ref_range<'a, Q, R>(&'a self, range: R) -> RefRange<'a, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
RefRange {
parent: self,
Expand Down Expand Up @@ -681,7 +681,7 @@ where
guard: &'a Guard,
) -> Option<&'a Node<K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
unsafe {
'search: loop {
Expand Down Expand Up @@ -762,7 +762,7 @@ where
/// Searches for a key in the skip list and returns a list of all adjacent nodes.
fn search_position<'a, Q>(&'a self, key: &Q, guard: &'a Guard) -> Position<'a, K, V>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
unsafe {
'search: loop {
Expand Down Expand Up @@ -1095,7 +1095,7 @@ where
/// Removes an entry with the specified `key` from the map and returns it.
pub fn remove<Q>(&self, key: &Q, guard: &Guard) -> Option<RefEntry<'_, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
self.check_guard(guard);

Expand Down Expand Up @@ -1790,7 +1790,7 @@ pub struct Range<'a: 'g, 'g, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
parent: &'a SkipList<K, V>,
head: Option<&'g Node<K, V>>,
Expand All @@ -1804,7 +1804,7 @@ impl<'a: 'g, 'g, Q, R, K: 'a, V: 'a> Iterator for Range<'a, 'g, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
type Item = Entry<'a, 'g, K, V>;

Expand Down Expand Up @@ -1847,7 +1847,7 @@ impl<'a: 'g, 'g, Q, R, K: 'a, V: 'a> DoubleEndedIterator for Range<'a, 'g, Q, R,
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
fn next_back(&mut self) -> Option<Entry<'a, 'g, K, V>> {
self.tail = match self.tail {
Expand Down Expand Up @@ -1889,7 +1889,7 @@ where
K: Ord + fmt::Debug,
V: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Range")
Expand All @@ -1904,7 +1904,7 @@ where
pub struct RefRange<'a, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
parent: &'a SkipList<K, V>,
pub(crate) head: Option<RefEntry<'a, K, V>>,
Expand All @@ -1916,14 +1916,14 @@ where
unsafe impl<Q, R, K, V> Send for RefRange<'_, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
}

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

Expand All @@ -1932,7 +1932,7 @@ where
K: fmt::Debug,
V: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RefRange")
Expand All @@ -1946,7 +1946,7 @@ where
impl<'a, Q, R, K: 'a, V: 'a> RefRange<'a, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
/// Decrements a reference count owned by this iterator.
pub fn drop_impl(&mut self, guard: &Guard) {
Expand All @@ -1964,7 +1964,7 @@ impl<'a, Q, R, K: 'a, V: 'a> RefRange<'a, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
/// Advances the iterator and returns the next value.
pub fn next(&mut self, guard: &Guard) -> Option<RefEntry<'a, K, V>> {
Expand Down Expand Up @@ -2129,7 +2129,7 @@ where
}

/// Helper function to check if a value is above a lower bound
fn above_lower_bound<V, T: Ord + ?Sized + Comparable<V>>(bound: &Bound<&T>, other: &V) -> bool {
fn above_lower_bound<V, T: ?Sized + Comparable<V>>(bound: &Bound<&T>, other: &V) -> bool {
match *bound {
Bound::Unbounded => true,
Bound::Included(key) => key.compare(other).is_le(),
Expand All @@ -2138,7 +2138,7 @@ fn above_lower_bound<V, T: Ord + ?Sized + Comparable<V>>(bound: &Bound<&T>, othe
}

/// Helper function to check if a value is below an upper bound
fn below_upper_bound<V, T: Ord + ?Sized + Comparable<V>>(bound: &Bound<&T>, other: &V) -> bool {
fn below_upper_bound<V, T: ?Sized + Comparable<V>>(bound: &Bound<&T>, other: &V) -> bool {
match *bound {
Bound::Unbounded => true,
Bound::Included(key) => key.compare(other).is_ge(),
Expand Down
22 changes: 11 additions & 11 deletions crossbeam-skiplist/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ where
/// ```
pub fn contains_key<Q>(&self, key: &Q) -> bool
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
let guard = &epoch::pin();
self.inner.contains_key(key, guard)
Expand All @@ -156,7 +156,7 @@ where
/// ```
pub fn get<Q>(&self, key: &Q) -> Option<Entry<'_, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
let guard = &epoch::pin();
try_pin_loop(|| self.inner.get(key, guard)).map(Entry::new)
Expand Down Expand Up @@ -190,7 +190,7 @@ where
/// ```
pub fn lower_bound<'a, Q>(&'a self, bound: Bound<&Q>) -> Option<Entry<'a, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
let guard = &epoch::pin();
try_pin_loop(|| self.inner.lower_bound(bound, guard)).map(Entry::new)
Expand Down Expand Up @@ -221,7 +221,7 @@ where
/// ```
pub fn upper_bound<'a, Q>(&'a self, bound: Bound<&Q>) -> Option<Entry<'a, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
let guard = &epoch::pin();
try_pin_loop(|| self.inner.upper_bound(bound, guard)).map(Entry::new)
Expand Down Expand Up @@ -334,7 +334,7 @@ where
pub fn range<Q, R>(&self, range: R) -> Range<'_, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
Range {
inner: self.inner.ref_range(range),
Expand Down Expand Up @@ -419,7 +419,7 @@ where
/// ```
pub fn remove<Q>(&self, key: &Q) -> Option<Entry<'_, K, V>>
where
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
let guard = &epoch::pin();
self.inner.remove(key, guard).map(Entry::new)
Expand Down Expand Up @@ -716,7 +716,7 @@ impl<K, V> Drop for Iter<'_, K, V> {
pub struct Range<'a, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
pub(crate) inner: base::RefRange<'a, Q, R, K, V>,
}
Expand All @@ -725,7 +725,7 @@ impl<'a, Q, R, K, V> Iterator for Range<'a, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
type Item = Entry<'a, K, V>;

Expand All @@ -739,7 +739,7 @@ impl<'a, Q, R, K, V> DoubleEndedIterator for Range<'a, Q, R, K, V>
where
K: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
fn next_back(&mut self) -> Option<Entry<'a, K, V>> {
let guard = &epoch::pin();
Expand All @@ -752,7 +752,7 @@ where
K: fmt::Debug,
V: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Range")
Expand All @@ -766,7 +766,7 @@ where
impl<Q, R, K, V> Drop for Range<'_, Q, R, K, V>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<K>,
Q: ?Sized + Comparable<K>,
{
fn drop(&mut self) {
let guard = &epoch::pin();
Expand Down
20 changes: 10 additions & 10 deletions crossbeam-skiplist/src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ where
/// ```
pub fn contains<Q>(&self, key: &Q) -> bool
where
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
self.inner.contains_key(key)
}
Expand All @@ -141,7 +141,7 @@ where
/// ```
pub fn get<Q>(&self, key: &Q) -> Option<Entry<'_, T>>
where
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
self.inner.get(key).map(Entry::new)
}
Expand Down Expand Up @@ -172,7 +172,7 @@ where
/// ```
pub fn lower_bound<'a, Q>(&'a self, bound: Bound<&Q>) -> Option<Entry<'a, T>>
where
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
self.inner.lower_bound(bound).map(Entry::new)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ where
/// ```
pub fn upper_bound<'a, Q>(&'a self, bound: Bound<&Q>) -> Option<Entry<'a, T>>
where
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
self.inner.upper_bound(bound).map(Entry::new)
}
Expand Down Expand Up @@ -264,7 +264,7 @@ where
pub fn range<Q, R>(&self, range: R) -> Range<'_, Q, R, T>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
Range {
inner: self.inner.range(range),
Expand Down Expand Up @@ -311,7 +311,7 @@ where
/// ```
pub fn remove<Q>(&self, key: &Q) -> Option<Entry<'_, T>>
where
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
self.inner.remove(key).map(Entry::new)
}
Expand Down Expand Up @@ -578,7 +578,7 @@ impl<T> fmt::Debug for Iter<'_, T> {
pub struct Range<'a, Q, R, T>
where
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
inner: map::Range<'a, Q, R, T, ()>,
}
Expand All @@ -587,7 +587,7 @@ impl<'a, Q, R, T> Iterator for Range<'a, Q, R, T>
where
T: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
type Item = Entry<'a, T>;

Expand All @@ -600,7 +600,7 @@ impl<'a, Q, R, T> DoubleEndedIterator for Range<'a, Q, R, T>
where
T: Ord,
R: RangeBounds<Q>,
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
fn next_back(&mut self) -> Option<Entry<'a, T>> {
self.inner.next_back().map(Entry::new)
Expand All @@ -611,7 +611,7 @@ impl<Q, R, T> fmt::Debug for Range<'_, Q, R, T>
where
T: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
Q: Ord + ?Sized + Comparable<T>,
Q: ?Sized + Comparable<T>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Range")
Expand Down

0 comments on commit 26ab5c3

Please sign in to comment.