Skip to main content

Domain

Enum Domain 

Source
pub enum Domain {
    Range {
        min: i64,
        max: i64,
    },
    Explicit(BTreeSet<i64>),
}
Expand description

Representation of possible integer values for a decision variable.

Variants§

§

Range

Range-bounded domain [min, max]. Space complexity: O(1).

Fields

§min: i64
§max: i64
§

Explicit(BTreeSet<i64>)

Explicit set of discrete values stored as a sorted BTreeSet or Sparse Set representation. Space complexity: O(D) where D is domain size.

Implementations§

Source§

impl Domain

Source

pub fn range(min: i64, max: i64) -> Self

Creates a range domain [min, max].

§Complexity

Time & Space: O(1).

Source

pub fn from_values<I: IntoIterator<Item = i64>>(values: I) -> Self

Creates an explicit domain from an iterator of integer values.

§Complexity

Time: O(N log N) where N is number of elements. Space: O(N).

Source

pub fn is_empty(&self) -> bool

Checks whether the domain is empty.

§Complexity

Time: O(1).

Source

pub fn len(&self) -> usize

Returns the number of values in the domain.

§Complexity

Time: O(1) for Range, O(1) for Explicit.

Source

pub fn contains(&self, val: i64) -> bool

Checks if a value is contained in the domain.

§Complexity

Time: O(1) for Range, O(log N) for Explicit.

Source

pub fn min(&self) -> Option<i64>

Returns the minimum value in the domain, or None if empty.

§Complexity

Time: O(1) for Range, O(log N) for Explicit.

Source

pub fn max(&self) -> Option<i64>

Returns the maximum value in the domain, or None if empty.

§Complexity

Time: O(1) for Range, O(log N) for Explicit.

Source

pub fn remove(&mut self, val: i64) -> bool

Removes a value from the domain. Returns true if the domain was modified.

§Complexity

Time: O(1) / O(N) depending on representation conversion.

Source

pub fn remove_below(&mut self, min_val: i64) -> bool

Prunes values below min_val. Returns true if modified.

§Complexity

Time: O(1) for Range, O(K log N) for Explicit where K is number of removed elements.

Source

pub fn remove_above(&mut self, max_val: i64) -> bool

Prunes values above max_val. Returns true if modified.

§Complexity

Time: O(1) for Range, O(K log N) for Explicit where K is number of removed elements.

Source

pub fn assign(&mut self, val: i64) -> bool

Restricts the domain to a single value. Returns true if modified.

§Complexity

Time: O(1) for Range, O(N) for Explicit.

Source

pub fn values(&self) -> Vec<i64>

Returns all values in the domain as a vector.

§Complexity

Time: O(N) where N = domain size. Space: O(N).

Trait Implementations§

Source§

impl Clone for Domain

Source§

fn clone(&self) -> Domain

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Domain

Source§

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

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

impl Eq for Domain

Source§

impl PartialEq for Domain

Source§

fn eq(&self, other: &Domain) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Domain

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.