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.CollectionsAssembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntaxpublic static T[] RandomSubset<T>(
IEnumerable<T> collection,
int count
)
public:
generic<typename T>
static array<T>^ RandomSubset(
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:
TAn array of
count items, selected at random from
collection.
Exceptions
RemarksIf 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