FastLookupCollectionT Class

Similar to CollectionT but IndexOf and Contains methods have O(1) access if the underlying collection is changed through only the FastLookupCollectionT class.

Definition

Namespace: KGySoft.Collections.ObjectModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.2.0
C#
[SerializableAttribute]
public class FastLookupCollection<T> : VirtualCollection<T>
Inheritance
Object    VirtualCollectionT    FastLookupCollectionT
Derived

Type Parameters

T

Remarks

If CheckConsistency is , then the FastLookupCollectionT class is tolerant with direct modifications of the underlying collection but when inconsistency is detected, the cost of IndexOf and Contains methods can fall back to O(n) where n is the count of the elements in the collection.

  Caution

Do not store elements in a FastLookupCollectionT that may change their hash code while they are added to the collection. Finding such elements may fail even if CheckConsistency is .

Constructors

FastLookupCollectionT Initializes an empty instance of the FastLookupCollectionT class with a CircularListT internally.
FastLookupCollectionT(IListT, Boolean) Initializes a new instance of the FastLookupCollectionT class as a wrapper for the specified list.

Properties

CanSetItem Gets whether an item can be set through the indexer.
The base implementation returns if IsReadOnly returns or when the wrapped collection is a one dimensional zero based array of T; otherwise, returns .
(Inherited from VirtualCollectionT)
CheckConsistency Gets or sets whether consistency of the stored items should be checked when items are get or set in the collection.
Default value: , if the FastLookupCollectionT was initialized by the default constructor; otherwise, as it was specified.
Count Gets the number of elements actually contained in the VirtualCollectionT.
The base implementation returns the Count property of the underlying collection.
(Inherited from VirtualCollectionT)
IsReadOnly Gets whether the VirtualCollectionT is read-only. Affects the behavior of Add, Insert, Remove, RemoveAt and Clear methods.
The base implementation returns the IsReadOnly property of the underlying collection.
(Inherited from VirtualCollectionT)
Item Gets or sets the element at the specified index.
When read, calls the overridable GetItem method, and when set, calls the overridable SetItem method.
(Inherited from VirtualCollectionT)
Items Gets the wrapped underlying collection maintained by this VirtualCollectionT instance.
(Inherited from VirtualCollectionT)

Methods

Add Adds an object to the end of the VirtualCollectionT.
Calls the overridable InsertItem method.
(Inherited from VirtualCollectionT)
Clear Removes all elements from the VirtualCollectionT.
Calls the overridable ClearItems method.
(Inherited from VirtualCollectionT)
ClearItems Removes all elements from the FastLookupCollectionT.
(Overrides VirtualCollectionTClearItems)
Contains Determines whether an element is in the VirtualCollectionT.
Calls the overridable ContainsItem method.
(Inherited from VirtualCollectionT)
ContainsItem Gets whether the specified item is in the VirtualCollectionT.
The base implementation calls the GetItemIndex method.
(Inherited from VirtualCollectionT)
CopyTo Copies the entire VirtualCollectionT to a compatible one-dimensional Array, starting at the specified arrayIndex of the target array.
Calls the overridable GetItem method for each index between zero and Count, excluding upper bound.
(Inherited from VirtualCollectionT)
GetEnumerator Returns an enumerator that iterates through the VirtualCollectionT.
The base implementation returns the enumerator of the underlying collection.
(Inherited from VirtualCollectionT)
GetItem Gets the element at the specified index.
The base implementation gets the element at the specified index by calling the indexer of the underlying collection.
(Inherited from VirtualCollectionT)
GetItemIndex Gets the zero-based index of the first of the specified item within the FastLookupCollectionT.
(Overrides VirtualCollectionTGetItemIndex(T))
IndexOf Searches for the specified object and returns the zero-based index of an occurrence within the entire VirtualCollectionT.
Calls the overridable GetItemIndex method.
(Inherited from VirtualCollectionT)
InnerListChanged Invalidates the internally stored index mapping. Call if the wrapped list that has been passed to the constructor has been changed explicitly.
Insert Inserts an element into the VirtualCollectionT at the specified index.
Calls the overridable InsertItem method.
(Inherited from VirtualCollectionT)
InsertItem Inserts an element into the FastLookupCollectionT at the specified index.
(Overrides VirtualCollectionTInsertItem(Int32, T))
OnMapRebuilt Called after the internal index map has been rebuilt either when inconsistency has been detected or when InnerListChanged has been called.
Remove Removes one occurrence of a specific object from the VirtualCollectionT.
Calls the overridable RemoveItem method.
(Inherited from VirtualCollectionT)
RemoveAt Removes the element at the specified index of the VirtualCollectionT.
Calls the overridable RemoveItem method.
(Inherited from VirtualCollectionT)
RemoveItem Removes the first occurrence of item from the FastLookupCollectionT.
(Overrides VirtualCollectionTRemoveItem(T))
RemoveItemAt Removes the element at the specified index from the FastLookupCollectionT.
(Overrides VirtualCollectionTRemoveItemAt(Int32))
SetItem Replaces the item at the specified index.
(Overrides VirtualCollectionTSetItem(Int32, T))

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)

See Also