Class SortedListEx
Optimized version of 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.HTMLUI.Base.Utility
Assembly: Syncfusion.HTMLUI.Base.dll
Syntax
public class SortedListEx : IDictionary, ICollection, IEnumerable, ICloneable
Constructors
SortedListEx()
Overloaded. Default constructor.
Declaration
public SortedListEx()
SortedListEx(IComparer)
Creates an empty SortedList with the default initial capacity and specified comparer.
Declaration
public SortedListEx(IComparer comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IComparer | comparer | The IComparer that is to be used to determine whether two keys are equal. |
SortedListEx(IComparer, Int32)
Creates an empty SortedList with the specified initial capacity and specified comparer.
Declaration
public SortedListEx(IComparer comparer, int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IComparer | comparer | Initial capacity. |
| System.Int32 | capacity | The IComparer that is to be used to determine whether two keys are equal. |
SortedListEx(IDictionary)
Copies the elements from the specified dictionary to a new list with the same initial capacity as the number of elements copied.
Declaration
public SortedListEx(IDictionary d)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IDictionary | d | The IDictionary to copy from. |
SortedListEx(IDictionary, IComparer)
Copies the elements from the specified dictionary to a new list with the same initial capacity as the number of elements copied and with the specified comparer.
Declaration
public SortedListEx(IDictionary d, IComparer comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IDictionary | d | The IDictionary to copy from. |
| System.Collections.IComparer | comparer | The IComparer that is to be used to determine whether two keys are equal. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | When argument d is NULL. |
SortedListEx(Int32)
Creates an empty list with the specified initial capacity.
Declaration
public SortedListEx(int initialCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | initialCapacity | Initial capacity. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | When initialCapacity 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
Returns the size of the collection. Read-only.
Declaration
public virtual int Count { get; }
Property Value
| Type |
|---|
| System.Int32 |
IsFixedSize
Indicates whether the collection has fixed size.
Declaration
public virtual bool IsFixedSize { get; }
Property Value
| Type |
|---|
| System.Boolean |
IsReadOnly
Indicates whether list is Read-only.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
| Type |
|---|
| System.Boolean |
IsSynchronized
Indicates 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 |
Property Value
| Type |
|---|
| System.Object |
Keys
Returns the list of keys. Read-only.
Declaration
public virtual ICollection Keys { get; }
Property Value
| Type |
|---|
| System.Collections.ICollection |
SyncRoot
Returns 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
Returns 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 provided key and value to the list.
Declaration
public virtual void Add(object key, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | key | The Object that is to be used as the key of the element to be added. |
| System.Object | value | The Object that is to be used as the value of the element to be added. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | When key is NULL. |
| System.ArgumentException | When list already contains the 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)
Determines 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. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the list contains the specified key. |
ContainsKey(Object)
Determines 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. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the list contains the specified key. |
ContainsValue(Object)
Determines whether the list contains the element with the specified value.
Declaration
public virtual bool ContainsValue(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | Value of the element to search. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the 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 to be used as the destination of the elements copied from the current list. |
| System.Int32 | arrayIndex | The index in the 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 retrieve. |
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 retrieve. |
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 SortedListEx.
Declaration
public virtual void Remove(object key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | key | The key of the element to remove. |
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 specific index.
Declaration
public virtual void SetByIndex(int index, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index at which the value is to be saved. |
| 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. |