Class KeyRecordDictionary
- Namespace
- BelNytheraSeiche.TrieDictionary
- Assembly
- BelNytheraSeiche.TrieDictionary.dll
An abstract base class for advanced key-record dictionaries.
public abstract class KeyRecordDictionary
- Inheritance
-
KeyRecordDictionary
- Derived
- Inherited Members
Remarks
This class provides a framework for mapping byte array keys to linked lists of data records. It features a dual-storage system (transient and persistent) for records, supports different key search directions (LTR/RTL), and allows for custom metadata storage. Concrete implementations are expected to provide the specific key management structure (e.g., a trie).
Constructors
KeyRecordDictionary(SearchDirectionType)
An abstract base class for advanced key-record dictionaries.
protected KeyRecordDictionary(KeyRecordDictionary.SearchDirectionType searchDirection)
Parameters
searchDirectionKeyRecordDictionary.SearchDirectionTypeThe key search direction for the new dictionary.
Remarks
This class provides a framework for mapping byte array keys to linked lists of data records. It features a dual-storage system (transient and persistent) for records, supports different key search directions (LTR/RTL), and allows for custom metadata storage. Concrete implementations are expected to provide the specific key management structure (e.g., a trie).
Properties
Additional1
Gets or sets a small, general-purpose byte array for additional persistent data.
public byte[] Additional1 { get; set; }
Property Value
- byte[]
Remarks
The size of the byte array cannot exceed 4096 bytes.
Exceptions
- ArgumentNullException
The assigned value is null.
- ArgumentOutOfRangeException
The length of the assigned byte array is greater than 4096.
Additional2
Gets or sets a large, general-purpose byte array for additional persistent data.
public byte[] Additional2 { get; set; }
Property Value
- byte[]
Remarks
The size of the byte array cannot exceed 1,073,741,824 bytes (1 GB).
Exceptions
- ArgumentNullException
The assigned value is null.
- ArgumentOutOfRangeException
The length of the assigned byte array is greater than 1 GB.
SearchDirection
Gets the search direction (Left-To-Right or Right-To-Left) for key operations.
public KeyRecordDictionary.SearchDirectionType SearchDirection { get; }
Property Value
Methods
Create<T>(SearchDirectionType)
Creates a new instance of a derived dictionary type with an empty set of keys.
public static T Create<T>(KeyRecordDictionary.SearchDirectionType searchDirection = SearchDirectionType.LTR) where T : KeyRecordDictionary
Parameters
searchDirectionKeyRecordDictionary.SearchDirectionTypeThe key search direction for the new dictionary.
Returns
- T
A new instance of the specified dictionary type.
Type Parameters
TThe concrete type of the dictionary to create.
Create<T>(IEnumerable<byte[]>, SearchDirectionType)
Creates a new instance of a derived dictionary type, populated with an initial set of keys.
public static T Create<T>(IEnumerable<byte[]> keys, KeyRecordDictionary.SearchDirectionType searchDirection = SearchDirectionType.LTR) where T : KeyRecordDictionary
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
- T
A new instance of the specified dictionary type.
Type Parameters
TThe concrete type of the dictionary to create.
Remarks
This method uses reflection to invoke the static Create method on the concrete derived type T.
Exceptions
- ArgumentNullException
keysis null.
Create<T>(IEnumerable<string>, Encoding?, SearchDirectionType)
Creates a new instance of a derived dictionary type, populated with an initial set of string keys.
public static T Create<T>(IEnumerable<string> keys, Encoding? encoding = null, KeyRecordDictionary.SearchDirectionType searchDirection = SearchDirectionType.LTR) where T : KeyRecordDictionary
Parameters
keysIEnumerable<string>An enumerable collection of strings 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 strings.
encodingEncodingThe encoding to use for converting strings to bytes. Defaults to UTF-8.
searchDirectionKeyRecordDictionary.SearchDirectionTypeThe key search direction for the new dictionary.
Returns
- T
A new instance of the specified dictionary type.
Type Parameters
TThe concrete type of the dictionary to create.
Exceptions
- ArgumentNullException
keysis null.
Deserialize<T>(byte[])
Deserializes a dictionary from a byte array.
public static T Deserialize<T>(byte[] data) where T : KeyRecordDictionary
Parameters
databyte[]The byte array containing the serialized data.
Returns
- T
A new instance of
T.
Type Parameters
TThe concrete type of the dictionary to deserialize.
Remarks
This static method uses reflection to invoke the static Deserialize method on the specified type T.
Exceptions
- ArgumentNullException
datais null.
Deserialize<T>(Stream)
Deserializes a dictionary from a stream.
public static T Deserialize<T>(Stream stream) where T : KeyRecordDictionary
Parameters
streamStreamThe stream to read the serialized data from.
Returns
- T
A new instance of
T.
Type Parameters
TThe concrete type of the dictionary to deserialize.
Exceptions
- ArgumentNullException
streamis null.- NotSupportedException
The type
Tdoes not have a public staticDeserialize(Stream)method.
Deserialize<T>(string)
Deserializes a dictionary from a file.
public static T Deserialize<T>(string file) where T : KeyRecordDictionary
Parameters
filestringThe path of the file to read from.
Returns
- T
A new instance of
T.
Type Parameters
TThe concrete type of the dictionary to deserialize.
Remarks
This static method uses reflection to invoke the static Deserialize method on the specified type T.
Exceptions
- ArgumentNullException
fileis null.- ArgumentException
fileis empty or whitespace.
Serialize<T>(T, SerializationOptions?)
Serializes the specified dictionary instance into a byte array.
public static byte[] Serialize<T>(T obj, KeyRecordDictionary.SerializationOptions? options = null) where T : KeyRecordDictionary
Parameters
objTThe dictionary instance to serialize.
optionsKeyRecordDictionary.SerializationOptionsOptions to control the serialization process. If null, the settings from Default will be used.
Returns
- byte[]
A byte array containing the serialized data.
Type Parameters
TThe concrete type of the dictionary.
Remarks
This static method uses reflection to invoke the static Serialize method on the concrete derived type T.
Exceptions
- ArgumentNullException
objis null.
Serialize<T>(T, Stream, SerializationOptions?)
Serializes the specified dictionary instance into a stream.
public static void Serialize<T>(T obj, Stream stream, KeyRecordDictionary.SerializationOptions? options = null) where T : KeyRecordDictionary
Parameters
objTThe 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.
Type Parameters
TThe concrete type of the dictionary.
Exceptions
- ArgumentNullException
objorstreamis null.- NotSupportedException
The type
Tdoes not have a public staticSerialize(T, Stream)method.
Serialize<T>(T, string, SerializationOptions?)
Serializes the specified dictionary instance to a file.
public static void Serialize<T>(T obj, string file, KeyRecordDictionary.SerializationOptions? options = null) where T : KeyRecordDictionary
Parameters
objTThe dictionary instance to serialize.
filestringThe path of the file to create.
optionsKeyRecordDictionary.SerializationOptionsOptions to control the serialization process. If null, the settings from Default will be used.
Type Parameters
TThe concrete type of the dictionary.
Remarks
This static method uses reflection to invoke the static Serialize method on the concrete derived type T.
Exceptions
- ArgumentNullException
objorfileis null.- ArgumentException
fileis empty or whitespace.