VirtualCollectionT Class

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 Count, IsReadOnly and CanSetItem.

Definition

Namespace: KGySoft.Collections.ObjectModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
[SerializableAttribute]
public class VirtualCollection<T> : IList<T>, 
	ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection, 
	IReadOnlyList<T>, IReadOnlyCollection<T>
Inheritance
Object    VirtualCollectionT
Derived
Implements
ICollectionT, IEnumerableT, IListT, IReadOnlyCollectionT, IReadOnlyListT, ICollection, IEnumerable, IList

Type Parameters

T
The type of the elements in the collection.

Constructors

VirtualCollectionT Initializes an empty instance of the VirtualCollectionT class with a CircularListT internally.
VirtualCollectionT(IListT) Initializes a new instance of the VirtualCollectionT 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 .
Count Gets the number of elements actually contained in the VirtualCollectionT.
The base implementation returns the Count property of the underlying collection.
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.
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.
Items Gets the wrapped underlying collection maintained by this VirtualCollectionT instance.

Methods

Add Adds an object to the end of the VirtualCollectionT.
Calls the overridable InsertItem method.
Clear Removes all elements from the VirtualCollectionT.
Calls the overridable ClearItems method.
ClearItems Removes all elements from the VirtualCollectionT.
The base implementation calls the Clear method of the underlying collection.
Contains Determines whether an element is in the VirtualCollectionT.
Calls the overridable ContainsItem method.
ContainsItem Gets whether the specified item is in the VirtualCollectionT.
The base implementation calls the GetItemIndex method.
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.
GetEnumerator Returns an enumerator that iterates through the VirtualCollectionT.
The base implementation returns the enumerator of the underlying collection.
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.
GetItemIndex 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.
IndexOf Searches for the specified object and returns the zero-based index of an occurrence within the entire VirtualCollectionT.
Calls the overridable GetItemIndex method.
Insert Inserts an element into the VirtualCollectionT at the specified index.
Calls the overridable InsertItem method.
InsertItem Inserts an element into the VirtualCollectionT at the specified index.
The base implementation calls the Insert method of the underlying collection.
Remove Removes one occurrence of a specific object from the VirtualCollectionT.
Calls the overridable RemoveItem method.
RemoveAt Removes the element at the specified index of the VirtualCollectionT.
Calls the overridable RemoveItem method.
RemoveItem Removes one occurrence of a specific object from the VirtualCollectionT.
The base implementation calls the overridable GetItemIndex and RemoveItem methods.
RemoveItemAt Removes the element at the specified index from the VirtualCollectionT.
The base implementation calls the RemoveAt method of the underlying collection.
SetItem Replaces the item at the specified index.
The base implementation sets the item in the underlying collection by its indexer.

Extension Methods

AddRangeT Adds a collection to the target ICollectionT.
(Defined by CollectionExtensions)
AsThreadSafeT Returns a LockingListT, which provides a thread-safe wrapper for the specified list. This only means that if the members are accessed through the returned LockingListT, then the inner state of the wrapped list remains always consistent and not that all the multi-threading concerns can be ignored.
See the Remarks section of the LockingListT class for details and some examples.
(Defined by ListExtensions)
AsThreadSafeT Returns a LockingCollectionT, which provides a thread-safe wrapper for the specified collection. This only means that if the members are accessed through the returned LockingCollectionT, then the inner state of the wrapped collection remains always consistent and not that all the multi-threading concerns can be ignored.
See the Remarks section of the LockingCollectionT class for details and some examples.
(Defined by CollectionExtensions)
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)
ForEachT Similarly to the List<T>.ForEach method, processes an action on each element of an enumerable collection.
(Defined by EnumerableExtensions)
GetRandomElementT Gets a random element from the enumerable source using a new FastRandom instance.
(Defined by EnumerableExtensions)
GetRandomElementT Gets a random element from the enumerable source using a specified Random instance.
(Defined by EnumerableExtensions)
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)
IndexOf Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOf Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IndexOfT Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOfT Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
InsertRangeT Inserts a collection into the target IListT.
(Defined by ListExtensions)
IsNullOrEmpty Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
IsNullOrEmptyT Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
JoinT Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
JoinT Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
RemoveRangeT Removes count amount of items from the specified collection at the specified index.
(Defined by ListExtensions)
ReplaceRangeT 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)
ShuffleT Shuffles an enumerable source (randomizes its elements) using a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using a specified Random instance.
(Defined by EnumerableExtensions)
ToCircularListT Creates a CircularListT from an IEnumerableT.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryT Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified keySelector delegate and a comparer.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryT, TValue Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified key and value selector delegates and a comparer.
(Defined by EnumerableExtensions)
TryAdd Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddT Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddRange Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryAddRangeT Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryClear Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryClearT Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
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)
TryGetCount Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetCountT Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetElementAt Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryGetElementAtT Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryInsert Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertT Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertRange Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryInsertRangeT Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryRemove Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveT Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveAt Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveAtT Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveRange Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryRemoveRangeT Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryReplaceRange 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)
TryReplaceRangeT 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)
TrySetElementAt Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)
TrySetElementAtT Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)

See Also