KGy SOFT

FastLookupCollectionT Class

KGy SOFT Core Libraries Help
Similar to CollectionT but IndexOf and Contains methods have O(1) access if the underlying collection is changed through only the FastLookupCollectionT class.
Inheritance Hierarchy

SystemObject
  KGySoft.Collections.ObjectModelVirtualCollectionT
    KGySoft.Collections.ObjectModelFastLookupCollectionT
      KGySoft.ComponentModelCommandBindingsCollection
      KGySoft.ComponentModelFastBindingListT

Namespace:  KGySoft.Collections.ObjectModel
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0-rc.1
Syntax

[SerializableAttribute]
public class FastLookupCollection<T> : VirtualCollection<T>

Type Parameters

T

The FastLookupCollectionT type exposes the following members.

Constructors

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

  NameDescription
Protected propertyCanSetItem
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.)
Public propertyCheckConsistency
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.
Public propertyCount (Inherited from VirtualCollectionT.)
Public propertyIsReadOnly
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.)
Public propertyItem
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.)
Protected propertyItems (Inherited from VirtualCollectionT.)
Top
Methods

  NameDescription
Public methodAdd (Inherited from VirtualCollectionT.)
Public methodClear (Inherited from VirtualCollectionT.)
Protected methodClearItems
Removes all elements from the FastLookupCollectionT.
(Overrides VirtualCollectionTClearItems.)
Public methodContains (Inherited from VirtualCollectionT.)
Protected methodContainsItem (Inherited from VirtualCollectionT.)
Public methodCopyTo
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.)
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 VirtualCollectionT.
The base implementation returns the enumerator of the underlying collection.
(Inherited from VirtualCollectionT.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetItem
Gets the element at the specified index.
(Overrides VirtualCollectionTGetItem(Int32).)
Protected methodGetItemIndex
Gets the zero-based index of the first of the specified item within the FastLookupCollectionT.
(Overrides VirtualCollectionTGetItemIndex(T).)
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 an occurrence within the entire VirtualCollectionT.
Calls the overridable GetItemIndex method.
(Inherited from VirtualCollectionT.)
Public methodInnerListChanged
Rebuilds the internally stored index mapping. Call if CheckConsistency is   and the internally wrapped list has been changed explicitly.
Public methodInsert (Inherited from VirtualCollectionT.)
Protected methodInsertItem
Inserts an element into the FastLookupCollectionT at the specified index.
(Overrides VirtualCollectionTInsertItem(Int32, T).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnMapRebuilt
Called after the internal index map has been rebuilt either when inconsistency has been detected or when InnerListChanged has been called.
Public methodRemove (Inherited from VirtualCollectionT.)
Public methodRemoveAt (Inherited from VirtualCollectionT.)
Protected methodRemoveItem
Removes the element at the specified index from the FastLookupCollectionT.
(Overrides VirtualCollectionTRemoveItem(Int32).)
Protected methodSetItem
Replaces the item at the specified index.
(Overrides VirtualCollectionTSetItem(Int32, T).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods

  NameDescription
Public Extension MethodConvert(Type, CultureInfo)Overloaded.
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.)
Public Extension MethodCode exampleConvertTTarget(CultureInfo)Overloaded.
Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions.)
Public Extension MethodIn (Defined by ObjectExtensions.)
Public Extension MethodTryConvert(Type, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvert(Type, CultureInfo, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvertTTarget(TTarget)Overloaded.
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.)
Public Extension MethodTryConvertTTarget(CultureInfo, TTarget)Overloaded.
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.)
Top
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.

See Also

Reference