Struct ddo::NodeFlags

source ·
pub struct NodeFlags(/* private fields */);
Expand description

This structure stores a compact set of flags relating to a given node. So far, it maintains the following:

  • Exact which is true iff the current node is exact
  • Relaxed which is true iff the current node is relaxed (result of a merge)

§Remark

It might seem as though ( \neg exact \equiv relaxed ). But actually it is not the case. The subtlety is the following: ( relaxed \implies \neg exact ) and ( exact \implies \neg relaxed ) but ( \neg exact \not\implies relaxed ).

In other words, a node can be inexact and not relaxed either. This happens when a node is not the result of a merge operation but one of its ancestors is.

§Important Note

For the sake of clarity, and to keep the code simple and lean, it was decided that the setters would not enforce the above relationships. The only exception to this rule being that a node is always considered inexact when the relaxed flag is on.

§Default

By default, a node is considered exact, not relaxed and not feasible (because this field is not set until local bounds computation).

Implementations§

source§

impl NodeFlags

source

pub const F_EXACT: u8 = 1u8

The position of the exact flag

source

pub const F_RELAXED: u8 = 2u8

The position of the relaxed flag

source

pub const F_MARKED: u8 = 4u8

The position of the marked flag.

source

pub const F_CUTSET: u8 = 8u8

The position of the cut-set flag.

source

pub const F_DELETED: u8 = 16u8

The position of the deleted flag.

source

pub const F_CACHE: u8 = 32u8

The position of the cache flag.

source

pub const F_ABOVE_CUTSET: u8 = 64u8

The position of the above cut-set flag.

source

pub fn new(relaxed: bool) -> Self

Creates a new set of flags, either initialized with exact on or with relaxed on.

source

pub fn new_exact() -> Self

Creates a new set of flags having only the exact flag turned on.

source

pub fn new_relaxed() -> Self

Creates a new set of flags having only the relaxed flag turned on.

source

pub fn is_exact(self) -> bool

Returns true iff the exact flag is on and the relaxed flag is off

source

pub fn is_relaxed(self) -> bool

Returns true iff the exact flag is turned on

source

pub fn is_marked(self) -> bool

Returns true iff the marked flag is turned on

source

pub fn is_cutset(self) -> bool

Returns true iff the cut-set flag is turned on

source

pub fn is_above_cutset(self) -> bool

Returns true iff the above cut-set flag is turned on

source

pub fn is_deleted(self) -> bool

Returns true iff the deleted flag is turned on

source

pub fn is_pruned_by_cache(self) -> bool

Returns true iff the cache flag is turned on

source

pub fn set_exact(&mut self, exact: bool)

Sets the exact flag to the given value

source

pub fn set_relaxed(&mut self, relaxed: bool)

Sets the relaxed flat to the given value

source

pub fn set_marked(&mut self, marked: bool)

Sets the marked flag to the given value

source

pub fn set_cutset(&mut self, cutset: bool)

source

pub fn set_above_cutset(&mut self, above: bool)

source

pub fn set_deleted(&mut self, deleted: bool)

Sets the deleted flag to the given value

source

pub fn set_pruned_by_cache(&mut self, cache: bool)

Sets the cache flag to the given value

source

pub fn test(self, mask: u8) -> bool

Checks whether all the flags encoded in the given mask are turned on. Otherwise, it returns false

source

pub fn set(&mut self, flag: u8, value: bool)

Sets the value of a given flag to the selected polarity

source

pub fn add(&mut self, flags: u8)

Turns the given flag(s) on.

source

pub fn remove(&mut self, flags: u8)

Turns the given flag(s) off.

Trait Implementations§

source§

impl Clone for NodeFlags

source§

fn clone(&self) -> NodeFlags

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 Debug for NodeFlags

source§

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

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

impl Default for NodeFlags

source§

fn default() -> Self

Creates a default set of flags (only the exact flag is turned on).

source§

impl PartialEq for NodeFlags

source§

fn eq(&self, other: &NodeFlags) -> 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 Copy for NodeFlags

source§

impl Eq for NodeFlags

source§

impl StructuralPartialEq for NodeFlags

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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.