pub struct NameSet(_);
Expand description
A NameSet
contains an immutable list of names.
It provides order-preserving iteration and set operations, and is cheaply clonable.
Implementations§
source§impl NameSet
impl NameSet
sourcepub fn from_static_names(names: impl IntoIterator<Item = VertexName>) -> NameSet
pub fn from_static_names(names: impl IntoIterator<Item = VertexName>) -> NameSet
Creates from a (short) list of known names.
sourcepub fn from_iter<I>(iter: I, hints: Hints) -> NameSetwhere
I: IntoIterator<Item = Result<VertexName>> + 'static,
<I as IntoIterator>::IntoIter: Send + Sync,
pub fn from_iter<I>(iter: I, hints: Hints) -> NameSetwhere
I: IntoIterator<Item = Result<VertexName>> + 'static,
<I as IntoIterator>::IntoIter: Send + Sync,
Creates from a (lazy) iterator of names.
sourcepub fn from_stream(stream: BoxVertexStream, hints: Hints) -> NameSet
pub fn from_stream(stream: BoxVertexStream, hints: Hints) -> NameSet
Creates from a (lazy) stream of names with hints.
sourcepub fn from_id_iter_idmap_dag<I>(
iter: I,
map: Arc<dyn IdConvert + Send + Sync>,
dag: Arc<dyn DagAlgorithm + Send + Sync>
) -> NameSetwhere
I: IntoIterator<Item = Result<Id>> + 'static,
<I as IntoIterator>::IntoIter: Send + Sync,
pub fn from_id_iter_idmap_dag<I>(
iter: I,
map: Arc<dyn IdConvert + Send + Sync>,
dag: Arc<dyn DagAlgorithm + Send + Sync>
) -> NameSetwhere
I: IntoIterator<Item = Result<Id>> + 'static,
<I as IntoIterator>::IntoIter: Send + Sync,
Creates from a (lazy) iterator of Ids, an IdMap, and a Dag.
sourcepub fn from_id_iter_dag<I>(
iter: I,
dag: &impl DagAlgorithm + IdMapSnapshot
) -> Result<NameSet>where
I: IntoIterator<Item = Result<Id>> + 'static,
<I as IntoIterator>::IntoIter: Send + Sync,
pub fn from_id_iter_dag<I>(
iter: I,
dag: &impl DagAlgorithm + IdMapSnapshot
) -> Result<NameSet>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.
sourcepub fn from_spans_idmap_dag(
spans: IdSet,
map: Arc<dyn IdConvert + Send + Sync>,
dag: Arc<dyn DagAlgorithm + Send + Sync>
) -> NameSet
pub fn from_spans_idmap_dag(
spans: IdSet,
map: Arc<dyn IdConvert + Send + Sync>,
dag: Arc<dyn DagAlgorithm + Send + Sync>
) -> NameSet
Creates from IdSet
, [IdMap
] and DagAlgorithm
.
sourcepub fn from_spans_dag(
spans: IdSet,
dag: &impl DagAlgorithm + IdMapSnapshot
) -> Result<Self>
pub fn from_spans_dag(
spans: IdSet,
dag: &impl DagAlgorithm + IdMapSnapshot
) -> Result<Self>
Creates from IdSet
and a struct with snapshot abilities.
sourcepub fn from_evaluate_contains<C>(
evaluate: impl Fn() -> Result<NameSet> + Send + Sync + 'static,
contains: C,
hints: Hints
) -> NameSetwhere
C: for<'a> Fn(&'a MetaSet, &'a VertexName) -> Result<bool> + Send + Sync + 'static,
pub fn from_evaluate_contains<C>(
evaluate: impl Fn() -> Result<NameSet> + Send + Sync + 'static,
contains: C,
hints: Hints
) -> NameSetwhere
C: for<'a> Fn(&'a MetaSet, &'a VertexName) -> Result<bool> + Send + Sync + 'static,
Creates from a function that evaluates to a NameSet
, and a
contains
fast path.
sourcepub fn from_async_evaluate_contains(
evaluate: Box<dyn Fn() -> BoxFuture<'static, Result<NameSet>> + Send + Sync>,
contains: Box<dyn for<'a> Fn(&'a MetaSet, &'a VertexName) -> BoxFuture<'a, Result<bool>> + Send + Sync>,
hints: Hints
) -> NameSet
pub fn from_async_evaluate_contains(
evaluate: Box<dyn Fn() -> BoxFuture<'static, Result<NameSet>> + Send + Sync>,
contains: Box<dyn for<'a> Fn(&'a MetaSet, &'a VertexName) -> BoxFuture<'a, Result<bool>> + Send + Sync>,
hints: Hints
) -> NameSet
Creates from an async function that evaluates to a NameSet
, and a
async contains
fast path.
sourcepub fn difference(&self, other: &NameSet) -> NameSet
pub fn difference(&self, other: &NameSet) -> NameSet
Calculates the subset that is only in self, not in other.
sourcepub fn intersection(&self, other: &NameSet) -> NameSet
pub fn intersection(&self, other: &NameSet) -> NameSet
Calculates the intersection of two sets.
sourcepub fn filter(
&self,
filter_func: Box<dyn Fn(&VertexName) -> BoxFuture<'_, Result<bool>> + Send + Sync + 'static>
) -> Self
pub fn filter(
&self,
filter_func: Box<dyn Fn(&VertexName) -> 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.
sourcepub async fn to_parents(&self) -> Result<Option<impl Parents>>
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.
sourcepub fn dag(&self) -> Option<Arc<dyn DagAlgorithm + Send + Sync>>
pub fn dag(&self) -> Option<Arc<dyn DagAlgorithm + Send + Sync>>
Obtain the attached dag if available.
sourcepub fn id_map(&self) -> Option<Arc<dyn IdConvert + Send + Sync>>
pub fn id_map(&self) -> Option<Arc<dyn IdConvert + Send + Sync>>
Obtain the attached IdMap if available.
sourcepub async fn flatten(&self) -> Result<NameSet>
pub async fn flatten(&self) -> Result<NameSet>
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.
sourcepub async fn flatten_id(
&self,
id_map: Arc<dyn IdConvert + Send + Sync>,
dag: Arc<dyn DagAlgorithm + Send + Sync>
) -> Result<NameSet>
pub async fn flatten_id(
&self,
id_map: Arc<dyn IdConvert + Send + Sync>,
dag: Arc<dyn DagAlgorithm + Send + Sync>
) -> Result<NameSet>
Convert this set to a static id set.
sourcepub async fn flatten_names(&self) -> Result<NameSet>
pub async fn flatten_names(&self) -> Result<NameSet>
Convert this set to a static name set.
sourcepub fn to_id_set_and_id_map_in_o1(
&self
) -> Option<(IdSet, Arc<dyn IdConvert + Send + Sync>)>
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. bisect) and control how to resolve in batches.