[][src]Trait sophia::term::index_map::TermIndexMap

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>>> { ... } }

A bidirectionnal 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

type Index: Copy + Eq

The type used to represent terms

type Factory: TermFactory

The factory used to instantiate terms.

Loading content...

Associated Constants

const NULL_INDEX: Self::Index

Loading content...

Required methods

fn get_index(&self, t: &RefTerm) -> Option<Self::Index>

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

fn make_index(&mut self, t: &RefTerm) -> Self::Index

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

fn get_term(&self, i: Self::Index) -> Option<&FTerm<Self::Factory>>

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

fn inc_ref(&mut self, i: Self::Index)

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

fn dec_ref(&mut self, i: Self::Index)

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

fn shrink_to_fit(&mut self)

Shrinks the capacity of the TermIndexMap as much as possible.

Loading content...

Provided methods

fn get_index_for_graph_name(&self, g: Option<&RefTerm>) -> Option<Self::Index>

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

fn make_index_for_graph_name(&mut self, g: Option<&RefTerm>) -> Self::Index

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

fn get_graph_name(
    &self,
    i: Self::Index
) -> Option<Option<&FTerm<Self::Factory>>>

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 associetd to a proper graph name.
Loading content...

Implementors

impl<T, F> TermIndexMap for TermIndexMapU<T, F> where
    T: Unsigned,
    F: TermFactory + Default
[src]

This macro implements TermIndexMap for TermIndexMapU, where uXX is one of u16, u32... I would prefer to define a generic implementation using traits, but I found this to be non trivial.

type Index = T

type Factory = F

Loading content...