pub struct SetDomain<E: Ord + Clone>(_);
Expand description

Implements a set domain.

Implementations§

source§

impl SetDomain<Addr>

source

pub fn constant(a: BigUint) -> Self

Create a constant address from concrete address a

source

pub fn footprint(ap: AccessPath) -> Self

Create a footprint address from access path ap

source

pub fn formal(formal_index: TempIndex, func_env: &FunctionEnv<'_>) -> Self

Create a footprint address read from formal temp_index

source

pub fn is_constant(&self) -> bool

Return true if self is a constant

source

pub fn is_statically_known(&self) -> bool

Return true if self consists only of statically known constants

source

pub fn substitute_footprint( &mut self, actuals: &[TempIndex], type_actuals: &[Type], func_env: &FunctionEnv<'_>, sub_map: &dyn AccessPathMap<AbsAddr> )

Substitute all occurences of Footprint(ap) in self by resolving the accesss path ap in sub_map

source

pub fn add_struct_offset( self, mid: &ModuleId, sid: StructId, types: Vec<Type> ) -> Self

Return a new abstract address by adding the offset mid::sid<types> to each element of self

source

pub fn add_offset(&self, offset: Offset) -> Self

Return a new abstract address by adding the offset offset to each element of self

source

pub fn prepend(self, prefix: AccessPath) -> Self

Produce a new version of self with prefix prepended to each footprint value

source

pub fn footprint_paths(&self) -> impl Iterator<Item = &AccessPath>

return an iterator over the footprint paths in self

source

pub fn get_concrete_addresses(&self) -> Vec<AccountAddress>

Return an iterator over the concrete addresses in self

source

pub fn display<'a>(&'a self, env: &'a FunctionEnv<'_>) -> AbsAddrDisplay<'a>

Return a wrapper of self that implements Display using env

source§

impl<E: Ord + Clone> SetDomain<E>

source

pub fn singleton(e: E) -> Self

source

pub fn difference<'a>(&'a self, other: &'a Self) -> impl Iterator<Item = &'a E>

Implements set difference, which is not following standard APIs for rust sets in OrdSet

source

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

Implements is_disjoint which is not available in OrdSet

Methods from Deref<Target = OrdSet<E>>§

pub fn is_empty(&self) -> bool

Test whether a set is empty.

Time: O(1)

Examples
assert!(
  !ordset![1, 2, 3].is_empty()
);
assert!(
  OrdSet::<i32>::new().is_empty()
);

pub fn len(&self) -> usize

Get the size of a set.

Time: O(1)

Examples
assert_eq!(3, ordset![1, 2, 3].len());

pub fn ptr_eq(&self, other: &OrdSet<A>) -> bool

Test whether two sets refer to the same content in memory.

This is true if the two sides are references to the same set, or if the two sets refer to the same root node.

This would return true if you’re comparing a set to itself, or if you’re comparing a set to a fresh clone of itself.

Time: O(1)

pub fn clear(&mut self)

Discard all elements from the set.

This leaves you with an empty set, and all elements that were previously inside it are dropped.

Time: O(n)

Examples
let mut set = ordset![1, 2, 3];
set.clear();
assert!(set.is_empty());

pub fn get_min(&self) -> Option<&A>

Get the smallest value in a set.

If the set is empty, returns None.

Time: O(log n)

pub fn get_max(&self) -> Option<&A>

Get the largest value in a set.

If the set is empty, returns None.

Time: O(log n)

pub fn iter(&self) -> Iter<'_, A>

Create an iterator over the contents of the set.

pub fn range<R, BA>(&self, range: R) -> RangedIter<'_, A>where R: RangeBounds<BA>, A: Borrow<BA>, BA: Ord + ?Sized,

Create an iterator over a range inside the set.

pub fn diff<'a>(&'a self, other: &'a OrdSet<A>) -> DiffIter<'a, A>

Get an iterator over the differences between this set and another, i.e. the set of entries to add or remove to this set in order to make it equal to the other set.

This function will avoid visiting nodes which are shared between the two sets, meaning that even very large sets can be compared quickly if most of their structure is shared.

Time: O(n) (where n is the number of unique elements across the two sets, minus the number of elements belonging to nodes shared between them)

pub fn contains<BA>(&self, a: &BA) -> boolwhere BA: Ord + ?Sized, A: Borrow<BA>,

Test if a value is part of a set.

Time: O(log n)

Examples
let mut set = ordset!{1, 2, 3};
assert!(set.contains(&1));
assert!(!set.contains(&4));

pub fn get_prev(&self, key: &A) -> Option<&A>

Get the closest smaller value in a set to a given value.

If the set contains the given value, this is returned. Otherwise, the closest value in the set smaller than the given value is returned. If the smallest value in the set is larger than the given value, None is returned.

Examples
let set = ordset![1, 3, 5, 7, 9];
assert_eq!(Some(&5), set.get_prev(&6));

pub fn get_next(&self, key: &A) -> Option<&A>

Get the closest larger value in a set to a given value.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let set = ordset![1, 3, 5, 7, 9];
assert_eq!(Some(&5), set.get_next(&4));

pub fn is_subset<RS>(&self, other: RS) -> boolwhere RS: Borrow<OrdSet<A>>,

Test whether a set is a subset of another set, meaning that all values in our set must also be in the other set.

Time: O(n log m) where m is the size of the other set

pub fn is_proper_subset<RS>(&self, other: RS) -> boolwhere RS: Borrow<OrdSet<A>>,

Test whether a set is a proper subset of another set, meaning that all values in our set must also be in the other set. A proper subset must also be smaller than the other set.

Time: O(n log m) where m is the size of the other set

pub fn insert(&mut self, a: A) -> Option<A>

Insert a value into a set.

Time: O(log n)

Examples
let mut set = ordset!{};
set.insert(123);
set.insert(456);
assert_eq!(
  set,
  ordset![123, 456]
);

pub fn remove<BA>(&mut self, a: &BA) -> Option<A>where BA: Ord + ?Sized, A: Borrow<BA>,

Remove a value from a set.

Time: O(log n)

pub fn remove_min(&mut self) -> Option<A>

Remove the smallest value from a set.

Time: O(log n)

pub fn remove_max(&mut self) -> Option<A>

Remove the largest value from a set.

Time: O(log n)

pub fn update(&self, a: A) -> OrdSet<A>

Construct a new set from the current set with the given value added.

Time: O(log n)

Examples
let set = ordset![456];
assert_eq!(
  set.update(123),
  ordset![123, 456]
);

pub fn without<BA>(&self, a: &BA) -> OrdSet<A>where BA: Ord + ?Sized, A: Borrow<BA>,

Construct a new set with the given value removed if it’s in the set.

Time: O(log n)

pub fn without_min(&self) -> (Option<A>, OrdSet<A>)

Remove the smallest value from a set, and return that value as well as the updated set.

Time: O(log n)

pub fn without_max(&self) -> (Option<A>, OrdSet<A>)

Remove the largest value from a set, and return that value as well as the updated set.

Time: O(log n)

pub fn take(&self, n: usize) -> OrdSet<A>

Construct a set with only the n smallest values from a given set.

Time: O(n)

pub fn skip(&self, n: usize) -> OrdSet<A>

Construct a set with the n smallest values removed from a given set.

Time: O(n)

Trait Implementations§

source§

impl<E: Ord + Clone> AbstractDomain for SetDomain<E>

source§

fn join(&mut self, other: &Self) -> JoinResult

source§

impl<E: Ord + Clone> AsRef<OrdSet<E>> for SetDomain<E>

source§

fn as_ref(&self) -> &OrdSet<E>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<E: Ord + Clone> Borrow<OrdSet<E>> for SetDomain<E>

source§

fn borrow(&self) -> &OrdSet<E>

Immutably borrows from an owned value. Read more
source§

impl<E: Clone + Ord + Clone> Clone for SetDomain<E>

source§

fn clone(&self) -> SetDomain<E>

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<E: Ord + Clone + Debug> Debug for SetDomain<E>

source§

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

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

impl<E: Ord + Clone> Default for SetDomain<E>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<E: Ord + Clone> Deref for SetDomain<E>

§

type Target = OrdSet<E>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<E: Ord + Clone> DerefMut for SetDomain<E>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<E: Ord + Clone> From<BTreeSet<E, Global>> for SetDomain<E>

source§

fn from(s: BTreeSet<E>) -> Self

Converts to this type from the input type.
source§

impl<E: Ord + Clone> From<OrdSet<E>> for SetDomain<E>

source§

fn from(ord_set: OrdSet<E>) -> Self

Converts to this type from the input type.
source§

impl<E: Ord + Clone> FromIterator<E> for SetDomain<E>

source§

fn from_iter<I: IntoIterator<Item = E>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<E: Ord + Clone> IntoIterator for SetDomain<E>

§

type Item = E

The type of the elements being iterated over.
§

type IntoIter = ConsumingIter<E>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<E: Ord + Ord + Clone> Ord for SetDomain<E>

source§

fn cmp(&self, other: &SetDomain<E>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<E: PartialEq + Ord + Clone> PartialEq<SetDomain<E>> for SetDomain<E>

source§

fn eq(&self, other: &SetDomain<E>) -> 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<E: PartialOrd + Ord + Clone> PartialOrd<SetDomain<E>> for SetDomain<E>

source§

fn partial_cmp(&self, other: &SetDomain<E>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<E: Eq + Ord + Clone> Eq for SetDomain<E>

source§

impl<E: Ord + Clone> StructuralEq for SetDomain<E>

source§

impl<E: Ord + Clone> StructuralPartialEq for SetDomain<E>

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for SetDomain<E>where E: RefUnwindSafe,

§

impl<E> Send for SetDomain<E>where E: Send + Sync,

§

impl<E> Sync for SetDomain<E>where E: Send + Sync,

§

impl<E> Unpin for SetDomain<E>where E: Unpin,

§

impl<E> UnwindSafe for SetDomain<E>where E: UnwindSafe + RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

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

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V