Click or drag to resize

CondensedCollectionT Class

[This is preliminary documentation and is subject to change.]

An IListT implementation that uses interning (deduplication) for efficient storage of large numbers of immutable elements. Interning items makes the collection more memory-efficient and can often improve performance for certain compute-intensive tasks.
Inheritance Hierarchy
SystemObject
  CondensedCondensedCollectionT

Namespace:  Condensed
Assembly:  Condensed (in Condensed.dll) Version: 0.1.0.0 (0.1.0.0)
Syntax
[SerializableAttribute]
public class CondensedCollection<T> : IList<T>, 
	ICollection<T>, IEnumerable<T>, IEnumerable

Type Parameters

T
The type of elements in the collection.

The CondensedCollectionT type exposes the following members.

Constructors
  NameDescription
Public methodCondensedCollectionT
Initializes a new instance of the CondensedCollectionT class with the default capacity, default comparer for the type, and no cutover predicate.
Public methodCondensedCollectionT(Int32, IEqualityComparerT, PredicateCondensedStats, IEnumerableT)
Initializes a new instance of the CondensedCollectionT class.
Top
Properties
  NameDescription
Public propertyCapacity
Gets or sets the total number of elements the internal data structure can hold without resizing.
Public propertyComparer
Gets the IEqualityComparerT that is used by the CondensedCollectionT to compare elements while performing deduplication.
Public propertyCount
Gets the number of elements in the collection.
Public propertyCutoverPredicate
Gets the callback that is periodically called to determine whether it's worthwhile for this collection to perform deduplication. Called immediately before a new, unique item is added to the intern pool. Return true if the condensed list needs to cutover to normal ListT storage.
Public propertyHasCutover
Gets whether the collection has stopped performing deduplication and has internally cutover to normal ListT storage.
Public propertyIndexType
Gets the width of the internal index currently used by a CondensedCollectionT.
Public propertyInternPoolCount
Gets count of values held internally in the collection's intern pool of unique values, or -1 if the collection has cutover and is no longer performing deduplication.
Public propertyIsReadOnly
Gets a value indicating whether the collection is read-only.
Public propertyItem
Gets or sets the element at the specified index.
Public propertyReclaimableInternsCount
Gets count of unused items in the collection's intern pool that would be freed (made eligible for GC) by a cleanup operation, or -1 if the collection has cutover and is no longer performing deduplication.
Public propertyUniqueCount
Gets count of unique values held in the collection. If T is nullable and null element(s) are present, null will be counted as a unique value.
Top
Methods
  NameDescription
Public methodAdd
Adds an item to the collection.
Public methodCleanup
Rebuilds the collection's internal data structures, reclaiming unused items and potentially freeing memory.
Public methodClear
Removes all items from the collection.
Public methodContains
Determines whether the collection contains a specific value.
Public methodCopyTo
Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the collection.
Public methodInsert
Inserts an element into the collection at the specified index.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemove
Removes the first occurrence of a specific object from the collection.
Public methodRemoveAt
Removes the item at the specified index.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventInternedValueReclaimable
Event that is raised when an item in the intern pool of unique values is no longer stored in the collection.
Top
Extension Methods
  NameDescription
