Struct symbol_map::Table [] [src]

pub struct Table<T, D> where D: SymbolId {
    // some fields omitted
}

The head of a linked list associating Ts with SymbolIds. SymbolId values start at 0 and increase by 1 for each T added to the table.

The linked list owns instances of Symbol<T>, which wrap around a T and a SymbolId. It satisfies the contract: once allocated, a Symbol's address does not change as long as its parent table exists and it is not dropped from the table.

As a result, a table index may retain a raw pointer to a Symbol<T> as long as care is taken not to dereference or otherwise make use of such pointers after the symbol they point to has been dropped by retain().

Methods

impl<T, D> Table<T, D> where D: SymbolId
[src]

Creates a new, empty table.

Returns the number of symbols in the table.

Inserts value into the table and assigns it an id. The same value may be inserted more than once. To prevent such operations, use the get_or_insert() method of Indexing.

Returns a reference to the newly created symbol.

Remaps associations between Ts and Ds, selectively dropping some associations entirely. The addresses of Symbol<T>s for entries which are retained do not change.

(T, D) associations for which f returns Some(d) will be remapped to use d.

(T, D) associations for which f returns None will be dropped.

It is the responsibility of the caller to maintain the following:

  • The final mapping should be a dense range of whole numbers starting at 0.

  • No two different Ts are associated with the same D.

Returns an iterator over table entries.

impl<T, D> Table<T, D> where T: Eq + Hash, D: SymbolId
[src]

Converts self to a HashMap holding the same associations as self. If the same key occurs in self more than once, then duplicate occurrences will be dropped arbitrarily.

Trait Implementations

impl<'a, T, D> IntoIterator for &'a Table<T, D> where T: 'a, D: 'a + SymbolId
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<T, D> IntoIterator for Table<T, D> where D: SymbolId
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more