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)
Assembly: Azos.dll
Syntax
public sealed class CappedSet<T> : ApplicationComponent, IDisposable, IApplicationComponent, IEnumerable<KeyValuePair<T, DateTime>>, IEnumerable
Type Parameters
Constructors
CappedSet(IApplicationComponent, IEqualityComparer<T>)
Declaration
public CappedSet(IApplicationComponent director, IEqualityComparer<T> comparer = null)
Parameters
Type |
Name |
Description |
IApplicationComponent |
director |
|
System.Collections.Generic.IEqualityComparer<T> |
comparer |
|
CappedSet(IApplication, IEqualityComparer<T>)
Declaration
public CappedSet(IApplication app, IEqualityComparer<T> comparer = null)
Parameters
Type |
Name |
Description |
IApplication |
app |
|
System.Collections.Generic.IEqualityComparer<T> |
comparer |
|
Properties
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
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 caps the total number of entries by
removing the older elements. The limit does not guarantee the instantaneous 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 member 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