Class CappedSet<T>
Implements a set of T with the optional size limit and optional item lifespan limit.
This class is thread-safe and must be disposed in a deterministic way
Inheritance
System.Object
CappedSet<T>
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<T, System.DateTime>>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: NFX.dll
Syntax
public sealed class CappedSet<T> : DisposableObject, IDisposable, IEnumerable<KeyValuePair<T, DateTime>>, IEnumerable
Type Parameters
Constructors
CappedSet(IEqualityComparer<T>)
Declaration
public CappedSet(IEqualityComparer<T> comparer = null)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEqualityComparer<T> |
comparer |
|
Fields
BUCKET_COUNT
Declaration
public const int BUCKET_COUNT = 251
Field Value
| Type |
Description |
| System.Int32 |
|
THREAD_GRANULARITY_MS
Declaration
public const int THREAD_GRANULARITY_MS = 5000
Field Value
| Type |
Description |
| System.Int32 |
|
Properties
Count
Returns the number of members in the set
Declaration
public int Count { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
SizeLimit
If set > 0, imposes a limit on the maximum number of entries.
When Count exceeds the limit the set asynchronously capps the capacity by
removing older entries. The limit does not guarantee the instant or exact consistency with the Count property
Declaration
public int SizeLimit { get; set; }
Property Value
| Type |
Description |
| System.Int32 |
|
TimeLimitSec
If set >0 then evicts the entries older than the specified value.
Does not guarantee the exact consistency of eviction time
Declaration
public int TimeLimitSec { get; set; }
Property Value
| Type |
Description |
| System.Int32 |
|
Methods
Clear()
Declaration
Contains(T)
Atomic operation which tries to get a member data returning true if it was found
Declaration
public bool Contains(T item)
Parameters
| Type |
Name |
Description |
| T |
item |
|
Returns
| Type |
Description |
| System.Boolean |
|
Get(T, out DateTime)
Atomic operation which tries to get a member data returning true if it was found
Declaration
public bool Get(T item, out DateTime createDate)
Parameters
| Type |
Name |
Description |
| T |
item |
|
| System.DateTime |
createDate |
|
Returns
| Type |
Description |
| System.Boolean |
|
GetEnumerator()
Declaration
public IEnumerator<KeyValuePair<T, DateTime>> GetEnumerator()
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<T, System.DateTime>> |
|
Put(T)
Atomic operation which tries to include a member in the set. Returns true if member was included.
Declaration
Parameters
| Type |
Name |
Description |
| T |
item |
|
Returns
| Type |
Description |
| System.Boolean |
|
Remove(T)
Atomic operation which tries to remove and existing memeber returning true
Declaration
public bool Remove(T item)
Parameters
| Type |
Name |
Description |
| T |
item |
|
Returns
| Type |
Description |
| System.Boolean |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type |
Description |
| System.Collections.IEnumerator |
|
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods