示例#1
0
        static void Main(string[] args)
        {
            MyLinkedList <int> myList = new MyLinkedList <int>();

            myList.Add(1);
            myList.Add(2);
            myList.Add(3);
            myList.Remove(3);
            Console.WriteLine(myList.Count);
            foreach (int number in myList)
            {
                Console.WriteLine(number);
            }



            string[] strings = new[] { "Bob", "Sally", "Mark", "Colt" };


            MyLinkedList <string> listOfStrings = new MyLinkedList <string>(strings);

            Console.WriteLine(listOfStrings.IndexOf("Mark"));

            listOfStrings.Insert(4, "Max");
            listOfStrings.RemoveAt(1);
            listOfStrings.Add("Porsh");
            Console.WriteLine(listOfStrings.Contains("Colty"));

            foreach (string item in listOfStrings)
            {
                Console.WriteLine(item);
            }
        }
示例#2
0
        static void Main()
        {
            MyLinkedList <int> numbers = new MyLinkedList <int>();

            numbers.Add(3);
            numbers.Add(5);
            numbers.Add(2);
            numbers.Add(10);
            numbers.Add(222);

            Console.WriteLine(numbers.IndexOf(3));
            Console.WriteLine(numbers.IndexOf(2));
            Console.WriteLine(numbers.IndexOf(222));

            Console.WriteLine(numbers.Count);

            Console.WriteLine(numbers.Contains(2));

            Console.WriteLine(numbers.RemoveAt(0).Value);

            Console.WriteLine(numbers.Remove(222).Value);

            Console.WriteLine(numbers.Count);

            Console.WriteLine();
        }
示例#3
0
        static void Main()
        {
            MyLinkedList myLinkedList = new MyLinkedList();

            myLinkedList.AddFirst(13);
            myLinkedList.AddFirst(12);
            myLinkedList.AddFirst(11);
            myLinkedList.Add(9, 4);
            myLinkedList.Add(10, 4);
            myLinkedList.PrintList();
        }
        public static void Main()
        {
            MyLinkedList <int> numbers = new MyLinkedList <int>();

            for (int i = 0; i < 20; i++)
            {
                numbers.Add(i);
            }

            numbers.Enumerate();
        }
示例#5
0
        static void Main(string[] args)
        {
            Stopwatch             stopwatch = new Stopwatch();
            MyLinkedList <string> list      = new MyLinkedList <string>();

            list.Add("Дмитрий");
            stopwatch.Start();
            string name = list.Current.Value;

            stopwatch.Stop();
            TimeSpan time = stopwatch.Elapsed;

            Console.WriteLine(time.TotalMilliseconds);
            Console.Read();
        }
        public static void Main()
        {
            var linkedList = new MyLinkedList<int>();
            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.Add(4);
            linkedList.Add(5);
            linkedList.Add(6);

            // Add
            Console.WriteLine("All nodes: ");
            ListAllNodes(linkedList);

            // Contains
            Console.WriteLine("Contains 4? : {0}", linkedList.Contains(4));
            Console.WriteLine("Contains 7? : {0}", linkedList.Contains(7));

            // Remove
            Console.WriteLine("All nodes after removing the first one: ");
            linkedList.Remove(1);
            ListAllNodes(linkedList);
        }
        public static void Main()
        {
            var linkedList = new MyLinkedList <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.Add(4);
            linkedList.Add(5);
            linkedList.Add(6);

            // Add
            Console.WriteLine("All nodes: ");
            ListAllNodes(linkedList);

            // Contains
            Console.WriteLine("Contains 4? : {0}", linkedList.Contains(4));
            Console.WriteLine("Contains 7? : {0}", linkedList.Contains(7));

            // Remove
            Console.WriteLine("All nodes after removing the first one: ");
            linkedList.Remove(1);
            ListAllNodes(linkedList);
        }