Interface IOrderedDictionary<TKey, TValue>
- Namespace
- Renci.SshNet
- Assembly
- Renci.SshNet.dll
Represents a collection of key/value pairs that are accessible by the key or index.
public interface IOrderedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : notnull
Type Parameters
TKey
-
The type of the keys in the dictionary.
TValue
-
The type of the values in the dictionary.
Implements
Properties
Count
Gets the number of key/value pairs contained in the Renci.SshNet.IOrderedDictionary`2.
int Count { get; }
Property Value
Keys
Gets a collection containing the keys in the Renci.SshNet.IOrderedDictionary`2.
ICollection<TKey> Keys { get; }
Property Value
- ICollection<TKey>
Values
Gets a collection containing the values in the Renci.SshNet.IOrderedDictionary`2.
ICollection<TValue> Values { get; }
Property Value
- ICollection<TValue>
this[TKey]
Gets or sets the value associated with the specified key.
TValue this[TKey key] { get; set; }
Property Value
- TValue
Remarks
Setting the value of an existing key does not impact its order in the collection.
Exceptions
- ArgumentNullException
-
key
is null. - KeyNotFoundException
-
The property is retrieved and
key
does not exist in the collection.
Methods
ContainsKey(TKey)
Determines whether the Renci.SshNet.IOrderedDictionary`2 contains the specified key.
bool ContainsKey(TKey key)
Parameters
key
TKey-
The key to locate in the Renci.SshNet.IOrderedDictionary`2.
Returns
- bool
-
true if the Renci.SshNet.IOrderedDictionary`2 contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
-
key
is null.
ContainsValue(TValue)
Determines whether the Renci.SshNet.IOrderedDictionary`2 contains a specific value.
bool ContainsValue(TValue value)
Parameters
value
TValue-
The value to locate in the Renci.SshNet.IOrderedDictionary`2. The value can be null for reference types.
Returns
- bool
-
true if the Renci.SshNet.IOrderedDictionary`2 contains an element with the specified value; otherwise, false.
GetAt(int)
Gets the key/value pair at the specified index.
KeyValuePair<TKey, TValue> GetAt(int index)
Parameters
index
int-
The zero-based index of the pair to get.
Returns
- KeyValuePair<TKey, TValue>
-
The element at the specified index.
Exceptions
- ArgumentOutOfRangeException
-
index
is less than 0 or greater than or equal to Renci.SshNet.IOrderedDictionary`2.Count.
IndexOf(TKey)
Determines the index of a specific key in the Renci.SshNet.IOrderedDictionary`2.
int IndexOf(TKey key)
Parameters
key
TKey-
The key to locate.
Returns
- int
-
The index of
key
if found; otherwise, -1.
Exceptions
- ArgumentNullException
-
key
is null.
Insert(int, TKey, TValue)
Inserts an item into the collection at the specified index.
void Insert(int index, TKey key, TValue value)
Parameters
index
int-
The zero-based index at which item should be inserted.
key
TKey-
The key to insert.
value
TValue-
The value to insert.
Exceptions
- ArgumentNullException
-
key
is null. - ArgumentException
-
An element with the same key already exists in the Renci.SshNet.IOrderedDictionary`2.
- ArgumentOutOfRangeException
-
index
is less than 0 or greater than Renci.SshNet.IOrderedDictionary`2.Count.
Remove(TKey, out TValue)
Removes the value with the specified key from the Renci.SshNet.IOrderedDictionary`2 and copies the element to the value parameter.
bool Remove(TKey key, out TValue value)
Parameters
key
TKey-
The key of the element to remove.
value
TValue-
The removed element.
Returns
Exceptions
- ArgumentNullException
-
key
is null.
RemoveAt(int)
Removes the key/value pair at the specified index.
void RemoveAt(int index)
Parameters
index
int-
The zero-based index of the item to remove.
Exceptions
- ArgumentOutOfRangeException
-
index
is less than 0 or greater than or equal to Renci.SshNet.IOrderedDictionary`2.Count.
SetAt(int, TKey, TValue)
Sets the key/value pair at the specified index.
void SetAt(int index, TKey key, TValue value)
Parameters
index
int-
The zero-based index at which to set the key/value pair.
key
TKey-
The key to store at the specified index.
value
TValue-
The value to store at the specified index.
Exceptions
- ArgumentNullException
-
key
is null. - ArgumentException
-
An element with the same key already exists at an index different to
index
. - ArgumentOutOfRangeException
-
index
is less than 0 or greater than or equal to Renci.SshNet.IOrderedDictionary`2.Count.
SetAt(int, TValue)
Sets the value for the key at the specified index.
void SetAt(int index, TValue value)
Parameters
index
int-
The zero-based index at which to set the key/value pair.
value
TValue-
The value to store at the specified index.
Exceptions
- ArgumentOutOfRangeException
-
index
is less than 0 or greater than or equal to Renci.SshNet.IOrderedDictionary`2.Count.
SetPosition(int, int)
Moves an existing key/value pair to the specified index in the collection.
void SetPosition(int index, int newIndex)
Parameters
index
int-
The current zero-based index of the key/value pair to move.
newIndex
int-
The zero-based index at which to set the key/value pair.
Exceptions
- ArgumentOutOfRangeException
-
index
ornewIndex
are less than 0 or greater than or equal to Renci.SshNet.IOrderedDictionary`2.Count.
SetPosition(TKey, int)
Moves an existing key/value pair to the specified index in the collection.
void SetPosition(TKey key, int newIndex)
Parameters
key
TKey-
The key to move.
newIndex
int-
The zero-based index at which to set the key/value pair.
Exceptions
- KeyNotFoundException
-
The specified key does not exist in the collection.
- ArgumentOutOfRangeException
-
newIndex
is less than 0 or greater than or equal to Renci.SshNet.IOrderedDictionary`2.Count.
TryAdd(TKey, TValue)
Adds the specified key and value to the dictionary if the key doesn't already exist.
bool TryAdd(TKey key, TValue value)
Parameters
key
TKey-
The key of the element to add.
value
TValue-
The value of the element to add. The value can be null for reference types.
Returns
- bool
-
true if the key didn't exist and the key and value were added to the dictionary; otherwise, false.
Exceptions
- ArgumentNullException
-
key
is null.
TryAdd(TKey, TValue, out int)
Adds the specified key and value to the dictionary if the key doesn't already exist.
bool TryAdd(TKey key, TValue value, out int index)
Parameters
key
TKey-
The key of the element to add.
value
TValue-
The value of the element to add. The value can be null for reference types.
index
int-
The index of the added or existing
key
. This is always a valid index into the dictionary.
Returns
- bool
-
true if the key didn't exist and the key and value were added to the dictionary; otherwise, false.
Exceptions
- ArgumentNullException
-
key
is null.
TryGetValue(TKey, out TValue)
Gets the value associated with the specified key.
bool TryGetValue(TKey key, out TValue value)
Parameters
key
TKey-
The key of the value to get.
value
TValue-
When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter.
Returns
- bool
-
true if the Renci.SshNet.IOrderedDictionary`2 contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
-
key
is null.
TryGetValue(TKey, out TValue, out int)
Gets the value associated with the specified key.
bool TryGetValue(TKey key, out TValue value, out int index)
Parameters
key
TKey-
The key of the value to get.
value
TValue-
When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter.
index
int-
The index of
key
if found; otherwise, -1.
Returns
- bool
-
true if the Renci.SshNet.IOrderedDictionary`2 contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
-
key
is null.