예제 #1
0
파일: AutoList.cs 프로젝트: biorpg/RT.Util
        /// <summary>Equivalent to the same method in <see cref="List{T}"/>.</summary>
        public AutoList <TOutput> ConvertAll <TOutput>(Converter <T, TOutput> converter)
        {
            if (converter == null)
            {
                throw new ArgumentNullException(nameof(converter));
            }
            var list = new AutoList <TOutput>(_inner.Count);

            foreach (var item in _inner)
            {
                list.Add(converter(item));
            }
            return(list);
        }
예제 #2
0
파일: AutoList.cs 프로젝트: biorpg/RT.Util
        /// <summary>Equivalent to the same method in <see cref="List{T}"/>.</summary>
        public AutoList <T> FindAll(Predicate <T> match)
        {
            if (match == null)
            {
                throw new ArgumentNullException(nameof(match));
            }
            var list = new AutoList <T>();

            foreach (var item in _inner)
            {
                if (match(item))
                {
                    list.Add(item);
                }
            }
            return(list);
        }
예제 #3
0
파일: AutoList.cs 프로젝트: biorpg/RT.Util
        /// <summary>Equivalent to the same method in <see cref="List{T}"/>.</summary>
        public AutoList <T> GetRange(int index, int count)
        {
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(index), "'index' cannot be negative.");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), "'count' cannot be negative.");
            }
            fill(index, count);
            while (_inner.Count < index + count)
            {
                _inner.Add(_initializer == null ? default(T) : _initializer(_inner.Count));
            }
            var list = new AutoList <T>(count);

            for (int i = 0; i < count; i++)
            {
                list.Add(_inner[i + index]);
            }
            return(list);
        }