pub trait TermIndexMap: Default {
    type Index: Copy + Eq;
    type Factory: TermFactory;

    const NULL_INDEX: Self::Index;

    fn get_index(&self, t: &RefTerm<'_>) -> Option<Self::Index>;
fn make_index(&mut self, t: &RefTerm<'_>) -> Self::Index;
fn get_term(&self, i: Self::Index) -> Option<&FTerm<Self::Factory>>;
fn inc_ref(&mut self, i: Self::Index);
fn dec_ref(&mut self, i: Self::Index);
fn shrink_to_fit(&mut self); fn get_index_for_graph_name(
        &self,
        g: Option<&RefTerm<'_>>
    ) -> Option<Self::Index> { ... }
fn make_index_for_graph_name(
        &mut self,
        g: Option<&RefTerm<'_>>
    ) -> Self::Index { ... }
fn get_graph_name(
        &self,
        i: Self::Index
    ) -> Option<Option<&FTerm<Self::Factory>>> { ... } }
Expand description

A bidirectional mapping between Terms and indexes of a smaller type.

The TermIndexMap maintains a reference count for each index, to automatically free them whenever they are not used.

One special index (called the null index) is never mapped to any Term, and is used to represent None (the absence of graph name in a Quad).

Associated Types

The type used to represent terms

The factory used to instantiate terms.

Associated Constants

A reserved index representing no term

Required methods

Return the index associated to the given term, if it exists.

Return the index associated to the given term, creating it if required, and increasing its ref count.

Return the term associated to the given index, if it exists.

Increase the reference count of a given index (or do nothing if i is the null index).

Decrease the reference count of a given index (or do nothing if i is the null index).

Shrinks the capacity of the TermIndexMap as much as possible.

Provided methods

Return the index associated to the given graph name, if it exists.

Return the index associated to the given graph name, creating it if required, and increasing its ref count.

Return the graph name associated to the given index, if it exists.

NB: a graph name is already an Option, None meaning the (unnamed) default graph. As a consequence, this methods returns an option of option :

  • None means that given index is not associated to any graph name,
  • Some(None) means that the given index is associated to the default graph,
  • Some(Some(term)) means that given index is associated to a proper graph name.

Implementors