コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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());
 }
コード例 #6
0
 public static int Count <TEntity>(this ICountableCollection <TEntity> queryable) where TEntity : class, new()
 {
     return(Query <TEntity> .GetQuery(queryable).Count());
 }