TKey
- The type of keys in the collection.TItem
- The type of items in the collection.public abstract class KeyedCollection<TKey,TItem> extends Collection<TItem>
Modifier | Constructor and Description |
---|---|
protected |
KeyedCollection() |
protected |
KeyedCollection(IEqualityComparer<TKey> comparer) |
protected |
KeyedCollection(IEqualityComparer<TKey> comparer,
int dictionaryCreationThreshold) |
Modifier and Type | Method and Description |
---|---|
protected void |
ChangeItemKey(TItem item,
TKey newKey)
Changes the key associated with the specified element in the lookup dictionary.
|
protected void |
ClearItems()
Removes all elements from the Collection<>.
|
boolean |
Contains(TKey key) |
TItem |
get(TKey key)
Gets the element with the specified key.
|
IEqualityComparer<TKey> |
getComparer() |
protected java.util.Map<TKey,TItem> |
getDictionary() |
protected abstract TKey |
GetKeyForItem(TItem item) |
protected void |
InsertItem(int index,
TItem item)
Inserts an element into the Collection<> at the specified index.
|
boolean |
Remove(TKey key) |
protected void |
RemoveItem(int index)
Removes the element at the specified index of the Collection<>.
|
protected void |
SetItem(int index,
TItem item)
Replaces the element at the specified index.
|
protected KeyedCollection()
protected KeyedCollection(IEqualityComparer<TKey> comparer)
protected KeyedCollection(IEqualityComparer<TKey> comparer, int dictionaryCreationThreshold)
public IEqualityComparer<TKey> getComparer()
public TItem get(TKey key)
key
- The key of the element to get.ArgumentNullException
- key is null.KeyNotFoundException
- An element with the specified key does not exist in the collection.protected void ChangeItemKey(TItem item, TKey newKey)
item
- The element to change the key of.newKey
- The new key for item.ArgumentNullException
- item is null.-or-newKey is null.ArgumentException
- item is not found.-or-newKey already exists in the System.Collections.ObjectModel.KeyedCollectionprotected void ClearItems()
Collection
ClearItems
in class Collection<TItem>
public boolean Contains(TKey key)
key
- protected void InsertItem(int index, TItem item)
Collection
InsertItem
in class Collection<TItem>
index
- The object to insert. The value can be null for reference types.item
- The zero-based index at which item should be inserted.public boolean Remove(TKey key)
protected void RemoveItem(int index)
Collection
RemoveItem
in class Collection<TItem>
index
- The zero-based index of the element to remove.protected void SetItem(int index, TItem item)
Collection
SetItem
in class Collection<TItem>
index
- The zero-based index of the element to replace.item
- The new value for the element at the specified index. The value can be null for reference types.