コード例 #1
0
        /// <summary>
        /// Searches for an element that matches the conditions defined by the specified predicate,
        ///  and returns the last occurrence within the entire <see cref="BigArray{T}"/>.
        /// </summary>
        /// <param name="match">The Predicate{T} delegate that defines the conditions of the element to search for.</param>
        /// <returns>The last element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type T.</returns>
        public T FindLast(Predicate <T> match)
        {
            var range = _arrayMap.ReverseMultyblockRange(new Range(Count - 1, Count));

            //Find it
            int indexOfBlock = range.IndexOfStartBlock;

            foreach (var blockRange in range.Ranges)
            {
                int findLastIndexResult = _blockCollection[indexOfBlock--]
                                          .FindLastIndex(blockRange.Subindex, blockRange.Count, match);
                if (findLastIndexResult != -1)
                {
                    return(this[blockRange.CommonStartIndex + findLastIndexResult]);
                }
            }

            //If there is no such item
            return(default(T));
        }