Wintellect.PowerCollections Namespace
Algorithms Class
Algorithms Methods
GhostDoc Pro Sample Help File

Algorithms..::..Partition<(Of <(<'T>)>)> Method

Partition a list or array based on a predicate. After partitioning, all items for which the predicate returned true precede all items for which the predicate returned false.

Namespace:  Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax


public static int Partition<T>(
	IList<T> list,
	Predicate<T> predicate
)
Public Shared Function Partition(Of T) ( _
	list As IList(Of T), _
	predicate As Predicate(Of T) _
) As Integer
public:
generic<typename T>
static int^ Partition(
	IList<T>^ list, 
	Predicate<T>^ predicate
)

Type Parameters

T

Parameters

list
Type: IList<(Of <(<'T>)>)>
The list or array to partition.
predicate
Type: Predicate<(Of <(<'T>)>)>
A delegate that defines the partitioning condition.

Return Value

The index of the first item in the second half of the partition; i.e., the first item for which predicate returned false. If the predicate was true for all items in the list, list.Count is returned.

Remarks


Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as list.