Skip to main content

Module unimap

Module unimap 

Source
Expand description

This module implements the UniMap, which is a way to get efficient mappings optimized for the setting of tree_borrows/tree.rs.

A UniKeyMap<K> is a (slow) mapping from K to UniIndex, and UniValMap<V> is a (fast) mapping from UniIndex to V. Thus a pair (UniKeyMap<K>, UniValMap<V>) acts as a virtual HashMap<K, V>.

Because of the asymmetry in access time, the use-case for UniMap is the following: a tuple (UniKeyMap<K>, Vec<UniValMap<V>>) is much more efficient than the equivalent Vec<HashMap<K, V>> it represents if all maps have similar sets of keys.

Re-exportsยง

use std::fmt::Debug; ๐Ÿ”’
use std::fmt::Debug; ๐Ÿ”’
use std::hash::Hash; ๐Ÿ”’
use std::hash::Hash; ๐Ÿ”’
use std::mem; ๐Ÿ”’
use rustc_data_structures::fx::FxHashMap; ๐Ÿ”’
use crate::helpers::ToUsize; ๐Ÿ”’

Modulesยง

tests ๐Ÿ”’

Structsยง

UniEntry
An access to a single value of the map.
UniIndex
Intermediate key between a UniKeyMap and a UniValMap.
UniKeyMap
From K to UniIndex
UniValMap
From UniIndex to V