Struct regex_automata::nfa::thompson::map::Utf8SuffixMap
source · pub struct Utf8SuffixMap {
version: u16,
capacity: usize,
map: Vec<Utf8SuffixEntry>,
}
Expand description
A cache of suffixes used to modestly compress UTF-8 automata for large Unicode character classes.
Fields§
§version: u16
The current version of this map. Only entries with matching versions are considered during lookups. If an entry is found with a mismatched version, then the map behaves as if the entry does not exist.
capacity: usize
The total number of entries this map can store.
map: Vec<Utf8SuffixEntry>
The actual entries, keyed by hash. Collisions between different states result in the old state being dropped.
Implementations§
source§impl Utf8SuffixMap
impl Utf8SuffixMap
sourcepub fn new(capacity: usize) -> Utf8SuffixMap
pub fn new(capacity: usize) -> Utf8SuffixMap
Create a new bounded map with the given capacity. The map will never grow beyond the given size.
Note that this does not allocate. Instead, callers must call clear
before using this map. clear
will allocate space if necessary.
This avoids the need to pay for the allocation of this map when compiling regexes that lack large Unicode character classes.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear this map of all entries, but permit the reuse of allocation if possible.
This must be called before the map can be used.
sourcepub fn hash(&self, key: &Utf8SuffixKey) -> usize
pub fn hash(&self, key: &Utf8SuffixKey) -> usize
Return a hash of the given transition.
sourcepub fn get(&mut self, key: &Utf8SuffixKey, hash: usize) -> Option<StateID>
pub fn get(&mut self, key: &Utf8SuffixKey, hash: usize) -> Option<StateID>
Retrieve the cached state ID corresponding to the given key. The hash
given must have been computed with hash
using the same key value.
If there is no cached state with the given key, then None is returned.
sourcepub fn set(&mut self, key: Utf8SuffixKey, hash: usize, state_id: StateID)
pub fn set(&mut self, key: Utf8SuffixKey, hash: usize, state_id: StateID)
Add a cached state to this map with the given key. Callers should
ensure that state_id
points to a state that contains precisely the
NFA transition given.
hash
must have been computed using the hash
method with the same
key.
Trait Implementations§
source§impl Clone for Utf8SuffixMap
impl Clone for Utf8SuffixMap
source§fn clone(&self) -> Utf8SuffixMap
fn clone(&self) -> Utf8SuffixMap
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more