Struct standing_relations::core::Relation
source · [−]pub struct Relation<C: Op_> { /* private fields */ }Implementations
sourceimpl<'a, K: Clone + Eq + Hash + 'a, V: Clone + Eq + Hash + 'a, C: Op<D = (K, V)> + 'a> Relation<C>
impl<'a, K: Clone + Eq + Hash + 'a, V: Clone + Eq + Hash + 'a, C: Op<D = (K, V)> + 'a> Relation<C>
pub fn first_occurences<I>(
self,
context: &mut CreationContext<'a, I>
) -> Relation<impl Op<D = (K, V)>>
sourceimpl<K: Clone + Eq + Hash, V: Clone + Eq + Hash, C: Op<D = (K, V)>> Relation<C>
impl<K: Clone + Eq + Hash, V: Clone + Eq + Hash, C: Op<D = (K, V)>> Relation<C>
pub fn semijoin(
self,
other: Relation<impl Op<D = K>>
) -> Relation<impl Op<D = (K, V)>>
pub fn join_values<V2: Clone + Eq + Hash>(
self,
other: Relation<impl Op<D = (K, V2)>>
) -> Relation<impl Op<D = (V, V2)>>
pub fn left_join<V2: Clone + Eq + Hash>(
self,
other: Relation<impl Op<D = (K, V2)>>
) -> Relation<impl Op<D = (K, V, Option<V2>)>>
sourceimpl<C: Op> Relation<C>
impl<C: Op> Relation<C>
pub fn flat_map<I: IntoIterator>(
self,
f: impl Fn(C::D) -> I
) -> Relation<impl Op<D = I::Item>>
pub fn flatten(self) -> Relation<impl Op<D = <C::D as IntoIterator>::Item>> where
C::D: IntoIterator,
pub fn map<Y>(self, f: impl Fn(C::D) -> Y) -> Relation<impl Op<D = Y>>
pub fn map_h<Y>(self, f: impl Fn(C::D) -> Y) -> Relation<impl Op<D = Y>>
pub fn filter(self, f: impl Fn(&C::D) -> bool) -> Relation<impl Op<D = C::D>>
pub fn map_counts(
self,
f: impl Fn(isize) -> isize
) -> Relation<impl Op<D = C::D>>
pub fn negate(self) -> Relation<impl Op<D = C::D>>
sourceimpl<C: Op> Relation<C>
impl<C: Op> Relation<C>
pub fn into_output(self, context: &CreationContext<'_>) -> Output<C::D, C> where
C::D: Eq + Hash,
sourceimpl<K, V, C: Op<D = (K, V)>> Relation<C>
impl<K, V, C: Op<D = (K, V)>> Relation<C>
pub fn into_kv_output(
self,
context: &CreationContext<'_>
) -> Output<(K, V), C, HashMap<K, HashMap<V, isize>>> where
K: Eq + Hash,
V: Eq + Hash,
pub fn into_extrema_output(
self,
context: &CreationContext<'_>
) -> Output<(K, V), C, ExtremaMap<K, V>> where
K: Ord,
V: Eq + Hash,
sourceimpl<C: Op<D = (K, V)>, K: Clone + Eq + Hash, V> Relation<C>
impl<C: Op<D = (K, V)>, K: Clone + Eq + Hash, V> Relation<C>
pub fn reduce_<M: CountMap<V> + Observable, Y: Clone + Eq, F: Fn(&K, &M) -> Y>(
self,
f: F
) -> Relation<Reduce<K, V, C, M, Y, HashMap<K, Y>, F>>
pub fn reduce<Y: Clone + Eq>(
self,
f: impl Fn(&K, &HashMap<V, isize>) -> Y
) -> Relation<impl IsReduce<T = ((K, Y), isize), OM = HashMap<K, Y>>> where
V: Eq + Hash,
pub fn group_min(
self
) -> Relation<impl IsReduce<T = ((K, V), isize), OM = HashMap<K, V>>> where
V: Clone + Ord,
pub fn group_max(
self
) -> Relation<impl IsReduce<T = ((K, V), isize), OM = HashMap<K, V>>> where
V: Clone + Ord,
sourceimpl<C: Op<D = (L, R)>, L, R> Relation<C>
impl<C: Op<D = (L, R)>, L, R> Relation<C>
sourcepub fn split(self) -> (Relation<impl Op<D = L>>, Relation<impl Op<D = R>>)
pub fn split(self) -> (Relation<impl Op<D = L>>, Relation<impl Op<D = R>>)
Splits a collection of 2-tuples into a 2-tuple of collections.
Example:
use standing_relations::CreationContext;
use std::{collections::HashMap, iter::FromIterator};
let mut context = CreationContext::new();
let (mut foo_input, foo) = context.new_input::<usize>();
let (evens, odds) = foo.map(|x| (x * 2, x * 2 + 1)).split();
let evens = evens.into_output(&context);
let odds = odds.into_output(&context);
let mut context = context.begin();
foo_input.add_all(&context, 0 .. 2);
context.commit();
assert_eq!(&*evens.get(&context), &HashMap::from_iter(vec![(0,1),(2,1)]));
assert_eq!(&*odds.get(&context), &HashMap::from_iter(vec![(1,1),(3,1)]));sourceimpl<C: Op> Relation<C> where
C::D: Clone,
impl<C: Op> Relation<C> where
C::D: Clone,
pub fn collect<'a>(self) -> Collection<'a, C::D> where
C: 'a,
sourcepub fn t<D: Is<Myself = C::D>>(self) -> Self
pub fn t<D: Is<Myself = C::D>>(self) -> Self
No-op which nails down the expected item type.
The compiler will complain if the provided type is wrong. This helps you spot type errors where they occur rather than downstream.
Example:
use standing_relations::CreationContext;
use std::{collections::HashMap, iter::FromIterator};
let mut context = CreationContext::new();
let (_foo_input, foo) = context.new_input::<(char, isize)>();
let (_bar_input, bar) = context.new_input::<char>();
let foobar =
foo.join(bar.counts()).flat_map(|(k,x,y)| if x < y {Some((k,x))} else {None});
let foobar = foobar.t::<(char, isize)>();Note that if instead of flat_map, we had accidentally used map, the compiler would
complain because foobar would have item type Option<(char, isize)> where we expect
(char, isize).
sourceimpl<C: Op_<T = (D, isize)>, D: Eq + Hash> Relation<C>
impl<C: Op_<T = (D, isize)>, D: Eq + Hash> Relation<C>
pub fn consolidate(self) -> Relation<Consolidate<C>>
sourceimpl<C: Op_> Relation<C>
impl<C: Op_> Relation<C>
pub fn dynamic_shown<'a>(self) -> Relation<Dynamic<'a, C::T>> where
C: 'a,
sourceimpl<C: IsReduce> Relation<C>
impl<C: IsReduce> Relation<C>
pub fn probe(self, context: &CreationContext<'_>) -> ReduceProbe<C>
sourceimpl<C: Op> Relation<C>
impl<C: Op> Relation<C>
pub fn into_output_<M: CountMap<C::D>>(
self,
context: &CreationContext<'_>
) -> Output<C::D, C, M>
sourceimpl<C: Op_> Relation<C>
impl<C: Op_> Relation<C>
pub fn tracking_index(&self) -> TrackingIndex
pub fn named(self, name: &str) -> Self
pub fn type_named(self, type_name: &str) -> Self
Trait Implementations
Auto Trait Implementations
impl<C> !RefUnwindSafe for Relation<C>
impl<C> !Send for Relation<C>
impl<C> !Sync for Relation<C>
impl<C> Unpin for Relation<C> where
C: Unpin,
impl<C> !UnwindSafe for Relation<C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more