Public Extension MethodAllTSource
Determines whether all elements of the collection satisfy a condition. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAnyTSource
Determines whether any element of the collection satisfies a condition. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, Int32)Overloaded.
Computes the average of a CondensedCollection of Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, NullableInt32)Overloaded.
Computes the average of a CondensedCollection of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, Decimal)Overloaded.
Computes the average of a CondensedCollection of Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, NullableDecimal)Overloaded.
Computes the average of a CondensedCollection of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, Int64)Overloaded.
Computes the average of a CondensedCollection of Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, NullableInt64)Overloaded.
Computes the average of a CondensedCollection of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, Double)Overloaded.
Computes the average of a CondensedCollection of double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, NullableDouble)Overloaded.
Computes the average of a CondensedCollection of nullable double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, Single)Overloaded.
Computes the average of a CondensedCollection of float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodAverageTSource(FuncTSource, NullableSingle)Overloaded.
Computes the average of a CondensedCollection of nullable float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodContainsTSource
Determines whether a sequence contains a specified value by using a specified comparer.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodCountTSource
Returns count of elements in the CondensedCollection that satisfy a condition. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodDistinctTSource
Returns distinct elements from a CondensedCollectionT as determined by the collection's equality comparer.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodFirstTSource
Returns the first element in a sequence that satisfies a specified condition. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodFirstOrDefaultTSource
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodLastTSource
Returns the last element in a sequence that satisfies a specified condition. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodLastOrDefaultTSource
Returns the last element of the sequence that satisfies a condition or a default value if no such element is found. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSourceOverloaded.
Returns the maximum value in a generic sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, Int32)Overloaded.
Computes the maximum value of a CondensedCollection of Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, NullableInt32)Overloaded.
Computes the maximum value of a CondensedCollection of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, Decimal)Overloaded.
Computes the maximum value of a CondensedCollection of Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, NullableDecimal)Overloaded.
Computes the maximum value of a CondensedCollection of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, Int64)Overloaded.
Computes the maximum value of a CondensedCollection of Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, NullableInt64)Overloaded.
Computes the maximum value of a CondensedCollection of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, Double)Overloaded.
Computes the maximum value of a CondensedCollection of double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, NullableDouble)Overloaded.
Computes the maximum value of a CondensedCollection of nullable double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, Single)Overloaded.
Computes the maximum value of a CondensedCollection of float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource(FuncTSource, NullableSingle)Overloaded.
Computes the maximum value of a CondensedCollection of nullable float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMaxTSource, TResult(FuncTSource, TResult)Overloaded.
Invokes a transform function on each element of a generic sequence and returns the maximum resulting value. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSourceOverloaded.
Returns the minimum value in a generic sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, Int32)Overloaded.
Computes the minimum value of a CondensedCollection of Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, NullableInt32)Overloaded.
Computes the minimum value of a CondensedCollection of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, Decimal)Overloaded.
Computes the minimum value of a CondensedCollection of Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, NullableDecimal)Overloaded.
Computes the minimum value of a CondensedCollection of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, Int64)Overloaded.
Computes the minimum value of a CondensedCollection of Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, NullableInt64)Overloaded.
Computes the minimum value of a CondensedCollection of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, Double)Overloaded.
Computes the minimum value of a CondensedCollection of double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, NullableDouble)Overloaded.
Computes the minimum value of a CondensedCollection of nullable double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, Single)Overloaded.
Computes the minimum value of a CondensedCollection of float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource(FuncTSource, NullableSingle)Overloaded.
Computes the minimum value of a CondensedCollection of nullable float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodMinTSource, TResult(FuncTSource, TResult)Overloaded.
Invokes a transform function on each element of a generic sequence and returns the minimum resulting value. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, Int32)Overloaded.
Computes the sum of a CondensedCollection of Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, NullableInt32)Overloaded.
Computes the sum of a CondensedCollection of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, Decimal)Overloaded.
Computes the sum of a CondensedCollection of Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, NullableDecimal)Overloaded.
Computes the sum of a CondensedCollection of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, Int64)Overloaded.
Computes the sum of a CondensedCollection of Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, NullableInt64)Overloaded.
Computes the sum of a CondensedCollection of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, Double)Overloaded.
Computes the sum of a CondensedCollection of double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, NullableDouble)Overloaded.
Computes the sum of a CondensedCollection of nullable double values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, Single)Overloaded.
Computes the sum of a CondensedCollection of float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Public Extension MethodSumTSource(FuncTSource, NullableSingle)Overloaded.
Computes the sum of a CondensedCollection of nullable float values that are obtained by invoking a transform function on each element of the input sequence. Optimized for a CondensedCollection.
(Defined by CondensedCollectionExtensions.)
Top
Remarks

The CondensedCollection class provides a generalized form of interning for immutable types. It provides the following features:

  • Nullable types are supported.
  • Optional fallback ("cutover") to non-deduplicated list behavior if the items in the list aren't sufficiently unique.
  • Specialized LINQ operators in Condensed.Linq namespace that are optimized to work on the deduplicated collection.

The CondensedCollection class is best suited for relatively static collection of elements, or, at the very least, a population whose set of unique values is relatively fixed. The collection maintains an "intern pool" of unique values, and this pool is not automatically cleaned up.

CondensedCollection is not thread-safe and does not perform any internal synchronization. Multiple simultaneous readers are allowed, (provided there is no active writer), so a ReaderWriterLockSlim (or an ordinary exclusive lock) should be used to synchronize multi-threaded access to an instance of the collection.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Reference

Other Resources