pub struct ShortlexIntegerVectorRef<'a>(pub &'a IntegerVector);Expand description
ShortlexIntegerVectorRef is a wrapper around an IntegerVector, taking the
IntegerVector by reference.
See the ShortlexIntegerVector documentation for details.
Tuple Fields§
§0: &'a IntegerVectorTrait Implementations§
Source§impl<'a> Clone for ShortlexIntegerVectorRef<'a>
impl<'a> Clone for ShortlexIntegerVectorRef<'a>
Source§impl<'a> Debug for ShortlexIntegerVectorRef<'a>
impl<'a> Debug for ShortlexIntegerVectorRef<'a>
Source§impl Deref for ShortlexIntegerVectorRef<'_>
impl Deref for ShortlexIntegerVectorRef<'_>
Source§fn deref(&self) -> &IntegerVector
fn deref(&self) -> &IntegerVector
Allows a ShortlexIntegerVectorRef to dereference to an IntegerVector.
use core::str::FromStr;
use malachite_nz::integer_vector::{IntegerVector, ShortlexIntegerVectorRef};
let v = IntegerVector::from_str("(1, 2, 3)").unwrap();
let x = ShortlexIntegerVectorRef(&v);
assert_eq!(*x, v);Source§type Target = IntegerVector
type Target = IntegerVector
impl<'a> Eq for ShortlexIntegerVectorRef<'a>
Source§impl<'a> Hash for ShortlexIntegerVectorRef<'a>
impl<'a> Hash for ShortlexIntegerVectorRef<'a>
Source§impl Ord for ShortlexIntegerVectorRef<'_>
impl Ord for ShortlexIntegerVectorRef<'_>
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Compares two ShortlexIntegerVectorRefs.
The order is shortlex: the vectors are compared first by dimension, and then, in case of a
tie, lexicographically, by their elements from first to last. The 0-dimensional vector comes
first. This is a total order, and its equality agrees with
IntegerVector equality.
Where the dimensions differ this parts company with the lexicographic order of Vecs:
here dimension decides outright, so $(5) < (0, 0)$, where lexicographic order has $(5) > (0,
0)$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the smaller of the two vectors’ total number of bits, summed over their elements. Vectors of different dimensions are compared in constant time.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::{IntegerVector, ShortlexIntegerVectorRef};
let empty = IntegerVector::from_str("()").unwrap();
let five = IntegerVector::from_str("(5)").unwrap();
let zero_zero = IntegerVector::from_str("(0, 0)").unwrap();
let zero_one = IntegerVector::from_str("(0, 1)").unwrap();
// The 0-dimensional vector comes first.
assert!(ShortlexIntegerVectorRef(&empty) < ShortlexIntegerVectorRef(&five));
// Dimension decides, whatever the elements.
assert!(ShortlexIntegerVectorRef(&five) < ShortlexIntegerVectorRef(&zero_zero));
// At equal dimensions, the first differing element decides.
assert!(ShortlexIntegerVectorRef(&zero_zero) < ShortlexIntegerVectorRef(&zero_one));1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a> PartialEq for ShortlexIntegerVectorRef<'a>
impl<'a> PartialEq for ShortlexIntegerVectorRef<'a>
Source§impl PartialOrd for ShortlexIntegerVectorRef<'_>
impl PartialOrd for ShortlexIntegerVectorRef<'_>
Source§fn partial_cmp(&self, other: &ShortlexIntegerVectorRef<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &ShortlexIntegerVectorRef<'_>) -> Option<Ordering>
Compares two ShortlexIntegerVectorRefs.
See the documentation for the Ord implementation.
impl<'a> StructuralPartialEq for ShortlexIntegerVectorRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for ShortlexIntegerVectorRef<'a>
impl<'a> RefUnwindSafe for ShortlexIntegerVectorRef<'a>
impl<'a> Send for ShortlexIntegerVectorRef<'a>
impl<'a> Sync for ShortlexIntegerVectorRef<'a>
impl<'a> Unpin for ShortlexIntegerVectorRef<'a>
impl<'a> UnsafeUnpin for ShortlexIntegerVectorRef<'a>
impl<'a> UnwindSafe for ShortlexIntegerVectorRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more