Show / Hide Table of Contents

Class HashSetPool<T>

Object pool for System.Collections.Generic.HashSet<> instances.

Inheritance
System.Object
ObjectPoolBase<PooledHashSet<T>>
HashSetPool<T>
Implements
IObjectPool<PooledHashSet<T>>
IObjectPoolAllocateFree<PooledHashSet<T>>
IObjectPoolNew<PooledHashSet<T>>
Inherited Members
ObjectPoolBase<PooledHashSet<T>>.Allocate()
ObjectPoolBase<PooledHashSet<T>>.Free(PooledHashSet<T>)
ObjectPoolBase<PooledHashSet<T>>.CreateInstance()
Namespace: System.Collections.Generic
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class HashSetPool<T> : ObjectPoolBase<PooledHashSet<T>>, IObjectPool<PooledHashSet<T>>, IObjectPoolAllocateFree<PooledHashSet<T>>, IObjectPoolNew<PooledHashSet<T>>
Type Parameters
Name Description
T

The type of elements in the hash set.

Constructors

HashSetPool(Int32)

Creates a new System.Collections.Generic.HashSet<> pool of the specified pool size.

Declaration
protected HashSetPool(int size)
Parameters
Type Name Description
System.Int32 size

Number of System.Collections.Generic.HashSet<> instances to keep in the pool.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if size is less than zero.

Methods

Create(Int32)

Creates a new System.Collections.Generic.HashSet<> pool of the specified pool size. The pool creates new instances of System.Collections.Generic.HashSet<> by calling the default constructor on HashSet{T}.

Declaration
public static HashSetPool<T> Create(int size)
Parameters
Type Name Description
System.Int32 size

Number of System.Collections.Generic.HashSet<> instances to keep in the pool.

Returns
Type Description
HashSetPool<T>

Newly created pool for System.Collections.Generic.HashSet<> instances.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if size is less than zero.

Create(Int32, IEqualityComparer<T>)

Creates a new System.Collections.Generic.HashSet<> pool of the specified pool size. The pool creates new instances of System.Collections.Generic.HashSet<> by calling the constructor on System.Collections.Generic.HashSet<>, passing in the specified comparer.

Declaration
public static HashSetPool<T> Create(int size, IEqualityComparer<T> comparer)
Parameters
Type Name Description
System.Int32 size

Number of System.Collections.Generic.HashSet<> instances to keep in the pool.

System.Collections.Generic.IEqualityComparer<T> comparer

The System.Collections.Generic.IEqualityComparer<> implementation to use when comparing values in the set, or null to use the default System.Collections.Generic.EqualityComparer`1 implementation for the set type.

Returns
Type Description
HashSetPool<T>

Newly created pool for System.Collections.Generic.HashSet<> instances.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if size is less than zero.

Create(Int32, IEqualityComparer<T>, Int32)

Creates a new System.Collections.Generic.HashSet<> pool of the specified pool size. The pool creates new instances of System.Collections.Generic.HashSet<> by calling the constructor on System.Collections.Generic.HashSet<>, passing in the specified comparer.

Declaration
public static HashSetPool<T> Create(int size, IEqualityComparer<T> comparer, int maxCapacity)
Parameters
Type Name Description
System.Int32 size

Number of System.Collections.Generic.HashSet<> instances to keep in the pool.

System.Collections.Generic.IEqualityComparer<T> comparer

The System.Collections.Generic.IEqualityComparer<> implementation to use when comparing values in the set, or null to use the default System.Collections.Generic.EqualityComparer`1 implementation for the set type.

System.Int32 maxCapacity

The maximum capacity allowed for pooled instances.

Returns
Type Description
HashSetPool<T>

Newly created pool for System.Collections.Generic.HashSet<> instances.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if size is less than zero.

New()

Gets a holder to a pooled hash set instance with RAII capabilities to return it to the pool.

Declaration
public PooledHashSetHolder<T> New()
Returns
Type Description
PooledHashSetHolder<T>

Holder to a pooled hash set instance.

Implements

IObjectPool<T>
IObjectPoolAllocateFree<T>
IObjectPoolNew<T>
In This Article
Back to top Generated by DocFX