public static IEnumerable <T> RemoveWhereEnumerable <T>(this IBucket <T> bucket, Predicate <T> check) { if (bucket == null) { throw new ArgumentNullException(nameof(bucket)); } if (check == null) { throw new ArgumentNullException(nameof(check)); } var matches = bucket.WhereIndexed(check); return(from pair in matches where bucket.RemoveAt(pair.Key) select pair.Value); }
public static int RemoveWhere <T>(this IBucket <T> bucket, Predicate <T> check) { if (bucket == null) { throw new ArgumentNullException(nameof(bucket)); } if (check == null) { throw new ArgumentNullException(nameof(check)); } var matches = bucket.WhereIndexed(check); return(matches.Count(pair => bucket.RemoveAt(pair.Key))); }
public static int RemoveWhere <T>(this IBucket <T> bucket, Predicate <T> check) { if (bucket == null) { throw new ArgumentNullException(nameof(bucket)); } if (check == null) { throw new ArgumentNullException(nameof(check)); } var matches = bucket.WhereIndexed(check); var count = 0; foreach (var pair in matches) { if (bucket.RemoveAt(pair.Key)) { count++; } } return(count); }