Skip to main content

Set

Struct Set 

Source
pub struct Set(/* private fields */);
Expand description

A Set contains an immutable list of names.

It provides order-preserving iteration and set operations, and is cheaply clonable.

Implementations§

Source§

impl Set

Source

pub fn empty() -> Self

Creates an empty set.

Source

pub fn from_static_names(names: impl IntoIterator<Item = Vertex>) -> Set

Creates from a (short) list of known names.

Source

pub fn from_iter<I>(iter: I, hints: Hints) -> Set
where I: IntoIterator<Item = Result<Vertex>> + 'static, <I as IntoIterator>::IntoIter: Send + Sync,

Creates from a (lazy) iterator of names.

Source

pub fn from_stream(stream: BoxVertexStream, hints: Hints) -> Set

Creates from a (lazy) stream of names with hints.

Source

pub fn from_id_iter_idmap_dag<I>( iter: I, map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, ) -> Set
where I: IntoIterator<Item = Result<Id>> + 'static, <I as IntoIterator>::IntoIter: Send + Sync,

Creates from a (lazy) iterator of Ids, an IdMap, and a Dag.

Source

pub fn from_id_iter_dag<I>( iter: I, dag: &(impl DagAlgorithm + IdMapSnapshot), ) -> Result<Set>
where I: IntoIterator<Item = Result<Id>> + 'static, <I as IntoIterator>::IntoIter: Send + Sync,

Creates from a (lazy) iterator of Ids and a struct with snapshot abilities.

Source

pub fn from_id_set_idmap_dag( spans: IdSet, map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, ) -> Set

Creates from IdSet, [IdMap] and DagAlgorithm. Callsite must make sure spans, map, dag are using the same Id mappings. Prefer from_id_set_dag if possible.

Source

pub fn from_id_set_idmap_dag_order( spans: IdSet, map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, iteration_order: Option<BasicIterationOrder>, ) -> Set

Creates from IdSet, [IdMap], DagAlgorithm, and BasicIterationOrder. Callsite must make sure spans, map, dag are using the same Id mappings.

Source

pub fn from_id_set_dag( spans: IdSet, dag: &(impl DagAlgorithm + IdMapSnapshot), ) -> Result<Self>

Creates from IdSet and a struct with snapshot abilities. Callsite must make sure spans, dag are using the same Id mappings.

Source

pub fn from_id_list_dag( list: IdList, dag: &(impl DagAlgorithm + IdMapSnapshot), ) -> Result<Self>

Creates from IdList and a struct with snapshot abilities. Unlike Self::from_id_set_dag, the iteration order of list will be preserved. Callsite must make sure list, dag are using the same Id mappings.

Source

