Пример #1
0
        /// <summary>
        /// Retrieves all the elements that match the conditions defined by the specified predicate.
        /// </summary>
        /// <param name="match">The <see cref="System.Predicate{T}"/> delegate that defines the conditions of the elements to search for.</param>
        /// <returns>
        /// A <see cref="LargeList{T}"/> containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty <see cref="LargeList{T}"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="match"/> is null.</exception>
        public LargeList <T> FindAll(Predicate <T> match)
        {
            if (match == null)
            {
                throw new ArgumentNullException(nameof(match), "Value cannot be null.");
            }

            LargeList <T> Result = new LargeList <T>();

            int SegmentIndex = 0;
            int ElementIndex = 0;

            for (long l = 0; l < Count; l++)
            {
                T item = Partition.GetItem(SegmentIndex, ElementIndex);
                if (match(item))
                {
                    Result.Add(item);
                }

                Partition.IncrementPosition(ref SegmentIndex, ref ElementIndex);
            }

            return(Result);
        }
Пример #2
0
        public LargeCollection()
        {
#if STRICT
            List = new LargeList <T>();
#else
            Initialize();
            List = CreateList();
#endif
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyLargeList{T}"/> class.
        /// Creates an instance that is a read-only wrapper around the specified list.
        /// </summary>
        /// <param name="list">The list to wrap.</param>
        /// <exception cref="ArgumentNullException"><paramref name="list"/> is null.</exception>
        public ReadOnlyLargeList(LargeList <T> list)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            List = list;
        }
Пример #4
0
        /// <summary>
        /// Converts the elements in the current <see cref="LargeList{T}"/> to another type, and returns a list containing the converted elements.
        /// </summary>
        /// <param name="converter">A <see cref="System.Converter{T, TOutput}"/> delegate that converts each element from one type to another type.</param>
        /// <typeparam name="TOutput">The type of the elements of the target array.</typeparam>
        /// <returns>
        /// A <see cref="LargeList{T}"/> of the target type containing the converted elements from the current <see cref="LargeList{T}"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="converter"/> is null.</exception>
        /// <exception cref="OutOfMemoryException">There is not enough memory available on the system.</exception>
        public LargeList <TOutput> ConvertAll <TOutput>(Converter <T, TOutput> converter)
        {
            if (converter == null)
            {
                throw new ArgumentNullException(nameof(converter), "Value cannot be null.");
            }

            LargeList <TOutput> Result = new LargeList <TOutput>(Count, Partition.MaxSegmentCapacity);

            int SegmentIndex = 0;
            int ElementIndex = 0;

            for (long l = 0; l < Count; l++)
            {
                Result[l] = converter(Partition.GetItem(SegmentIndex, ElementIndex));
                Partition.IncrementPosition(ref SegmentIndex, ref ElementIndex);
            }

#if DEBUG
            AssertInvariant();
#endif

            return(Result);
        }