示例#1
0
        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);
        }
示例#2
0
        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)));
        }
示例#3
0
        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);
        }