Show / Hide Table of Contents

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
DisposableObject
CappedSet<T>
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<T, System.DateTime>>
System.Collections.IEnumerable
Inherited Members
DisposableObject.DisposeAndNull<T>(T)
DisposableObject.DisposeStarted
DisposableObject.Disposed
DisposableObject.Destructor()
DisposableObject.EnsureObjectNotDisposed()
DisposableObject.Dispose()
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()
Namespace: NFX.Collections
Assembly: NFX.dll
Syntax
public sealed class CappedSet<T> : DisposableObject, IDisposable, IEnumerable<KeyValuePair<T, DateTime>>, IEnumerable
Type Parameters
Name Description
T

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()

Removes all items

Declaration
public void Clear()

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
public bool Put(T item)
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

CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T>)
CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T, Int32>)
CollectionUtils.SkipLast<T>(IEnumerable<T>)
CollectionUtils.SkipLast<T>(IEnumerable<T>, Int32)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstOrAnyOrDefault<TResult>(IEnumerable<TResult>, Func<TResult, Boolean>)
CollectionUtils.Distinct<TResult, TKey>(IEnumerable<TResult>, Func<TResult, TKey>)
MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
LookAheadExtensions.AsLookAheadEnumerable<T>(IEnumerable<T>)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX