AlgorithmsEqualCollectionsT Method (IEnumerableT, IEnumerableT, BinaryPredicateT) |
Determines if the two collections contain "equal" items in the same order. The passed
BinaryPredicate is used to determine if two items are "equal".
Namespace: X3Platform.CollectionsAssembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntaxpublic static bool EqualCollections<T>(
IEnumerable<T> collection1,
IEnumerable<T> collection2,
BinaryPredicate<T> predicate
)
public:
generic<typename T>
static bool EqualCollections(
IEnumerable<T>^ collection1,
IEnumerable<T>^ collection2,
BinaryPredicate<T>^ predicate
)
Parameters
- collection1
- Type: System.Collections.GenericIEnumerableT
The first collection to compare. - collection2
- Type: System.Collections.GenericIEnumerableT
The second collection to compare. - predicate
- Type: X3Platform.CollectionsBinaryPredicateT
The BinaryPredicate used to compare items for "equality".
This predicate can compute any relation between two items; it need not represent equality or an equivalence relation.
Type Parameters
- T
- The type of items in the collections.
Return Value
Type:
BooleanTrue if
predicatereturns true for each corresponding pair of
items in the two collections. If both collections are empty, true is returned.
Exceptions
RemarksSince an arbitrary BinaryPredicate is passed to this function, what is being tested
for need not be equality. For example, the following code determines if each integer in
list1 is less than or equal to the corresponding integer in list2.
List<int> list1, list2;
if (EqualCollections(list1, list2, delegate(int x, int y) { return x <= y; }) {
}
See Also