Trait idmap::table::IdTable [−][src]
pub trait IdTable: Debug + Clone {
fn new() -> Self;
fn with_capacity(capacity: usize) -> Self;
fn get(&self, key_index: TableIndex) -> Option<TableIndex>;
fn create_mut(&mut self, key_index: TableIndex) -> &mut TableIndex;
fn set_raw(&mut self, key_index: TableIndex, value: TableIndex);
fn clear(&mut self);
fn reserve(&mut self, amount: usize);
}
Expand description
Assigns unique u32
indexes to each IntegerId
key,
which can be used to modify the behavior and performance of a DenseEntryTable
.
Currently the only implementation is OrderedIdTable
,
which preserves ordering by using a Vec
DenseEntryTable
s need a separate IdTable
since entries will be stored densely,
though a DirectEntryTable
doesn’t need one at all.
Required methods
fn with_capacity(capacity: usize) -> Self
fn with_capacity(capacity: usize) -> Self
Create a table, initialized with the specified capacity
fn get(&self, key_index: TableIndex) -> Option<TableIndex>
fn get(&self, key_index: TableIndex) -> Option<TableIndex>
Determine the index of the specified key, which may or may not be valid.
In other words this may have ‘false positives’,
so that Some(TableIndex::from(key))
is a correct implementation even though
the index isn’t necessarily in-bounds for the entry table.
However, it can never have ‘false negatives’ so None
and Some(TableIndex::INVALID)
are both wrong.
The TableIndex::INVALID
index is special case and should never be considered valid
under any circumstances.
It is logically equivalent to a None
result, but kept for performance reasons.
fn create_mut(&mut self, key_index: TableIndex) -> &mut TableIndex
fn create_mut(&mut self, key_index: TableIndex) -> &mut TableIndex
Get a mutable reference to the index of the specified key
See also IdTable::get
fn set_raw(&mut self, key_index: TableIndex, value: TableIndex)
fn set_raw(&mut self, key_index: TableIndex, value: TableIndex)
Directly set the value of the specified key