Collections Collections
Collections Collections
DocFX + Singulink = ♥

Search Results for

    Class WeakCollection<T>

    Represents a collection of weakly referenced values that keeps items in an undefined order. If this collection is accessed concurrently from multiple threads (even in a read-only manner) then all accesses must be synchronized with a full lock.

    Inheritance
    object
    WeakCollection<T>
    Implements
    IEnumerable<T>
    IEnumerable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Singulink.Collections
    Assembly: Singulink.Collections.Weak.dll
    Syntax
    public sealed class WeakCollection<T> : IEnumerable<T>, IEnumerable where T : class
    Type Parameters
    Name Description
    T Represents a collection of weakly referenced values that keeps items in an undefined order. If this collection is accessed concurrently from multiple threads (even in a read-only manner) then all accesses must be synchronized with a full lock.
    Remarks

    On .NET, internal entries for garbage collected values are removed as they are encountered (i.e. as they are enumerated over). This is not the case on .NET Standard targets like .NET Framework. You can perform a full clean by calling the Clean() method or configure automatic cleaning after a set number of add operations by setting the AutoCleanAddCount property.

    Constructors

    Name Description
    WeakCollection()

    Initializes a new instance of the WeakCollection<T> class.

    Properties

    Name Description
    AddCountSinceLastClean

    Gets the number of add operations that have been performed since the last cleaning.

    AutoCleanAddCount

    Gets or sets the number of Add(T) operations that automatically triggers the Clean() method to run. Default value is null which indicates that automatic cleaning is not performed.

    TrimExcessDuringClean

    Gets or sets a value indicating whether to automatically call TrimExcess() whenever Clean() is called. Default value is false.

    UnsafeCount

    Gets the number of entries in the internal data structure. This value will be higher than the actual number of values in the collection if any of the values were garbage collected but still have internal entries in the collection that have not been cleaned.

    Methods

    Name Description
    Add(T)

    Adds an item to the collection.

    Clean()

    Removes internal entries for values that have been garbage collected and trims the excess if TrimExcessDuringClean is set.

    Clear()

    Removes all the elements from the collection.

    Contains(T, IEqualityComparer<T>?)

    Determines whether the collection contains the given item using the specified equality comparer.

    EnsureCapacity(int)

    Ensures that this collection can hold the specified number of elements without growing.

    GetEnumerator()

    Returns an enumerator that iterates through the collection.

    Remove(T, IEqualityComparer<T>?)

    Removes an item from the collection using the specified equality comparer.

    TrimExcess()

    Reduces the internal capacity to the number of entries in the collection.

    Explicit Interface Implementations

    Name Description
    IEnumerable.GetEnumerator()

    Returns an enumerator that iterates through the collection.

    © Singulink. All rights reserved.