Skip to main content

Relation

Struct Relation 

Source
pub struct Relation<K> { /* private fields */ }
Expand description

A finite-support function from document ids to semiring values.

Entries are sorted by doc_id, unique by doc_id, and never store the semiring zero value.

Implementations§

Source§

impl<K> Relation<K>

Source

pub fn new() -> Self

Construct the empty relation.

Source

pub fn entries(&self) -> &[RelationEntry<K>]

Borrow the sorted non-zero entries.

Source

pub fn get(&self, doc_id: DocId) -> Option<&K>

Look up a value by document id.

Source

pub fn support(&self) -> DocSet

Project away values and return the finite support.

Source

pub fn len(&self) -> usize

Number of non-zero entries.

Source

pub fn is_empty(&self) -> bool

Whether the support is empty.

Source

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

Iterate over non-zero entries in document-id order.

Source§

impl<K: Semiring> Relation<K>

Source

pub fn from_support(support: &DocSet) -> Self

Lift a document set to its characteristic relation, assigning the semiring multiplicative identity to every supported document.

Source

pub fn from_terms<I>(terms: I) -> Self
where I: IntoIterator<Item = RelationEntry<K>>,

Construct from possibly unsorted terms, combining duplicate document ids with semiring addition and discarding zero results.

Source

pub fn singleton(doc_id: DocId, value: K) -> Self

Construct a singleton relation. A zero value produces the empty relation.

Source

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

Pointwise semiring addition.

Source

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

Pointwise semiring multiplication.

Trait Implementations§

Source§

impl<K: Clone> Clone for Relation<K>

Source§

fn clone(&self) -> Relation<K>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug> Debug for Relation<K>

Source§

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

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

impl<K: Default> Default for Relation<K>

Source§

fn default() -> Relation<K>

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

impl From<&DocSet> for Relation<bool>

Source§

fn from(support: &DocSet) -> Self

Converts to this type from the input type.
Source§

impl From<DocSet> for Relation<bool>

Source§

fn from(support: DocSet) -> Self

Converts to this type from the input type.
Source§

impl<K> IntoIterator for Relation<K>

Source§

type Item = RelationEntry<K>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<RelationEntry<K>>

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<'a, K> IntoIterator for &'a Relation<K>

Source§

type Item = &'a RelationEntry<K>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, RelationEntry<K>>

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<K: PartialEq> PartialEq for Relation<K>

Source§

fn eq(&self, other: &Relation<K>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<K: PartialEq> StructuralPartialEq for Relation<K>

Auto Trait Implementations§

§

impl<K> Freeze for Relation<K>

§

impl<K> RefUnwindSafe for Relation<K>
where K: RefUnwindSafe,

§

impl<K> Send for Relation<K>
where K: Send,

§

impl<K> Sync for Relation<K>
where K: Sync,

§

impl<K> Unpin for Relation<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for Relation<K>

§

impl<K> UnwindSafe for Relation<K>
where K: UnwindSafe,

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

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