Skip to main content

IOrderedDictionary<TKey, TValue>

Represents a generic collection of key/value pairs that are ordered independently of the key and value.

Assembly: ServiceStack.Redis.dll
View Source
Declaration
public interface IOrderedDictionary<TKey, TValue> : IOrderedDictionary, IDictionary, ICollection, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Properties

Item[Int32]

Gets or sets the value at the specified index.

View Source
Declaration
TValue this[int index] { get; set; }

Methods

Add(TKey, TValue)

Adds an entry with the specified key and value into the ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e collection with the lowest available index.

<p>You can also use the <xref href="System.Collections.Generic.IDictionary%7bTKey%2cTValue%7d.Item(TKey)" data-throw-if-not-resolved="false"></xref> property to add new elements by setting the value of a key that does not exist in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref> collection; however, if the specified key already exists in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref>, setting the <xref href="Item(TKey)" data-throw-if-not-resolved="false"></xref> property overwrites the old value. In contrast, the <xref href="Add" data-throw-if-not-resolved="false"></xref> method does not modify existing elements.</p>

View Source
Declaration
int Add(TKey key, TValue value)
Returns

System.Int32: The index of the newly added entry

<p>You can also use the <xref href="System.Collections.Generic.IDictionary%7bTKey%2cTValue%7d.Item(TKey)" data-throw-if-not-resolved="false"></xref> property to add new elements by setting the value of a key that does not exist in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref> collection; however, if the specified key already exists in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref>, setting the <xref href="Item(TKey)" data-throw-if-not-resolved="false"></xref> property overwrites the old value. In contrast, the <xref href="Add" data-throw-if-not-resolved="false"></xref> method does not modify existing elements.</p>

Parameters
TypeNameDescription
<TKey>keyThe key of the entry to add.

<p>You can also use the <xref href="System.Collections.Generic.IDictionary%7bTKey%2cTValue%7d.Item(TKey)" data-throw-if-not-resolved="false"></xref> property to add new elements by setting the value of a key that does not exist in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref> collection; however, if the specified key already exists in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref>, setting the <xref href="Item(TKey)" data-throw-if-not-resolved="false"></xref> property overwrites the old value. In contrast, the <xref href="Add" data-throw-if-not-resolved="false"></xref> method does not modify existing elements.</p> | | <TValue> | value | The value of the entry to add.

<p>You can also use the <xref href="System.Collections.Generic.IDictionary%7bTKey%2cTValue%7d.Item(TKey)" data-throw-if-not-resolved="false"></xref> property to add new elements by setting the value of a key that does not exist in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref> collection; however, if the specified key already exists in the <xref href="ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e" data-throw-if-not-resolved="false"></xref>, setting the <xref href="Item(TKey)" data-throw-if-not-resolved="false"></xref> property overwrites the old value. In contrast, the <xref href="Add" data-throw-if-not-resolved="false"></xref> method does not modify existing elements.</p> |

Insert(Int32, TKey, TValue)

Inserts a new entry into the ServiceStack.Redis.Support.IOrderedDictionary%602?text=IOrderedDictionary%3cTKey%2cTValue%3e collection with the specified key and value at the specified index.

View Source
Declaration
void Insert(int index, TKey key, TValue value)
Parameters
TypeNameDescription
System.Int32indexThe zero-based index at which the element should be inserted.

| | <TKey> | key | The key of the entry to add.

| | <TValue> | value | The value of the entry to add. The value can be <null></null> if the type of the values in the dictionary is a reference type.

|