Class HybridCollection<T>
An abstract collection for accessing items by key or index.
public abstract class HybridCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged
Type Parameters
T
- Inheritance
-
HybridCollection<T>
- Implements
-
ICollection<T>IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
HybridCollection()
Initializes an empty collection.
protected HybridCollection()
HybridCollection(int)
Initializes a collection with the specified capacity.
protected HybridCollection(int capacity)
Parameters
capacity
int
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
IsReadOnly
Gets/sets whether the collection is read-only.
public bool IsReadOnly { get; protected set; }
Property Value
this[int]
Gets/sets an element by index.
public T this[int index] { get; set; }
Parameters
index
int
Property Value
- T
this[string]
Gets/sets an element by key.
public T this[string key] { get; set; }
Parameters
key
string
Property Value
- T
Methods
Contains(T)
Determines whether the specified element is in the collection.
public bool Contains(T item)
Parameters
item
T
Returns
ContainsKey(string)
Returns true if the collection contains the specified key.
public bool ContainsKey(string key)
Parameters
key
string
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
GetKeys()
Returns an enumerable of keys.
public IEnumerable<string> GetKeys()
Returns
OnAdd(string, T)
Adds the specified key/value pair.
protected void OnAdd(string key, T item)
Parameters
key
stringitem
T
OnClear()
Removes all elements from the collection.
protected void OnClear()
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Raises a NotifyCollectionChanged event.
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
OnCopyTo(T[], int)
Copies the collection to the specified array
protected void OnCopyTo(T[] array, int arrayIndex)
Parameters
array
T[]arrayIndex
int
OnGetItem(string)
Gets the item using the specified key.
protected virtual T OnGetItem(string key)
Parameters
key
string
Returns
- T
OnRemove(string)
Removes the value with the specified key from the collection.
protected bool OnRemove(string key)
Parameters
key
string
Returns
OnRemove(T)
Removes the specified value and associated key.
protected bool OnRemove(T item)
Parameters
item
T
Returns
OnRemoveAt(int)
Removes the value at the specified index.
protected bool OnRemoveAt(int index)
Parameters
index
int
Returns
ToDictionary()
Converts the collection to a dictionary.
protected Dictionary<string, T> ToDictionary()
Returns
- Dictionary<string, T>
ToString()
Returns a string representation of this collection.
public override string ToString()
Returns
Events
CollectionChanged
Raises an event when the collection is changed.
public event NotifyCollectionChangedEventHandler CollectionChanged