Class HashMap<TKey, TValue>
A C# emulation of the Java Hashmap
A V Get(TKey)
method in Java returns null if the key doesn't exist, instead of throwing
an exception. This implementation doesn't throw an exception when a key
doesn't exist, it will return null. This class is slower than using a
NOTE: This class works best with nullable types. default(T) is returned when a key doesn't exist in the collection (this being similar to how Java returns null). Therefore, if the expected behavior of the java code is to execute code based on if the key exists, when the key is an integer type, it will return 0 instead of null.
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public class HashMap<TKey, TValue> : IDictionary<TKey, TValue>
Type Parameters
Name | Description |
---|---|
TKey | The type of keys in the dictionary |
TValue | The type of values in the dictionary |
Remarks
Unordered Dictionaries
- use when order is not important and all keys are non-null. - HashMap<TKey, TValue> - use when order is not important and support for a null key is required.
Ordered Dictionaries
- LinkedHashMap<TKey, TValue> - use when you need to preserve entry insertion order. Keys are nullable.
- use when you need natural sort order. Keys must be unique. - TreeDictionary<K, V> - use when you need natural sort order. Keys may contain duplicates.
- LurchTable<TKey, TValue> - use when you need to sort by most recent access or most recent update. Works well for LRU caching.
Constructors
Name | Description |
---|---|
HashMap() | |
HashMap(IEnumerable<KeyValuePair<TKey, TValue>>) | |
HashMap(IEqualityComparer<TKey>) | |
HashMap(Int32) | |
HashMap(Int32, IEqualityComparer<TKey>) |
Properties
Name | Description |
---|---|
Count | |
IsReadOnly | |
Item[TKey] | |
Keys | |
Values |