Class SortedListEx
Represents a class that contains the SortedList collection. Instead of keeping two arrays one for keys and one for values, we change values array on Hashtable collection, and only keep keys collection sorted. Performance of this collection greater that SortedList.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Edit.Utils
Assembly: Syncfusion.Edit.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 with the default initial capacity and specified comparer.
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 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 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. 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 |
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 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
Gets the size of the collection.
Declaration
public virtual int Count { get; }
Property Value
Type |
---|
System.Int32 |
IsFixedSize
Gets a value indicating whether the collection has fixed size or not.
Declaration
public virtual bool IsFixedSize { get; }
Property Value
Type |
---|
System.Boolean |
IsReadOnly
Gets a value indicating whether the list is read-only or not.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
Type |
---|
System.Boolean |
IsSynchronized
Gets a value indicating whether the collection is synchronized or not.
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
Gets the read-only list of keys.
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 read-only list of values.
Declaration
public virtual ICollection Values { get; }
Property Value
Type |
---|
System.Collections.ICollection |
Methods
Add(Object, Object)
Helps to 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 to use as the key of the element to add |
System.Object | value | The Object to use as the value of the element to add |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When key is null |
System.ArgumentException | When list already contains specified key |
Clear()
Helps to 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 list contains 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 list contains specified key |
ContainsValue(Object)
Determines 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 |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if list contains 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 array at which copying begins |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If specified array is null |
System.ArgumentException | If rank of the array is not 1 or there is not enough elements |
System.ArgumentOutOfRangeException | If specified arrayIndex is less than zero |
GetByIndex(Int32)
Gets 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 get |
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)
Gets 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 get |
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()
Gets 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()
Gets 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)
Gets 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; otherwise, -1 |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If specified key is null |
IndexOfValue(Object)
Gets 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; otherwise, -1. |
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 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 to save value |
System.Object | value | The Object to save into. Can be NULL |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When index is less than zero or greater than 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 |