Class SortedListEx
Optimized version of the SortedList collection. Instead of keeping two arrays, one for keys and one for values, we change values on the Hashtable collection and only keep the keys collection sorted.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.HTMLUI
Assembly: Syncfusion.HTMLUI.Windows.dll
Syntax
public class SortedListEx : IDictionary, ICollection, IEnumerable, ICloneable
Constructors
SortedListEx()
Initializes a new instance of the SortedListEx class
Declaration
public SortedListEx()
SortedListEx(IComparer)
Initializes a new instance of the SortedListEx class
Declaration
public SortedListEx(IComparer comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IComparer | comparer | The IComparer to use to determine whether two keys are equal. |
SortedListEx(IComparer, Int32)
Initializes a new instance of the SortedListEx class
Declaration
public SortedListEx(IComparer comparer, int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IComparer | comparer | Initial capacity. |
System.Int32 | capacity | The IComparer to use to determine whether two keys are equal. |
SortedListEx(IDictionary)
Initializes a new instance of the SortedListEx class
Declaration
public SortedListEx(IDictionary d)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IDictionary | d | The IDictionary to copy. |
SortedListEx(IDictionary, IComparer)
Initializes a new instance of the SortedListEx class
Declaration
public SortedListEx(IDictionary d, IComparer comparer)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IDictionary | d | The IDictionary to copy. |
System.Collections.IComparer | comparer | The IComparer to use to determine whether two keys are equal. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When argument d is NULL. |
SortedListEx(Int32)
Initializes a new instance of the SortedListEx class
Declaration
public SortedListEx(int initialCapacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | initialCapacity | Initial capacity. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When initial capacity is less than zero. |
Properties
Capacity
Gets or sets the capacity of internal buffers.
Declaration
public virtual int Capacity { get; set; }
Property Value
Type |
---|
System.Int32 |
Count
Gets the size of the collection. Read-only.
Declaration
public virtual int Count { get; }
Property Value
Type |
---|
System.Int32 |
IsFixedSize
Gets a value indicating whether the collection has fixed size.
Declaration
public virtual bool IsFixedSize { get; }
Property Value
Type |
---|
System.Boolean |
IsReadOnly
Gets a value indicating whether the list is Read-only.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
Type |
---|
System.Boolean |
IsSynchronized
Gets a value indicating whether the collection is synchronized.
Declaration
public virtual bool IsSynchronized { get; }
Property Value
Type |
---|
System.Boolean |
Item[Object]
Gets or sets the value associated with the specified key.
Declaration
public virtual object this[object key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | a key value |
Property Value
Type |
---|
System.Object |
Keys
Gets the list of keys. Read-only.
Declaration
public virtual ICollection Keys { get; }
Property Value
Type |
---|
System.Collections.ICollection |
SyncRoot
Gets the object that can be used to synchronize access to the collection. Read-only.
Declaration
public virtual object SyncRoot { get; }
Property Value
Type |
---|
System.Object |
Values
Gets the list of values. Read-only.
Declaration
public virtual ICollection Values { get; }
Property Value
Type |
---|
System.Collections.ICollection |
Methods
Add(Object, Object)
Adds an element with the specified key and value to the list.
Declaration
public virtual void Add(object key, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | The Object to use as the key of the element to be added. |
System.Object | value | The Object to use as the value of the element to be added. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When key is NULL. |
System.ArgumentException | When list already contains specified key. |
Clear()
Removes all elements from the collection.
Declaration
public virtual void Clear()
Clone()
Creates a new object that is a copy of the current instance.
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
System.Object | Copy of the current instance. |
Contains(Object)
Indicates whether the list contains an element with the specified key.
Declaration
public virtual bool Contains(object key)
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | Key of the element to search for. |
Returns
Type | Description |
---|---|
System.Boolean | True if list contains the specified key. |
ContainsKey(Object)
Indicates whether the list contains an element with the specified key.
Declaration
public virtual bool ContainsKey(object key)
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | Key of the element to search for. |
Returns
Type | Description |
---|---|
System.Boolean | True if list contains the specified key. |
ContainsValue(Object)
Indicates whether the list contains the specified value.
Declaration
public virtual bool ContainsValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Value of the element to search for. |
Returns
Type | Description |
---|---|
System.Boolean | True if list contains the specified value |
CopyTo(Array, Int32)
Copies all the elements of the SortedListEx to the specified one-dimensional array starting at the specified destination array index.
Declaration
public virtual void CopyTo(Array array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Array | array | The one-dimensional array that is the destination of the elements copied from the current list. |
System.Int32 | arrayIndex | The index in an array at which copying begins. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If specified array is NULL. |
System.ArgumentException | If rank of the array is not one or there are not enough elements. |
System.ArgumentOutOfRangeException | If specified array Index is less than zero. |
GetByIndex(Int32)
Returns the value at the specified index of the SortedListEx.
Declaration
public virtual object GetByIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the value to return. |
Returns
Type | Description |
---|---|
System.Object | The value at the specified index of the SortedListEx. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When index is less than zero or greater than size of the list. |
GetEnumerator()
Returns an IDictionaryEnumerator that can iterate through the SortedListEx.
Declaration
public virtual IDictionaryEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IDictionaryEnumerator | An IDictionaryEnumerator for the SortedListEx. |
GetKey(Int32)
Returns the key at the specified index of the SortedListEx.
Declaration
public virtual object GetKey(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the key to return. |
Returns
Type | Description |
---|---|
System.Object | The key at the specified index of the SortedListEx. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When index is less than zero or greater than size of the list. |
GetKeyList()
Returns the keys in the SortedListEx.
Declaration
public virtual IList GetKeyList()
Returns
Type | Description |
---|---|
System.Collections.IList | An IList containing the keys in the SortedListEx. |
GetValueList()
Returns the values in the SortedListEx.
Declaration
public virtual IList GetValueList()
Returns
Type | Description |
---|---|
System.Collections.IList | An IList containing the values in the SortedListEx. |
IndexOfKey(Object)
Returns the zero-based index of the specified key.
Declaration
public virtual int IndexOfKey(object key)
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | The key to locate. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of key, if key is found; -1 otherwise. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If specified key is NULL. |
IndexOfValue(Object)
Returns the zero-based index of the first occurrence of the specified value.
Declaration
public virtual int IndexOfValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to locate (can be NULL). |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the first occurrence of value, if value is found; -1 otherwise. |
Remove(Object)
Removes the element with the specified key from the SortedListEx.
Declaration
public virtual void Remove(object key)
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | The key of the element to be removed. |
RemoveAt(Int32)
Removes the element at the specified index.
Declaration
public virtual void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the element to remove. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When index is less than zero or greater than the size of the list. |
SetByIndex(Int32, Object)
Replaces the value at the specified index.
Declaration
public virtual void SetByIndex(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which to save the value. |
System.Object | value | The Object to save. Can be NULL. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When index is less than zero or greater than the size of the list. |
Synchronized(SortedListEx)
Returns a synchronized (thread-safe) wrapper for the SortedList.
Declaration
public static SortedListEx Synchronized(SortedListEx list)
Parameters
Type | Name | Description |
---|---|---|
SortedListEx | list | The SortedList to synchronize. |
Returns
Type | Description |
---|---|
SortedListEx | A synchronized (thread-safe) wrapper for the SortedList. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When list is NULL. |
TrimToSize()
Sets the capacity to the actual number of elements.
Declaration
public virtual void TrimToSize()
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an IEnumerator that can iterate through the SortedListEx.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An IEnumerator for the SortedListEx. |