Exemplo n.º 1
0
        public static IList <TOutput> ConvertAll <TInput, TOutput>
            (IList <TInput> list, ConvertDelegate <TInput, TOutput> convertDelegate, ListConstructorDelegate <TOutput> listConstructorDelegate)
        {
            IList <TOutput> resultList = listConstructorDelegate();

            foreach (var item in list.Reverse())
            {
                resultList.Add(convertDelegate(item));
            }
            return(resultList);
        }
Exemplo n.º 2
0
        //возвращает все элементы списка, удовлетворяещие условиям предиката
        public static IList <T> FindAll <T>(IList <T> list, CheckDelegate <T> check, ListConstructorDelegate <T> construct)
        {
            IList <T> found = construct();

            foreach (T item in list)
            {
                if (check(item))
                {
                    found.Add(item);
                }
            }

            return(found);
        }
Exemplo n.º 3
0
 public static IList <TOutput> ConvertAll <TInput, TOutput>
     (IList <TInput> list, ConvertDelegate <TInput, TOutput> convertDelegate, ListConstructorDelegate <TOutput> listConstructorDelegate)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public static IList <TValue> FindAll <TValue>(IList <TValue> list, CheckDelegate <TValue> delegete_func, ListConstructorDelegate <TValue> listConstructorDelegate)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
        public static IList <TValue> FindAll <TValue>(IList <TValue> list, CheckDelegate <TValue> delegete_func, ListConstructorDelegate <TValue> listConstructorDelegate)
        {
            IList <TValue> resultList = listConstructorDelegate();

            foreach (var item in list.Reverse())
            {
                if (delegete_func(item))
                {
                    resultList.Add(item);
                }
            }

            return(resultList);
        }
Exemplo n.º 6
0
 static ListUtils()
 {
     ArrayListConstructor  = new ListConstructorDelegate <TValue>(() => new ArrayList <TValue>());
     LinkedListConstructor = new ListConstructorDelegate <TValue>(() => new LinkedList <TValue>());
 }
Exemplo n.º 7
0
        //конвертирует список типа TI в список типа TO
        public static IList <TO> ConvertAll <TI, TO>(IList <TI> list, ConvertDelegate <TI, TO> convert, ListConstructorDelegate <TO> construct)
        {
            IList <TO> converted = construct();

            foreach (TI item in list)
            {
                converted.Add(convert(item));
            }
            return(converted);
        }