Trait disjoint_sets::ElementType
[−]
[src]
pub trait ElementType: Copy + Debug + Eq { fn from_usize(usize) -> Option<Self>; fn to_usize(self) -> usize; }
A type that can be used as a union-find element.
It must be safely convertible to and from usize
.
The two methods must be well-behaved partial inverses as follows:
- For all
f: usize
, iff::from_usize()
=Some(t)
thent::to_usize()
=f
. - For all
f: Self
, iff::to_usize()
=t
thent::from_usize()
=Some(f)
. - For all
f: usize
, iff::from_usize()
=None
then for allg: usize
such thatg > f
,g::from_usize()
=None
.
In other words, ElementType
sets up a bijection between the first
k usize
values and some k values of the Self
type.
Required Methods
fn from_usize(usize) -> Option<Self>
Converts from usize
to the element type.
Returns None
if the argument won’t fit in Self
.
fn to_usize(self) -> usize
Converts from the element type to usize
.