Click or drag to resize
AlgorithmsRandomSubsetT Method (IEnumerableT, Int32)
Picks a random subset of count items from collection, and places those items into a random order. No item is selected more than once.

Namespace: X3Platform.Collections
Assembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntax
public static T[] RandomSubset<T>(
	IEnumerable<T> collection,
	int count
)

Parameters

collection
Type: System.Collections.GenericIEnumerableT
The collection of items to select from. This collection is not changed.
count
Type: SystemInt32
The number of items in the subset to choose.

Type Parameters

T
The type of items in the collection.

Return Value

Type: T
An array of count items, selected at random from collection.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptioncount is negative or greater than collection.Count.
Remarks
If the collection implements IList<T>, then this method takes time O(count). Otherwise, this method takes time O(N), where N is the number of items in the collection.
See Also