Class CharSpanLookupDictionary<TValue>
Represents collection of string keys and TValue
values, allowing the use of System.ReadOnlySpan<T> for dictionary operations.
Inheritance
Namespace: DisCatSharp.Common
Assembly: DisCatSharp.Common.dll
Syntax
public sealed class CharSpanLookupDictionary<TValue> : IDictionary<string, TValue>, ICollection<KeyValuePair<string, TValue>>, IReadOnlyDictionary<string, TValue>, IReadOnlyCollection<KeyValuePair<string, TValue>>, IEnumerable<KeyValuePair<string, TValue>>, IDictionary, ICollection, IEnumerable
Type Parameters
Name | Description |
---|---|
TValue | Type of items in this dictionary. |
Constructors
| Improve this Doc View SourceCharSpanLookupDictionary()
Creates a new, empty CharSpanLookupDictionary<TValue> with string keys and items of type TValue
.
Declaration
public CharSpanLookupDictionary()
CharSpanLookupDictionary(IDictionary<String, TValue>)
Creates a new CharSpanLookupDictionary<TValue> with string keys and items of type TValue
and populates it with key-value pairs from supplied dictionary.
Declaration
public CharSpanLookupDictionary(IDictionary<string, TValue> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<System.String, TValue> | values | Dictionary containing items to populate this dictionary with. |
CharSpanLookupDictionary(IEnumerable<KeyValuePair<String, TValue>>)
Creates a new CharSpanLookupDictionary<TValue> with string keys and items of type TValue
and populates it with key-value pairs from supplied key-value collection.
Declaration
public CharSpanLookupDictionary(IEnumerable<KeyValuePair<string, TValue>> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, TValue>> | values | Dictionary containing items to populate this dictionary with. |
CharSpanLookupDictionary(IReadOnlyDictionary<String, TValue>)
Creates a new CharSpanLookupDictionary<TValue> with string keys and items of type TValue
and populates it with key-value pairs from supplied dictionary.
Declaration
public CharSpanLookupDictionary(IReadOnlyDictionary<string, TValue> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.String, TValue> | values | Dictionary containing items to populate this dictionary with. |
CharSpanLookupDictionary(Int32)
Creates a new, empty CharSpanLookupDictionary<TValue> with string keys and items of type TValue
and sets its initial capacity to specified value.
Declaration
public CharSpanLookupDictionary(int initialCapacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | initialCapacity | Initial capacity of the dictionary. |
Properties
| Improve this Doc View SourceCount
Gets the total number of items in this dictionary.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsFixedSize
Gets whether this dictionary has a fixed size.
Declaration
public bool IsFixedSize { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsReadOnly
Gets whether this dictionary is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSynchronized
Gets whether this dictionary is considered thread-safe.
Declaration
public bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[ReadOnlySpan<Char>]
Gets or sets a value corresponding to given key in this dictionary.
Declaration
public TValue this[ReadOnlySpan<char> key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | key | Key to get or set the value for. |
Property Value
Type | Description |
---|---|
TValue | Value matching the supplied key, if applicable. |
Item[String]
Gets or sets a value corresponding to given key in this dictionary.
Declaration
public TValue this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key to get or set the value for. |
Property Value
Type | Description |
---|---|
TValue | Value matching the supplied key, if applicable. |
Keys
Gets the collection of all keys present in this dictionary.
Declaration
public IEnumerable<string> Keys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
SyncRoot
Gets the object which allows synchronizing access to this dictionary.
Declaration
public object SyncRoot { get; }
Property Value
Type | Description |
---|---|
System.Object |
Values
Gets the collection of all values present in this dictionary.
Declaration
public IEnumerable<TValue> Values { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TValue> |
Methods
| Improve this Doc View SourceAdd(ReadOnlySpan<Char>, TValue)
Inserts a specific key and corresponding value into this dictionary.
Declaration
public void Add(ReadOnlySpan<char> key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | key | Key to insert. |
TValue | value | Value corresponding to this key. |
Add(String, TValue)
Inserts a specific key and corresponding value into this dictionary.
Declaration
public void Add(string key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key to insert. |
TValue | value | Value corresponding to this key. |
Clear()
Removes all items from this dictionary.
Declaration
public void Clear()
ContainsKey(ReadOnlySpan<Char>)
Checks whether this dictionary contains the specified key.
Declaration
public bool ContainsKey(ReadOnlySpan<char> key)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | key | Key to check for in this dictionary. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the key was present in the dictionary. |
ContainsKey(String)
Checks whether this dictionary contains the specified key.
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key to check for in this dictionary. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the key was present in the dictionary. |
GetEnumerator()
Gets an enumerator over key-value pairs in this dictionary.
Declaration
public IEnumerator<KeyValuePair<string, TValue>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, TValue>> |
TryAdd(ReadOnlySpan<Char>, TValue)
Attempts to insert a specific key and corresponding value into this dictionary.
Declaration
public bool TryAdd(ReadOnlySpan<char> key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | key | Key to insert. |
TValue | value | Value corresponding to this key. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful. |
TryAdd(String, TValue)
Attempts to insert a specific key and corresponding value into this dictionary.
Declaration
public bool TryAdd(string key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key to insert. |
TValue | value | Value corresponding to this key. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful. |
TryGetValue(ReadOnlySpan<Char>, out TValue)
Attempts to retrieve a value corresponding to the supplied key from this dictionary.
Declaration
public bool TryGetValue(ReadOnlySpan<char> key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | key | Key to retrieve the value for. |
TValue | value | Retrieved value. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful. |
TryGetValue(String, out TValue)
Attempts to retrieve a value corresponding to the supplied key from this dictionary.
Declaration
public bool TryGetValue(string key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key to retrieve the value for. |
TValue | value | Retrieved value. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful. |
TryRemove(ReadOnlySpan<Char>, out TValue)
Attempts to remove a value corresponding to the supplied key from this dictionary.
Declaration
public bool TryRemove(ReadOnlySpan<char> key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | key | Key to remove the value for. |
TValue | value | Removed value. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful. |
TryRemove(String, out TValue)
Attempts to remove a value corresponding to the supplied key from this dictionary.
Declaration
public bool TryRemove(string key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | Key to remove the value for. |
TValue | value | Removed value. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the operation was successful. |