Trait symbol_map::indexing::Indexing [] [src]

pub trait Indexing: Default {
    type Data;
    type Id: SymbolId;
    fn from_table(table: Table<Self::Data, Self::Id>) -> Self;
    fn table(&self) -> &Table<Self::Data, Self::Id>;
    fn to_table(self) -> Table<Self::Data, Self::Id>;
    fn get(&self, data: &Self::Data) -> Option<&Symbol<Self::Data, Self::Id>>;
    fn get_or_insert<'s>(&'s mut self, data: Self::Data) -> Insertion<&'s Symbol<Self::Data, Self::Id>>;
    fn get_symbol<'s>(&'s self, id: &Self::Id) -> Option<&'s Symbol<Self::Data, Self::Id>>;
}

Provides indexing for a Table, so that its elements may be retrieved efficiently. Most table lookups should go through an implementation of this trait structure instead of a Table directly.

An Indexing should own an underlying Table<Indexing::Data>. This table provides persistent storage for Symbol<Indexing::Data>s, which associate instances of Data with a SymbolId.

This trait is provided for extensibility. Realistically speaking, however, you should probably just use HashIndexing.

Associated Types

The type T of a Table<T, D>.

The type D of a Table<T, D>.

Required Methods

Returns a new indexing method that has already indexed the contents of table.

Returns a read-only view of the underlying table.

Extracts the underlying table from the index, discarding all pointers into the table.

Looks up data in the index. Returns Some(&symbol) if a symbol is present, else None.

Looks up data in the index, inserting it into the index and table if it isn't present. Returns the resulting &Symbol<T> wrapped in an Insertion that indicates whether a new table entry had to be created.

Looks up the symbol with id i in the index. Returns Some(symbol) if a symbol is present, else None.

Implementors