Class SortedListEx
Optimized version of SortedList collection. Instead of keeping two arrays, one for keys and one for values, the values array on Hashtable collection are changed. Performance of this collection is better than that of SortedList.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.XlsIO.Implementation
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public class SortedListEx : IDictionary, ICollection, IEnumerable, ICloneable
Constructors
SortedListEx()
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 is 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 is 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. |
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. |
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)
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
Capacity of internal buffers.
Declaration
public virtual int Capacity { get; set; }
Property Value
Type |
---|
System.Int32 |
Count
Size of the collection. Read-only.
Declaration
public virtual int Count { get; }
Property Value
Type |
---|
System.Int32 |
IsFixedSize
Returns True if collection has fixed size, False otherwise.
Declaration
public virtual bool IsFixedSize { get; }
Property Value
Type |
---|
System.Boolean |
IsReadOnly
Returns True if list is readonly, False otherwise. Read-only.
Declaration
public virtual bool IsReadOnly { get; }
Property Value
Type |
---|
System.Boolean |
IsSynchronized
Returns True if the collection is synchronized, False otherwise.
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
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
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 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()
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. |
CloneAll()
Clone current instance.
Declaration
public SortedListEx CloneAll()
Returns
Type | Description |
---|---|
SortedListEx | Returns clone of current object. |
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 are 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)
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; otherwise, -1. |
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; 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. |