Class BitwiseVectorDictionary
- Namespace
- BelNytheraSeiche.TrieDictionary
- Assembly
- BelNytheraSeiche.TrieDictionary.dll
A concrete implementation of KeyRecordDictionary that uses a high-performance, array-based trie structure.
public abstract class BitwiseVectorDictionary : LevelOrderBitsDictionary, KeyRecordDictionary.IKeyAccess
- Inheritance
-
BitwiseVectorDictionary
- Implements
- Inherited Members
Remarks
This class represents a trie data structure that is flattened into a series of arrays using a level-order (breadth-first) build process. The tree's topology is stored using integer arrays for parent/child relationships, while a bit vector is used to mark terminal nodes. This approach prioritizes lookup performance and a relatively straightforward implementation over the extreme memory compactness of structures like LOUDS.
Important Usage Notes:
- Read-Only Structure: The dictionary is built once from a collection of keys and is effectively read-only afterward. Key addition and removal operations are not supported and will throw a NotSupportedException.
- Key Reconstruction: Getting a key by its identifier requires traversing the structure from a node up to the root.
Methods
Create(IEnumerable<byte[]>, SearchDirectionType)
Creates a new BitwiseVectorDictionary from a collection of keys.
public static BitwiseVectorDictionary Create(IEnumerable<byte[]> keys, KeyRecordDictionary.SearchDirectionType searchDirection = SearchDirectionType.LTR)
Parameters
keysIEnumerable<byte[]>An enumerable collection of byte arrays to use as the initial keys. The collection does not need to be pre-sorted. Duplicate keys are permitted, but only the first occurrence will be added. The collection must not contain any elements that are null or empty byte array.
searchDirectionKeyRecordDictionary.SearchDirectionTypeThe key search direction for the new dictionary.
Returns
- BitwiseVectorDictionary
A new, optimized, and read-only BitwiseVectorDictionary instance.
Remarks
The input keys are sorted and used to construct the Bitwise-Vector trie representation.
Exceptions
- ArgumentNullException
keysis null.
Deserialize(Stream)
Deserializes a dictionary from a stream.
public static BitwiseVectorDictionary Deserialize(Stream stream)
Parameters
streamStreamThe stream to read the serialized data from.
Returns
- BitwiseVectorDictionary
A new instance of BitwiseVectorDictionary.
Exceptions
- ArgumentNullException
streamis null.- InvalidDataException
The stream data is corrupted or in an unsupported format.
Serialize(BitwiseVectorDictionary, Stream, SerializationOptions?)
Serializes the state of the dictionary into a stream.
public static void Serialize(BitwiseVectorDictionary dictionary, Stream stream, KeyRecordDictionary.SerializationOptions? options = null)
Parameters
dictionaryBitwiseVectorDictionaryThe dictionary instance to serialize.
streamStreamThe stream to write the serialized data to.
optionsKeyRecordDictionary.SerializationOptionsOptions to control the serialization process. If null, the settings from Default will be used.
Remarks
The serialization format is a custom binary format specific to this Bitwise-Vector implementation.
Exceptions
- ArgumentNullException
dictionaryorstreamis null.