Class HashSet<T>
A set collection class based on linear hashing
Implements
Inherited Members
Namespace: Lucene.Net.Support.C5
Assembly: Lucene.Net.dll
Syntax
public class HashSet<T> : CollectionBase<T>, ICollection<T>, IExtensible<T>, ICollectionValue<T>, IShowable, IFormattable, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceHashSet()
Declaration
public HashSet()
HashSet(MemoryType)
Create a hash set with natural item equalityComparer and default fill threshold (66%) and initial table size (16).
Declaration
public HashSet(MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
MemoryType | memoryType |
HashSet(IEqualityComparer<T>, MemoryType)
Create a hash set with external item equalityComparer and default fill threshold (66%) and initial table size (16).
Declaration
public HashSet(IEqualityComparer<T> itemequalityComparer, MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEqualityComparer<T> | itemequalityComparer | The external item equalitySCG.Comparer |
MemoryType | memoryType |
HashSet(Int32, IEqualityComparer<T>, MemoryType)
Create a hash set with external item equalityComparer and default fill threshold (66%)
Declaration
public HashSet(int capacity, IEqualityComparer<T> itemequalityComparer, MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | Initial table size (rounded to power of 2, at least 16) |
System.Collections.Generic.IEqualityComparer<T> | itemequalityComparer | The external item equalitySCG.Comparer |
MemoryType | memoryType |
HashSet(Int32, Double, IEqualityComparer<T>, MemoryType)
Create a hash set with external item equalityComparer.
Declaration
public HashSet(int capacity, double fill, IEqualityComparer<T> itemequalityComparer, MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | Initial table size (rounded to power of 2, at least 16) |
System.Double | fill | Fill threshold (in range 10% to 90%) |
System.Collections.Generic.IEqualityComparer<T> | itemequalityComparer | The external item equalitySCG.Comparer |
MemoryType | memoryType |
Properties
| Improve this Doc View SourceAllowsDuplicates
Report if this is a set collection.
Declaration
public virtual bool AllowsDuplicates { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Always false |
ContainsSpeed
The complexity of the Contains operation
Declaration
public virtual Speed ContainsSpeed { get; }
Property Value
Type | Description |
---|---|
Speed | Always returns Speed.Constant |
DuplicatesByCounting
By convention this is true for any collection with set semantics.
Declaration
public virtual bool DuplicatesByCounting { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if only one representative of a group of equal items is kept in the collection together with the total count. |
Features
Show which implementation features was chosen at compilation time
Declaration
public static HashSet<T>.Feature Features { get; }
Property Value
Type | Description |
---|---|
HashSet.Feature<> |
ListenableEvents
Declaration
public override EventTypeEnum ListenableEvents { get; }
Property Value
Type | Description |
---|---|
EventTypeEnum |
Overrides
Methods
| Improve this Doc View SourceAdd(T)
Add an item to this set.
Declaration
public virtual bool Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add. |
Returns
Type | Description |
---|---|
System.Boolean | True if item was added (i.e. not found) |
AddAll(IEnumerable<T>)
Add the elements from another collection with a more specialized item type to this collection. Since this collection has set semantics, only items not already in the collection will be added.
Declaration
public virtual void AddAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to add |
BucketCostDistribution()
Produce statistics on distribution of bucket sizes. Current implementation is incomplete.
Declaration
public ISortedDictionary<int, int> BucketCostDistribution()
Returns
Type | Description |
---|---|
ISortedDictionary<System.Int32, System.Int32> | Histogram data. |
Check()
Test internal structure of data (invariants)
Declaration
public virtual bool Check()
Returns
Type | Description |
---|---|
System.Boolean | True if pass |
Choose()
Choose some item of this collection.
Declaration
public override T Choose()
Returns
Type | Description |
---|---|
T |
Overrides
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if collection is empty. |
Clear()
Remove all items from the set, resetting internal table to initial size.
Declaration
public virtual void Clear()
Contains(T)
Check if an item is in the set
Declaration
public virtual bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to look for |
Returns
Type | Description |
---|---|
System.Boolean | True if set contains item |
ContainsAll(IEnumerable<T>)
Check if all items in a supplied collection is in this set (ignoring multiplicities).
Declaration
public virtual bool ContainsAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to look for. |
Returns
Type | Description |
---|---|
System.Boolean | True if all items are found. |
ContainsCount(T)
Count the number of times an item is in this set (either 0 or 1).
Declaration
public virtual int ContainsCount(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to look for. |
Returns
Type | Description |
---|---|
System.Int32 | 1 if item is in set, 0 else |
Find(ref T)
Check if an item (collection equal to a given one) is in the set and if so report the actual item object found.
Declaration
public virtual bool Find(ref T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | On entry, the item to look for. On exit the item found, if any |
Returns
Type | Description |
---|---|
System.Boolean | True if set contains item |
FindOrAdd(ref T)
Check if an item (collection equal to a given one) is in the set. If found, report the actual item object in the set, else add the supplied one.
Declaration
public virtual bool FindOrAdd(ref T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | On entry, the item to look for or add. On exit the actual object found, if any. |
Returns
Type | Description |
---|---|
System.Boolean | True if item was found |
GetEnumerator()
Create an enumerator for this set.
Declaration
public override IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> | The enumerator |
Overrides
ItemMultiplicities()
Declaration
public virtual ICollectionValue<KeyValuePair<T, int>> ItemMultiplicities()
Returns
Type | Description |
---|---|
ICollectionValue<KeyValuePair<T, System.Int32>> |
Remove(T)
Remove an item from the set
Declaration
public virtual bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to remove |
Returns
Type | Description |
---|---|
System.Boolean | True if item was (found and) removed |
Remove(T, out T)
Remove an item from the set, reporting the actual matching item object.
Declaration
public virtual bool Remove(T item, out T removeditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
T | removeditem | The removed value. |
Returns
Type | Description |
---|---|
System.Boolean | True if item was found. |
RemoveAll(IEnumerable<T>)
Remove all items in a supplied collection from this set.
Declaration
public virtual void RemoveAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to remove. |
RemoveAllCopies(T)
Remove all (at most 1) copies of item from this set.
Declaration
public virtual void RemoveAllCopies(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to remove |
RetainAll(IEnumerable<T>)
Remove all items not in a supplied collection from this set.
Declaration
public virtual void RetainAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to retain |
ToArray()
Create an array containing all items in this set (in enumeration order).
Declaration
public override T[] ToArray()
Returns
Type | Description |
---|---|
T[] | The array |
Overrides
UniqueItems()
Declaration
public virtual ICollectionValue<T> UniqueItems()
Returns
Type | Description |
---|---|
ICollectionValue<T> |
Update(T)
Check if an item (collection equal to a given one) is in the set and if so replace the item object in the set with the supplied one.
Declaration
public virtual bool Update(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item object to update with |
Returns
Type | Description |
---|---|
System.Boolean | True if item was found (and updated) |
Update(T, out T)
Check if an item (collection equal to a given one) is in the set and if so replace the item object in the set with the supplied one.
Declaration
public virtual bool Update(T item, out T olditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item object to update with |
T | olditem |
Returns
Type | Description |
---|---|
System.Boolean | True if item was found (and updated) |
UpdateOrAdd(T)
Check if an item (collection equal to a supplied one) is in the set and if so replace the item object in the set with the supplied one; else add the supplied one.
Declaration
public virtual bool UpdateOrAdd(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to look for and update or add |
Returns
Type | Description |
---|---|
System.Boolean | True if item was updated |
UpdateOrAdd(T, out T)
Check if an item (collection equal to a supplied one) is in the set and if so replace the item object in the set with the supplied one; else add the supplied one.
Declaration
public virtual bool UpdateOrAdd(T item, out T olditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to look for and update or add |
T | olditem |
Returns
Type | Description |
---|---|
System.Boolean | True if item was updated |
Explicit Interface Implementations
| Improve this Doc View SourceICollection<T>.Add(T)
Add an item to this set.
Declaration
void ICollection<T>.Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add. |