pub fn from_evaluate_contains<C>( evaluate: impl Fn() -> Result<Set> + Send + Sync + 'static, contains: C, hints: Hints, ) -> Set
where C: for<'a> Fn(&'a MetaSet, &'a Vertex) -> Result<bool> + Send + Sync + 'static,

Creates from a function that evaluates to a Set, and a contains fast path.

Source

pub fn from_async_evaluate_contains( evaluate: Box<dyn Fn() -> BoxFuture<'static, Result<Set>> + Send + Sync>, contains: Box<dyn for<'a> Fn(&'a MetaSet, &'a Vertex) -> BoxFuture<'a, Result<bool>> + Send + Sync>, hints: Hints, ) -> Set

Creates from an async function that evaluates to a Set, and a async contains fast path.

Source

pub fn reverse(&self) -> Set

Reverse the iteration order of the Set.

Source

pub fn difference(&self, other: &Set) -> Set

Calculates the subset that is only in self, not in other.

Source

pub fn intersection(&self, other: &Set) -> Set

Calculates the intersection of two sets.

Source

pub fn union(&self, other: &Set) -> Set

Calculates the union of two sets. Iteration order might get lost.

Source

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

Union, but preserve the iteration order (self first, other next).

Source

pub fn union_zip(&self, other: &Set) -> Set

Similar to union, but without showfast paths, and force a “flatten zip” order. For example [1,2,3,4].union_zip([5,6]) produces this order: [1,5,2,6,3,4].

Source

pub fn filter( &self, filter_func: Box<dyn Fn(&Vertex) -> BoxFuture<'_, Result<bool>> + Send + Sync + 'static>, ) -> Self

Filter using the given async function. If filter_func returns true for a vertex, then the vertex will be taken, other it will be skipped.

Source

pub async fn to_parents(&self) -> Result<Option<impl Parents>>

Convert the set to a graph containing only the vertexes in the set. This can be slow on larger sets.

Source

pub fn dag(&self) -> Option<Arc<dyn DagAlgorithm + Send + Sync>>

Obtain the attached dag if available.

Source

pub fn id_map(&self) -> Option<Arc<dyn IdConvert + Send + Sync>>

Obtain the attached IdMap if available.

Source

pub async fn flatten(&self) -> Result<Set>

Convert the current set into a flat static set so it can be used in some fast paths. This is useful for some common sets like obsolete() that might be represented by a complex expression.

By flattening, the iteration order might be lost.

Source

pub async fn flatten_id( &self, id_map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, ) -> Result<Set>

Convert this set to a static id set.

By flattening, the iteration order might be lost.

Source

pub async fn flatten_names(&self) -> Result<Set>

Convert this set to a static name set.

Source

pub fn take(&self, n: u64) -> Set

Take the first n items.

Source

pub fn skip(&self, n: u64) -> Set

Skip the first n items.

Source

pub fn to_id_set_and_id_map_in_o1( &self, ) -> Option<(IdSet, Arc<dyn IdConvert + Send + Sync>)>

Converts to (IdSet, IdConvert) pair in O(1). If the underlying set cannot provide such information in O(1), return None.

Useful if the callsite wants to have random access (ex.pathhistory) and control how to resolve in batches.

Trait Implementations§

Source§

impl Add for Set

Source§

type Output = Set

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl BitAnd for Set

Source§

type Output = Set

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Self) -> Self

Performs the & operation. Read more
Source§

impl BitOr for Set

Source§

type Output = Set

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl Clone for Set

Source§

fn clone(&self) -> Set

Returns a duplicate 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 Set

Source§

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

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

impl Deref for Set

Source§

type Target = dyn AsyncSetQuery

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl From<&Vertex> for Set

Source§

fn from(name: &Vertex) -> Set

Converts to this type from the input type.
Source§

impl<'a> From<(LegacyCodeNeedIdAccess, IdSet, &'a AbstractDag<IdDag<IndexedLogStore>, IdMap, IndexedLogDagPath, DagState>)> for Set

Source§

fn from(value: (LegacyCodeNeedIdAccess, IdSet, &'a Dag)) -> Set

Converts to this type from the input type.
Source§

impl From<Vertex> for Set

Source§

fn from(name: Vertex) -> Set

Converts to this type from the input type.
Source§

impl Sub for Set

Source§

type Output = Set

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

impl SyncSetQuery for Set

Source§

fn iter(&self) -> Result<Box<dyn NameIter>>

Iterate through the set in defined order.
Source§

fn iter_rev(&self) -> Result<Box<dyn NameIter>>

Iterate through the set in the reversed order.
Source§

fn count(&self) -> Result<u64>

Number of names in this set.
Source§

fn first(&self) -> Result<Option<Vertex>>

The first name in the set.
Source§

fn last(&self) -> Result<Option<Vertex>>

The last name in the set.
Source§

fn is_empty(&self) -> Result<bool>

Test if this set is empty.
Source§

fn contains(&self, name: &Vertex) -> Result<bool>

Test if this set contains a given name.
Source§

fn as_any(&self) -> &dyn Any

For downcasting.
Source§

fn hints(&self) -> &Hints

Get or set optimization hints.
Source§

fn id_convert(&self) -> Option<&dyn IdConvert>

Get an optional IdConvert interface to check hints.

Auto Trait Implementations§

§

impl Freeze for Set

§

impl !RefUnwindSafe for Set

§

impl Send for Set

§

impl Sync for Set

§

impl Unpin for Set

§

impl UnsafeUnpin for Set

§

impl !UnwindSafe for Set

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> TryClone for T
where T: Clone,

Source§

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

Source§

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

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more