Class CollectionsExtensions
Extension methods for .Net Collection objects, e.g. Lists, Dictionaries, Arrays
Inherited Members
Namespace: Microsoft.MixedReality.Toolkit
Assembly: cs.temp.dll.dll
Syntax
public static class CollectionsExtensions
Methods
AsReadOnly<TElement>(IList<TElement>)
Creates a read-only wrapper around an existing collection.
Declaration
public static ReadOnlyCollection<TElement> AsReadOnly<TElement>(this IList<TElement> elements)
Parameters
Type | Name | Description |
---|---|---|
IList<TElement> | elements | The collection to be wrapped. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<TElement> | The new, read-only wrapper around |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
AsReadOnly<TElement>(IList<TElement>)
Creates a read-only wrapper around an existing collection.
Declaration
public static ReadOnlyCollection<TElement> AsReadOnly<TElement>(this IList<TElement> elements)
Parameters
Type | Name | Description |
---|---|---|
IList<TElement> | elements | The collection to be wrapped. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<TElement> | The new, read-only wrapper around |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
DisposeElements<TElement>(IEnumerable<TElement>)
Disposes of all non-null elements in a collection.
Declaration
public static void DisposeElements<TElement>(this IEnumerable<TElement> elements)
where TElement : IDisposable
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TElement> | elements | The collection of elements to be disposed. |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
DisposeElements<TElement>(IEnumerable<TElement>)
Disposes of all non-null elements in a collection.
Declaration
public static void DisposeElements<TElement>(this IEnumerable<TElement> elements)
where TElement : IDisposable
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TElement> | elements | The collection of elements to be disposed. |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
DisposeElements<TElement>(IList<TElement>)
Disposes of all non-null elements in a collection.
Declaration
public static void DisposeElements<TElement>(this IList<TElement> elements)
where TElement : IDisposable
Parameters
Type | Name | Description |
---|---|---|
IList<TElement> | elements | The collection of elements to be disposed. |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
DisposeElements<TElement>(IList<TElement>)
Disposes of all non-null elements in a collection.
Declaration
public static void DisposeElements<TElement>(this IList<TElement> elements)
where TElement : IDisposable
Parameters
Type | Name | Description |
---|---|---|
IList<TElement> | elements | The collection of elements to be disposed. |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
ExportDictionaryValuesAsArray<T>(Dictionary<UInt32, T>)
Exports the values of a uint indexed Dictionary as an Array
Declaration
public static T[] ExportDictionaryValuesAsArray<T>(this Dictionary<uint, T> input)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<UInt32, T> | input | Dictionary to be exported |
Returns
Type | Description |
---|---|
T[] | array in the type of data stored in the Dictionary |
Type Parameters
Name | Description |
---|---|
T | Type of data stored in the values of the Dictionary |
ExportDictionaryValuesAsArray<T>(Dictionary<UInt32, T>)
Exports the values of a uint indexed Dictionary as an Array
Declaration
public static T[] ExportDictionaryValuesAsArray<T>(this Dictionary<uint, T> input)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<UInt32, T> | input | Dictionary to be exported |
Returns
Type | Description |
---|---|
T[] | array in the type of data stored in the Dictionary |
Type Parameters
Name | Description |
---|---|
T | Type of data stored in the values of the Dictionary |
GetInteractionByType(MixedRealityInteractionMapping[], DeviceInputType)
Overload extension to enable getting of an InteractionDefinition of a specific type
Declaration
public static MixedRealityInteractionMapping GetInteractionByType(this MixedRealityInteractionMapping[] input, DeviceInputType key)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityInteractionMapping[] | input | The InteractionDefinition array reference |
DeviceInputType | key | The specific DeviceInputType value to query |
Returns
Type | Description |
---|---|
MixedRealityInteractionMapping |
GetInteractionByType(MixedRealityInteractionMapping[], DeviceInputType)
Overload extension to enable getting of an InteractionDefinition of a specific type
Declaration
public static MixedRealityInteractionMapping GetInteractionByType(this MixedRealityInteractionMapping[] input, DeviceInputType key)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityInteractionMapping[] | input | The InteractionDefinition array reference |
DeviceInputType | key | The specific DeviceInputType value to query |
Returns
Type | Description |
---|---|
MixedRealityInteractionMapping |
SortedInsert<TElement>(List<TElement>, TElement, IComparer<TElement>)
Inserts an item in its sorted position into an already sorted collection. This is useful if you need to consume the collection in between insertions and need it to stay correctly sorted the whole time. If you just need to insert a bunch of items and then consume the sorted collection at the end, it's faster to add all the elements and then use Sort() at the end.
Declaration
public static int SortedInsert<TElement>(this List<TElement> elements, TElement toInsert, IComparer<TElement> comparer = null)
Parameters
Type | Name | Description |
---|---|---|
List<TElement> | elements | The collection of sorted elements to be inserted into. |
TElement | toInsert | The element to insert. |
IComparer<TElement> | comparer | The comparer to use when sorting or null to use Default. |
Returns
Type | Description |
---|---|
Int32 |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
SortedInsert<TElement>(List<TElement>, TElement, IComparer<TElement>)
Inserts an item in its sorted position into an already sorted collection. This is useful if you need to consume the collection in between insertions and need it to stay correctly sorted the whole time. If you just need to insert a bunch of items and then consume the sorted collection at the end, it's faster to add all the elements and then use Sort() at the end.
Declaration
public static int SortedInsert<TElement>(this List<TElement> elements, TElement toInsert, IComparer<TElement> comparer = null)
Parameters
Type | Name | Description |
---|---|---|
List<TElement> | elements | The collection of sorted elements to be inserted into. |
TElement | toInsert | The element to insert. |
IComparer<TElement> | comparer | The comparer to use when sorting or null to use Default. |
Returns
Type | Description |
---|---|
Int32 |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
SupportsInputType(MixedRealityInteractionMapping[], DeviceInputType)
Overload extension to enable getting of an InteractionDefinition of a specific type
Declaration
public static bool SupportsInputType(this MixedRealityInteractionMapping[] input, DeviceInputType key)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityInteractionMapping[] | input | The InteractionDefinition array reference |
DeviceInputType | key | The specific DeviceInputType value to query |
Returns
Type | Description |
---|---|
Boolean |
SupportsInputType(MixedRealityInteractionMapping[], DeviceInputType)
Overload extension to enable getting of an InteractionDefinition of a specific type
Declaration
public static bool SupportsInputType(this MixedRealityInteractionMapping[] input, DeviceInputType key)
Parameters
Type | Name | Description |
---|---|---|
MixedRealityInteractionMapping[] | input | The InteractionDefinition array reference |
DeviceInputType | key | The specific DeviceInputType value to query |
Returns
Type | Description |
---|---|
Boolean |
ToReadOnlyCollection<TElement>(IEnumerable<TElement>)
Creates a read-only copy of an existing collection.
Declaration
public static ReadOnlyCollection<TElement> ToReadOnlyCollection<TElement>(this IEnumerable<TElement> elements)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TElement> | elements | The collection to be copied. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<TElement> | The new, read-only copy of |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |
ToReadOnlyCollection<TElement>(IEnumerable<TElement>)
Creates a read-only copy of an existing collection.
Declaration
public static ReadOnlyCollection<TElement> ToReadOnlyCollection<TElement>(this IEnumerable<TElement> elements)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TElement> | elements | The collection to be copied. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<TElement> | The new, read-only copy of |
Type Parameters
Name | Description |
---|---|
TElement | The type of element in the collection. |