Table of Contents

Class LetterMap<T>

Namespace
Rinku.Querying
Assembly
Rinku.dll

Maps ASCII letters to values without treating case as different. Other characters are not supported. Enumeration follows alphabetical order.

public class LetterMap<T> : IDictionary<char, T>, ICollection<KeyValuePair<char, T>>, IEnumerable<KeyValuePair<char, T>>, IEnumerable

Type Parameters

T
Inheritance
LetterMap<T>
Implements
Inherited Members
Extension Methods

Constructors

LetterMap()

Creates an empty letter map.

public LetterMap()

LetterMap(params ReadOnlySpan<(char, T)>)

Creates a map from the supplied letter and value pairs.

public LetterMap(params ReadOnlySpan<(char, T)> items)

Parameters

items ReadOnlySpan<(char, T)>

The initial items to populate the map.

Properties

Count

Gets the number of unique letters currently mapped.

public int Count { get; }

Property Value

int

IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

public bool IsReadOnly { get; }

Property Value

bool

true if the ICollection<T> is read-only; otherwise, false.

this[char]

The value associated with the specified letter.

public T this[char key] { get; set; }

Parameters

key char

The letter (A-Z or a-z).

Property Value

T

Exceptions

KeyNotFoundException

Thrown on retrieval if the letter is missing.

ArgumentOutOfRangeException

Thrown if the character is not a Latin letter.

Keys

Gets an ICollection<T> containing the keys of the IDictionary<TKey, TValue>.

public ICollection<char> Keys { get; }

Property Value

ICollection<char>

An ICollection<T> containing the keys of the object that implements IDictionary<TKey, TValue>.

PresenceMap

Gets a bitmask representing the current set of letters present in the map. Bit 0 corresponds to 'a', bit 25 to 'z'.

public uint PresenceMap { get; }

Property Value

uint

Values

Gets an ICollection<T> containing the values in the IDictionary<TKey, TValue>.

public ICollection<T> Values { get; }

Property Value

ICollection<T>

An ICollection<T> containing the values in the object that implements IDictionary<TKey, TValue>.

Methods

Add(char, T)

Adds a letter and value. Throws when the letter already exists.

public void Add(char key, T value)

Parameters

key char
value T

Add(KeyValuePair<char, T>)

Adds an item to the ICollection<T>.

public void Add(KeyValuePair<char, T> item)

Parameters

item KeyValuePair<char, T>

The object to add to the ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Clear()

Removes all items from the ICollection<T>.

public void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Contains(KeyValuePair<char, T>)

Determines whether the ICollection<T> contains a specific value.

public bool Contains(KeyValuePair<char, T> item)

Parameters

item KeyValuePair<char, T>

The object to locate in the ICollection<T>.

Returns

bool

true if item is found in the ICollection<T>; otherwise, false.

ContainsKey(char)

Returns whether the ASCII letter exists in the map.

public bool ContainsKey(char key)

Parameters

key char

Returns

bool

CopyTo(KeyValuePair<char, T>[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

public void CopyTo(KeyValuePair<char, T>[] array, int arrayIndex)

Parameters

array KeyValuePair<char, T>[]

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<KeyValuePair<char, T>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<char, T>>

An enumerator that can be used to iterate through the collection.

Remove(char)

Removes a letter from the map.

public bool Remove(char key)

Parameters

key char

Returns

bool

True if the letter was found and removed, otherwise false.

Remove(KeyValuePair<char, T>)

Removes the first occurrence of a specific object from the ICollection<T>.

public bool Remove(KeyValuePair<char, T> item)

Parameters

item KeyValuePair<char, T>

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

ResetWith(params ReadOnlySpan<(char, T)>)

Replaces the map contents with the supplied items.

public void ResetWith(params ReadOnlySpan<(char, T)> items)

Parameters

items ReadOnlySpan<(char, T)>

A span of character-value pairs to initialize the map.

Remarks

If duplicate letters are provided in the input, the last occurrence will determine the final value for that letter.

TryGetValue(char, out T)

Tries to get the value for an ASCII letter. Returns false when it is missing.

public bool TryGetValue(char key, out T value)

Parameters

key char
value T

Returns

bool