KGy SOFT

VirtualCollectionT Class

KGy SOFT Core Libraries Help
Similar to CollectionT but provides virtual members not just for writing an setting but also for getting elements such as GetItem, GetItemIndex and allows to override also some properties such as IsReadOnly and CanSetItem.
Inheritance Hierarchy

SystemObject
  KGySoft.Collections.ObjectModelVirtualCollectionT
    KGySoft.Collections.ObjectModelFastLookupCollectionT

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

[SerializableAttribute]
public class VirtualCollection<T> : IList<T>, 
	ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection, 
	IReadOnlyList<T>, IReadOnlyCollection<T>

Type Parameters

T
The type of the elements in the collection.

The VirtualCollectionT type exposes the following members.

Constructors

  NameDescription
Public methodVirtualCollectionT
Initializes an empty instance of the VirtualCollectionT class with a CircularListT internally.
Public methodVirtualCollectionT(IListT)
Initializes a new instance of the VirtualCollectionT 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 .
Public propertyCount
Gets the number of elements actually contained in the 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.
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.
Protected propertyItems
Gets the wrapped underlying collection maintained by this VirtualCollectionT instance.
Top
Methods

  NameDescription
Public methodAdd
Adds an object to the end of the VirtualCollectionT.
Calls the overridable InsertItem method.
Public methodClear
Removes all elements from the VirtualCollectionT.
Calls the overridable ClearItems method.
Protected methodClearItems
Removes all elements from the VirtualCollectionT.
The base implementation calls the Clear method of the underlying collection.
Public methodContains
Determines whether an element is in the VirtualCollectionT.
Calls the overridable ContainsItem method.
Protected methodContainsItem
Gets whether the specified item is in the VirtualCollectionT.
The base implementation calls the GetItemIndex method.
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.
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.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetItem
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.
Protected methodGetItemIndex
Gets the zero-based index of an occurrence of the specified item within the VirtualCollectionT.
The base implementation calls the IndexOf method of the underlying collection.
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.
Public methodInsert
Inserts an element into the VirtualCollectionT at the specified index.
Calls the overridable InsertItem method.
Protected methodInsertItem
Inserts an element into the VirtualCollectionT at the specified index.
The base implementation calls the Insert method of the underlying collection.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemove
Removes one occurrence of a specific object from the VirtualCollectionT.
Calls the overridable GetItemIndex and RemoveItem methods.
Public methodRemoveAt
Removes the element at the specified index of the VirtualCollectionT.
Calls the overridable RemoveItem method.
Protected methodRemoveItem
Removes the element at the specified index from the VirtualCollectionT.
The base implementation calls the RemoveAt method of the underlying collection.
Protected methodSetItem
Replaces the item at the specified index.
The base implementation sets the item in the underlying collection by its indexer.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods

  NameDescription
Public Extension MethodAddRangeT (Defined by CollectionExtensions.)
Public Extension MethodAsThreadSafeTOverloaded. (Defined by ListExtensions.)
Public Extension MethodAsThreadSafeTOverloaded. (Defined by CollectionExtensions.)
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 MethodForEachT
Similarly to the List<T>.ForEach method, processes an action on each element of an enumerable collection.
(Defined by EnumerableExtensions.)
Public Extension MethodGetRandomElementT(Boolean)Overloaded.
Gets a random element from the enumerable source using a new Random instance.
(Defined by EnumerableExtensions.)
Public Extension MethodGetRandomElementT(Random, Boolean)Overloaded.
Gets a random element from the enumerable source using a specified Random instance.
(Defined by EnumerableExtensions.)
Public Extension MethodIn (Defined by ObjectExtensions.)
Public Extension MethodIndexOf(FuncObject, Boolean)Overloaded.
Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions.)
Public Extension MethodIndexOf(Object)Overloaded.
Searches for an element in the source enumeration.
(Defined by EnumerableExtensions.)
Public Extension MethodIndexOfT(FuncT, Boolean)Overloaded.
Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions.)
Public Extension MethodIndexOfT(T)Overloaded.
Searches for an element in the source enumeration.
(Defined by EnumerableExtensions.)
Public Extension MethodInsertRangeT (Defined by ListExtensions.)
Public Extension MethodIsNullOrEmptyOverloaded.
Determines whether the specified source is  or empty (has no elements).
(Defined by EnumerableExtensions.)
Public Extension MethodIsNullOrEmptyTOverloaded.
Determines whether the specified source is  or empty (has no elements).
(Defined by EnumerableExtensions.)
Public Extension MethodRemoveRangeT
Removes count amount of items from the specified collection at the specified index.
(Defined by ListExtensions.)
Public Extension MethodReplaceRangeT
Removes count amount of items from the target IListT at the specified index, and inserts the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by ListExtensions.)
Public Extension MethodShuffleTOverloaded.
Shuffles an enumerable source (randomizes its elements) using a new Random instance.
(Defined by EnumerableExtensions.)
Public Extension MethodShuffleT(Int32)Overloaded.
Shuffles an enumerable source (randomizes its elements) using the provided seed with a new Random instance.
(Defined by EnumerableExtensions.)
Public Extension MethodShuffleT(Random)Overloaded.
Shuffles an enumerable source (randomizes its elements) using a specified Random instance.
(Defined by EnumerableExtensions.)
Public Extension MethodToCircularListT (Defined by EnumerableExtensions.)
Public Extension MethodTryAdd(Object, Boolean, Boolean)Overloaded.
Tries to add the specified item to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryAddT(T, Boolean, Boolean)Overloaded.
Tries to add the specified item to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryAddRange(IEnumerable, Boolean, Boolean)Overloaded.
Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryAddRangeT(IEnumerableT, Boolean, Boolean)Overloaded.
Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryClear(Boolean, Boolean)Overloaded.
Tries to remove all elements from the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryClearT(Boolean, Boolean)Overloaded.
Tries to remove all elements from the collection.
(Defined by EnumerableExtensions.)
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.)
Public Extension MethodTryGetElementAt(Int32, Object, Boolean, Boolean)Overloaded.
Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryGetElementAtT(Int32, T, Boolean, Boolean)Overloaded.
Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryInsert(Int32, Object, Boolean, Boolean)Overloaded.
Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryInsertT(Int32, T, Boolean, Boolean)Overloaded.
Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryInsertRange(Int32, IEnumerable, Boolean, Boolean)Overloaded.
Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryInsertRangeT(Int32, IEnumerableT, Boolean, Boolean)Overloaded.
Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemove(Object, Boolean, Boolean)Overloaded.
Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveT(T, Boolean, Boolean)Overloaded.
Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveAt(Int32, Boolean, Boolean)Overloaded.
Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveAtT(Int32, Boolean, Boolean)Overloaded.
Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveRange(Int32, Int32, Boolean, Boolean)Overloaded.
Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions.)
Public Extension MethodTryRemoveRangeT(Int32, Int32, Boolean, Boolean)Overloaded.
Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions.)
Public Extension MethodTryReplaceRange(Int32, Int32, IEnumerable, Boolean, Boolean)Overloaded.
Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions.)
Public Extension MethodTryReplaceRangeT(Int32, Int32, IEnumerableT, Boolean, Boolean)Overloaded.
Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions.)
Public Extension MethodTrySetElementAt(Int32, Object, Boolean, Boolean)Overloaded.
Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions.)
Public Extension MethodTrySetElementAtT(Int32, T, Boolean, Boolean)Overloaded.
Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions.)
Top
See Also

Reference