public static void Add <T>(this ICountableCollection <T> collection, ICountableCollection <T> added) { foreach (KeyValuePair <T, int> keyValuePair in added) { collection.Add(keyValuePair.Key, keyValuePair.Value); } }
public static void Remove <T>(this ICountableCollection <T> collection, ICountableCollection <T> removed) { foreach (KeyValuePair <T, int> keyValuePair in removed) { collection.Remove(keyValuePair.Key, keyValuePair.Value); } }
public static ICountableCollection <T> Select <T>(this ICountableCollection <T> collection, Func <T, T> transformer) { var result = new CountableCollection <T>(); foreach (KeyValuePair <T, int> keyValuePair in collection) { result.Add(transformer(keyValuePair.Key), keyValuePair.Value); } return(result); }
public bool TryExchange(IDecreasingOrderCollection <int> availableValues, int valueForExchange, out ICountableCollection <int> result) { result = new CountableCollection <int>(); foreach (int availableValue in availableValues.DecreasingOrder()) { if (valueForExchange == 0) { return(true); } if (valueForExchange >= availableValue) { valueForExchange -= availableValue; result.Add(availableValue, 1); } } return(valueForExchange == 0); }
public static int Count <TEntity>(this ICountableCollection <TEntity> queryable, Expression <Func <TEntity, bool> > predicate) where TEntity : class, new() { return(Query <TEntity> .GetQuery(queryable).Where(predicate).Count()); }
public static int Count <TEntity>(this ICountableCollection <TEntity> queryable) where TEntity : class, new() { return(Query <TEntity> .GetQuery(queryable).Count()); }