Struct regex_automata::dfa::remapper::IndexMapper
source · struct IndexMapper {
stride2: usize,
}
Expand description
A simple type for mapping between state indices and state IDs.
The reason why this exists is because state IDs are “premultiplied.” That is, in order to get to the transitions for a particular state, one need only use the state ID as-is, instead of having to multiple it by transition table’s stride.
The downside of this is that it’s inconvenient to map between state IDs
using a dense map, e.g., Vec0
, 0+stride
, 0+2*stride
, 0+3*stride
, etc., instead of 0
, 1
,
2
, 3
, etc.
Since our state IDs are premultiplied, we can convert back-and-forth between IDs and indices by simply unmultiplying the IDs and multiplying the indices.
Fields§
§stride2: usize
The power of 2 corresponding to the stride of the corresponding transition table. ‘id >> stride2’ de-multiplies an ID while ‘index << stride2’ pre-multiplies an index to an ID.