예제 #1
0
        public void FindTest()
        {
            DoublyList <int> list = new DoublyList <int>();

            for (int i = 1; i <= 5; i++)
            {
                list.AddLast(i);
            }
            Assert.AreEqual(list.Find(5), 4);
            Assert.AreEqual(list.Find(6), -1);
            Assert.Pass();
        }
        /// <summary>
        /// Найти элементы
        /// </summary>
        /// <param name="doublyList"></param>
        private void FindInDoublyList(DoublyList <int> doublyList)
        {
            Console.WriteLine("Какой элемент нужно найти?");
            var answer = GetAnswer();

            if (answer == null)
            {
                return;
            }

            IReadOnlyList <int> result = doublyList
                                         .Find(answer.Value)
                                         .Select(item => item.Data)
                                         .ToList();

            Console.Write("Найденные элементы: ");
            WriteList(result);
        }