Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="match"></param>
        /// <returns></returns>
        public SafeList <ValueT> FindAll(Predicate <ValueT> match)
        {
            SafeList <ValueT> safeList = new SafeList <ValueT>();

            ValueT[] valueArray = this.ToArray();
            if (valueArray.Length <= 0)
            {
                return(safeList);
            }

            List <ValueT> list = new List <ValueT>(valueArray.Length);

            for (int iIndex = 0; iIndex < valueArray.Length; iIndex++)
            {
                ValueT itemT = valueArray[iIndex];
                if (match(itemT) == true)
                {
                    list.Add(itemT);
                }
            }

            if (list.Count <= 0)
            {
                return(safeList);
            }
            else
            {
                safeList.AddRange(list);
            }

            return(safeList);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="converter"></param>
        /// <returns></returns>
        public SafeList <TOutput> ConvertAll <TOutput>(Converter <ValueT, TOutput> converter)
        {
            SafeList <TOutput> safeList = new SafeList <TOutput>(m_List.Count);

            ValueT[] valueArray = this.ToArray();
            if (valueArray.Length <= 0)
            {
                return(safeList);
            }

            List <TOutput> converterList = new List <TOutput>(valueArray.Length);

            for (int iIndex = 0; iIndex < valueArray.Length; iIndex++)
            {
                ValueT itemT = valueArray[iIndex];
                converterList.Add(converter(itemT));
            }

            if (converterList.Count <= 0)
            {
                return(safeList);
            }
            else
            {
                safeList.AddRange(converterList);
            }

            return(safeList);
        }