BadScript 2
Loading...
Searching...
No Matches
PartitionExtensions.cs
Go to the documentation of this file.
1// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3using System;
4using System.Collections.Generic;
5
6namespace CommandLine.Core
7{
8 internal static class PartitionExtensions
9 {
10 public static Tuple<IEnumerable<T>, IEnumerable<T>> PartitionByPredicate<T>(this IEnumerable<T> items,
11 Func<T, bool> pred)
12 {
13 List<T> yes = new List<T>();
14 List<T> no = new List<T>();
15
16 foreach (T item in items)
17 {
18 List<T> list = pred(item) ? yes : no;
19 list.Add(item);
20 }
21
22 return Tuple.Create<IEnumerable<T>, IEnumerable<T>>(yes, no);
23 }
24 }
25}
static Tuple< IEnumerable< T >, IEnumerable< T > > PartitionByPredicate< T >(this IEnumerable< T > items, Func< T, bool > pred)