Struct mpchash::KeyRange

source ·
pub struct KeyRange<Idx>
where Idx: Bounded,
{ pub start: Idx, pub end: Idx, }
Expand description

A (half-open) range bounded inclusively below and exclusively above i.e. [start..end).

If start >= end, the range is considered wrapping and is equivalent to covering union of two ranges: [start..MAX_VALUE] and [0..end).

Fields§

§start: Idx§end: Idx

Implementations§

source§

impl<Idx: Bounded> KeyRange<Idx>

source

pub fn new(start: Idx, end: Idx) -> Self

Creates a new range.

source§

impl<Idx> KeyRange<Idx>
where Idx: PartialOrd<Idx> + Clone + Debug + Bounded + Ord,

source

pub fn is_wrapping(&self) -> bool

Returns true if the range is wrapping, which is equivalent to union of the following two ranges: [start..MAX_VALUE] and [0..end)..

source

pub fn is_inverted(&self) -> bool

Returns true if the range is inverted, i.e. start >= end.

source

pub fn ends_at_origin(&self) -> bool

Returns true if the range ends at the origin.

This is useful for distinguishing a special case of non-wrapping range that has inverted positions, end < start, but is still non-wrapping.

source

pub fn covers_whole_ring(&self) -> bool

Returns true if the range covers the whole ring.

source

pub fn contains(&self, item: &Idx) -> bool

Returns true if item is contained in the range.

source

pub fn is_overlapping(&self, other: &Self) -> bool

Returns true if the range overlaps with other.

source

pub fn is_continuous(&self, other: &Self) -> bool

Returns true if one range is a continuation of the other.

That’s intervals do not intersect, but can be merged i.e. for a given intervals [a, b) and [b, c) the union is [a, c).

source

pub fn merged(&self, other: &Self) -> Option<Self>

Returns a new range that is the union of self and other if they can be merged into a single interval. For ranges that can’t be merged, returns None.

source§

impl KeyRange<RingPosition>

source

pub fn size(&self) -> RingPosition

Trait Implementations§

source§

impl<Idx> Clone for KeyRange<Idx>
where Idx: Bounded + Clone,

source§

fn clone(&self) -> KeyRange<Idx>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Idx> Debug for KeyRange<Idx>
where Idx: Bounded + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Idx> Hash for KeyRange<Idx>
where Idx: Bounded + Hash,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<Idx> PartialEq for KeyRange<Idx>
where Idx: Bounded + PartialEq,

source§

fn eq(&self, other: &KeyRange<Idx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Idx> Eq for KeyRange<Idx>
where Idx: Bounded + Eq,

source§

impl<Idx> StructuralEq for KeyRange<Idx>
where Idx: Bounded,

source§

impl<Idx> StructuralPartialEq for KeyRange<Idx>
where Idx: Bounded,

Auto Trait Implementations§

§

impl<Idx> RefUnwindSafe for KeyRange<Idx>
where Idx: RefUnwindSafe,

§

impl<Idx> Send for KeyRange<Idx>
where Idx: Send,

§

impl<Idx> Sync for KeyRange<Idx>
where Idx: Sync,

§

impl<Idx> Unpin for KeyRange<Idx>
where Idx: Unpin,

§

impl<Idx> UnwindSafe for KeyRange<Idx>
where Idx: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.