Trait sophia_term::index_map::TermIndexMap
source · [−]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 Term
s 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 Factory: TermFactory
type Factory: TermFactory
The factory used to instantiate terms.
Associated Constants
const NULL_INDEX: Self::Index
const NULL_INDEX: Self::Index
A reserved index representing no term
Required methods
Return the index associated to the given term, if it exists.
fn make_index(&mut self, t: &RefTerm<'_>) -> Self::Index
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.
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).
fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
Shrinks the capacity of the TermIndexMap as much as possible.
Provided methods
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
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.
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.