public void TestIndexOutOfBound()
 {
     List += 13;
     List += 1;
     List += 5;
     var exception = List[4];
 }
        public void DeleteSingleElementTest()
        {
            var list = new DoubleLinkedList<int>();
            list.Head = list.Tail = new DoubleLinkedList<int>.DoubleLinkedListItem<int> {Value = 1};
            list.Delete(list.Head);

            Assert.IsNull(list.Head);
            Assert.IsNull(list.Tail);
        }
 public void TestIndex()
 {
     List += 13;
     List += 1;
     List += 5;
     Assert.AreEqual(13, List[0].Value);
     Assert.AreEqual(1, List[1].Value);
     Assert.AreEqual(5, List[2].Value);
 }
        public void TestCountOnAddLastMethod()
        {
            var linkedList = new DoubleLinkedList<int>();
            linkedList.AddLast(3);
            linkedList.AddLast(2);
            linkedList.AddLast(1);

            Assert.AreEqual(3, linkedList.Count);
        }
        public void TestLastElementOnAddFirstMethod()
        {
            var linkedList = new DoubleLinkedList<int>();
            linkedList.AddLast(1);

            Assert.AreEqual(1, linkedList.First.Value);
            Assert.AreEqual(1, linkedList.Last.Value);
            Assert.AreEqual(1, linkedList.Count);
        }
Пример #6
0
        public FormMain()
        {
            InitializeComponent();

            //Create new DoubleLinkedList object
            this.list = new DoubleLinkedList();
            //Wire change event handler
            this.list.Changed += new DoubleLinkedList.ChangeHandler(HandleChange);
            //Populate list from file
            this.list.LoadData(FileHandler.LoadEntries());
        }
 private static DoubleLinkedList<int> CreateListWithTwoElements()
 {
     var list = new DoubleLinkedList<int>
     {
         Head = new DoubleLinkedList<int>.DoubleLinkedListItem<int> { Value = 1 },
         Tail = new DoubleLinkedList<int>.DoubleLinkedListItem<int> { Value = 3 }
     };
     list.Head.Next = list.Tail;
     list.Tail.Previous = list.Head;
     return list;
 }
        public void TestFirstMiddleLastElementsOnAddLastMethod()
        {
            var linkedList = new DoubleLinkedList<int>();
            linkedList.AddLast(1);
            linkedList.AddLast(2);
            linkedList.AddLast(3);

            Assert.AreEqual(1, linkedList.First.Value);
            Assert.AreEqual(2, linkedList.First.Next.Value);
            Assert.AreEqual(3, linkedList.Last.Value);
            Assert.AreEqual(3, linkedList.Count);
        }
        public void contains_does_not_find_value_in_list()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);
            list.Add(15);
            list.Add(45);

            // assert
            Assert.AreEqual(false, list.Contains(99));
        }
        static void Main(string[] args)
        {
            var numbers = new DoubleLinkedList<int>();

            for (int i = 0; i < 15; i++)
            {
                numbers.PushFront(i + 1);
            }
            var index = numbers.GetEnumerator();
            while (index.MoveNext())
            {
                Console.WriteLine(index.Current);
            }
        }
        public void TestEqual()
        {
            List += 13;
            List += 1;
            List += 5;

            DoubleLinkedList<double> List2 = new DoubleLinkedList<double>();
            List2 += 13;
            List2 += 1;
            List2 += 5;

            Assert.IsTrue(List == List2);
            Assert.IsFalse(List != List2);
        }
        public void contains_finds_value_in_list()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);
            list.Add(15);
            list.Add(45);

            // assert
            Assert.AreEqual(true, list.Contains(5));
            Assert.AreEqual(true, list.Contains(15));
            Assert.AreEqual(true, list.Contains(45));
        }
        /// <summary>
        /// Connecting childs to form and store the full path.
        /// </summary>
        /// <param name="parentNode">The startup Node value.</param>
        /// <param name="currentResult">The list stores current paths in every moment.</param>
        /// <param name="allPaths">The collection stores all paths.</param>
        private void ConnectAllPathsDFS(Node<int> parentNode, DoubleLinkedList<int> currentResult, ref List<DoubleLinkedList<int>> allPaths)
        {
            currentResult.AddLast(parentNode.Value);

            // For each child go and visit its subtree
            foreach (var child in parentNode.Childs)
            {
                this.ConnectAllPathsDFS(child, currentResult, ref allPaths);
            }

            if (parentNode.Childs.Count == 0)
            {
                allPaths.Add(new DoubleLinkedList<int>(currentResult));
            }

            currentResult.RemoveLast();
        }
        public void add_value_must_be_in_correct_order_using_previous()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);
            list.Add(15);
            list.Add(45);

            var node = list.Last;

            // assert
            Assert.AreEqual(45, node.Value);
            Assert.AreEqual(15, node.Previous.Value);
            Assert.AreEqual(5, node.Previous.Previous.Value);
        }
Пример #15
0
        public static void Main(string[] args)
        {
            SingleLinkedList <int> list1 = new SingleLinkedList <int>();

            for (int i = 0; i < 10; i++)
            {
                list1.Add(i + 1);
            }
            SingleLinkedList <int> list2 = new SingleLinkedList <int>(list1);

            list1.AddRange(list2);
            list1.Show();
            Console.WriteLine();
            list2.Show();
            Console.WriteLine();
            Console.WriteLine(Sum(list1));

            int[]  test = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            String s    = toString(test);

            Console.WriteLine(s);

            DoubleLinkedList <int> list3 = new DoubleLinkedList <int>();

            for (int i = 10; i < 20; i++)
            {
                list3.Add(i + 1);
            }
            list3.Remove(15);
            list3.Show();
            Console.WriteLine();
            Console.WriteLine(list3.IndexOf(12));
            DoubleLinkedList <int> list4 = new DoubleLinkedList <int>(list3);

            list4.Show();
            Console.WriteLine();

            int[] aa = { 10, 15, 20, 12, 13, 19 };
            for (int i = 0; i < aa.Length; i++)
            {
                for (int j = i; j < aa.Length; j++)
                {
                    if (aa[j] < aa[i])
                    {
                        int temp = aa[i];
                        aa[i] = aa[j];
                        aa[j] = temp;
                    }
                }
            }
            for (int i = 0; i < aa.Length; i++)
            {
                Console.Write(aa[i].ToString() + ' ');
            }
            Console.WriteLine();
            Console.WriteLine();

            DoubleLinkedList <int> list5 = new DoubleLinkedList <int>();

            list5.Add(10);
            list5.Add(20);
            list5.Add(15);
            list5.Add(11);
            list5.Add(30);
            list5.Show();
            Console.WriteLine();
            //InsertSort(list5, 14);
            Sort(list5);
            list5.Show();
            Console.WriteLine();

            //list5.Show();
            //Console.WriteLine();
        }
Пример #16
0
        public void AddByIndex_WhenInvalidValuePaseed_ShouldReturnIndexOutOfRangeException_NegativeTests(int value, int index, int[] actualArray)
        {
            DoubleLinkedList actual = DoubleLinkedList.Create(actualArray);

            Assert.Throws <IndexOutOfRangeException>(() => actual.AddByIndex(value, index));
        }
Пример #17
0
 public FunctionIterator(int currentIndex, DoubleLinkedList <T> doubleLinkedList)
     : base(currentIndex, doubleLinkedList)
 {
 }
Пример #18
0
 public DriverProgram()
 {
     singleLL   = new SingleLinkedList();
     doubleLL   = new DoubleLinkedList();
     circularLL = new CircularLinkedList();
 }
Пример #19
0
        private void SortList()
        {
            List<Employee> sortList = this.list.ToList();

            if (sortList != null) {
                List<Employee> sortedList = sortList.OrderBy(o => o.department).ToList();

                //Create new DoubleLinkedList object
                this.list = new DoubleLinkedList();
                //Rewire change event handler
                this.list.Changed += new DoubleLinkedList.ChangeHandler(HandleChange);
                //Populate list from sorted list
                this.list.LoadData(sortedList);
            }
        }
 public void TestPredecessor()
 {
     List += 5;
     Assert.IsNull(List.First.Predecessor);
     List += 3;
     Assert.IsNotNull(List.Last.Predecessor);
     Assert.AreEqual(List.First, List.Last.Predecessor);
 }
Пример #21
0
        public static Jugador SearchBySalario(DoubleLinkedList <Jugador> lista, string argumento, string rangoSalarial)
        {
            Jugador jugador = new Jugador();
            double  rango   = double.Parse(rangoSalarial);

            //poner argumento a todo mayusculas para evitar errores por sintaxis
            switch (argumento)
            {
            case "MAYOR":
                if (!lista.isEmpty())
                {
                    for (int i = 0; i < lista.size(); i++)
                    {
                        if (lista.GetElementAtPos(i).Salario > rango)
                        {
                            jugador = lista.GetElementAtPos(i);
                            break;
                        }
                    }
                }

                else
                {
                    throw new ArgumentNullException("No hay ninguna lista seleccionada");
                }

                break;

            case "MENOR":
                if (!lista.isEmpty())
                {
                    for (int i = 0; i < lista.size(); i++)
                    {
                        if (lista.GetElementAtPos(i).Salario < rango)
                        {
                            jugador = lista.GetElementAtPos(i);
                            break;
                        }
                    }
                }

                else
                {
                    throw new ArgumentNullException("No hay ninguna lista seleccionada");
                }
                break;

            case "IGUAL":
                if (!lista.isEmpty())
                {
                    for (int i = 0; i < lista.size(); i++)
                    {
                        if (lista.GetElementAtPos(i).Salario == rango)
                        {
                            jugador = lista.GetElementAtPos(i);
                            break;
                        }
                    }
                }

                else
                {
                    throw new ArgumentNullException("No hay ninguna lista seleccionada");
                }
                break;

            default:
                break;
            }
            return(jugador);
        }
        public void remove_node_in_middle_of_list_with_multiple_nodes()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);
            list.Add(10);
            list.Add(15);

            // assert
            Assert.AreEqual(true, list.Remove(10));
            Assert.AreEqual(5, list.First.Value);
            Assert.AreEqual(15, list.Last.Value);
            Assert.AreEqual(15, list.First.Next.Value);
            Assert.AreEqual(5, list.Last.Previous.Value);
        }
        public void remove_empty_list()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act

            // assert
            Assert.AreEqual(false, list.Remove(99));
            Assert.IsNull(list.First);
            Assert.IsNull(list.Last);
        }
        public void must_add_node_with_correct_value()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(10);

            // assert
            Assert.AreEqual(10, list.First.Value);
        }
        public void iterate_through_entire_list_and_yield_results()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);
            list.Add(10);
            list.Add(15);

            var result = "";

            foreach (var item in list.Traverse())
            {
                result += item.ToString();
            }

            // assert
            Assert.AreEqual("51015", result);
        }
Пример #26
0
        public void GetByIndexTestNegative(int[] array, int index)
        {
            DoubleLinkedList a = new DoubleLinkedList(array);

            Assert.Throws <IndexOutOfRangeException>(() => a[index]++);
        }
Пример #27
0
        public void AddByIndexTestNegative(int[] array, int index, int value)
        {
            DoubleLinkedList a = new DoubleLinkedList(array);

            Assert.Throws <IndexOutOfRangeException>(() => a.AddByIndex(index, value));
        }
Пример #28
0
        static void DSDoublLinkedListMain(string[] args)
        {
            try
            {
                DoubleLinkedList doubleLinkedList = new DoubleLinkedList();

                Console.WriteLine("Effect of Add First (30,20, 10)");
                doubleLinkedList.AddFirst(30);
                doubleLinkedList.AddFirst(20);
                doubleLinkedList.AddFirst(10);
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Add Last(40,50)");
                doubleLinkedList.AddLast(40);
                doubleLinkedList.AddLast(50);
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Add At position(3) value(25)");
                doubleLinkedList.AddAt(25, 3);
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Remove At Position(3) value(25)");
                doubleLinkedList.RemoveAt(3);
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Get Kth Node From End( get 3rd node)");
                int result = doubleLinkedList.GetKthNodeFromEnd(3);
                Console.WriteLine("3rd node from end is: {0}", result);

                Console.WriteLine();
                Console.WriteLine("Effect of Print Middle Node (when size is odd)");
                doubleLinkedList.PrintMiddleNode();

                Console.WriteLine();
                Console.WriteLine("Effect of Print Middle Node (when size is even)");
                Console.WriteLine("Adding 1 more node 60 at the end");
                doubleLinkedList.AddLast(60);
                doubleLinkedList.PrintMiddleNode();
                doubleLinkedList.RemoveLast();

                Console.WriteLine();
                Console.WriteLine("Effect of Delete Middle Node (when size is odd)");
                doubleLinkedList.RemoveMiddleNode();
                doubleLinkedList.Print();
                doubleLinkedList.AddAt(30, 3);

                Console.WriteLine();
                Console.WriteLine("Effect of Delete Middle Node (when size is even)");
                Console.WriteLine("Adding 1 more node 60 at the end");
                doubleLinkedList.AddLast(60);
                doubleLinkedList.RemoveMiddleNode();
                doubleLinkedList.Print();
                doubleLinkedList.AddAt(30, 3);
                doubleLinkedList.AddAt(40, 4);
                doubleLinkedList.RemoveLast();

                Console.WriteLine();
                Console.WriteLine("Effect of Remove First(10)");
                doubleLinkedList.RemoveFirst();
                doubleLinkedList.Print();
                doubleLinkedList.AddFirst(10);

                Console.WriteLine();
                Console.WriteLine("Effect of Remove Last(50)");
                doubleLinkedList.RemoveLast();
                doubleLinkedList.Print();
                doubleLinkedList.AddLast(50);

                Console.WriteLine();
                Console.WriteLine("Effect of Remove Even Nodes");
                doubleLinkedList.RemoveEvenNodes();
                doubleLinkedList.Print();
                doubleLinkedList.AddAt(20, 2);
                doubleLinkedList.AddAt(40, 4);

                Console.WriteLine();
                Console.WriteLine("Effect of Remove Odd Nodes");
                doubleLinkedList.RemoveOddNodes();
                doubleLinkedList.Print();
                doubleLinkedList.AddAt(10, 1);
                doubleLinkedList.AddAt(30, 3);
                doubleLinkedList.AddAt(50, 5);

                Console.WriteLine();
                Console.WriteLine("Effect of Remove First Node By Value(30)");
                doubleLinkedList.RemoveFirstNodeByValue(30);
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Remove Last Node By Value(30)");
                doubleLinkedList.RemoveLastNodeByValue(30);
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Remove All Nodes By Value(30)");
                Console.WriteLine("Adding 3 more 30's in different places");
                doubleLinkedList.AddAt(30, 5);
                doubleLinkedList.AddAt(30, 2);
                doubleLinkedList.AddAt(30, 1);
                doubleLinkedList.Print();
                doubleLinkedList.RemoveAllNodesByValue(30);
                Console.WriteLine("After Remove");
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Reverse Linked List");
                doubleLinkedList.Reverse();
                doubleLinkedList.Print();

                Console.WriteLine();
                Console.WriteLine("Effect of Remove All");
                doubleLinkedList.RemoveAll();
                doubleLinkedList.Print();

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #29
0
 public ParseTokenEnumerator(DoubleLinkedList <TokenLine> lines, string filename, Language lang)
     : base(lines, filename, lang)
 {
     updatelocations = true;
 }
        public void remove_one_node_in_list_with_only_one_node()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);

            // assert
            Assert.AreEqual(true, list.Remove(5));
            Assert.IsNull(list.First);
            Assert.IsNull(list.Last);
        }
 public void TestNegativeIndex()
 {
     List += 5;
     var haha = List[-1];
 }
        // Function to merge two list into one list in sorted order.
        public static DoubleLinkedList <int> MergeList(DoubleLinkedList <int> listA, DoubleLinkedList <int> listB)
        {
            // Create new list to be the merged one
            DoubleLinkedList <int> mergedList = new DoubleLinkedList <int>();

            // Getting the size of the list being the sum of the sizes of the two parameters list
            int mergedListSize = listA.Size() + listB.Size();

            // Started Index
            int mergedIndex = 0;

            // Index to check in the list
            int indexA = 0;
            int indexB = 0;

            // Loop until fill all the merged list with the values of the other list
            // increasing the merged index until it stay less than the size of the
            // merged ist
            while (mergedIndex < mergedListSize)
            {
                // Check which values is smaller and adding to the list
                // increase the index

                // If the index of B is the size of the list, so it reach it max value
                // so everything will be on the left list
                if (indexB == listB.Size())
                {
                    mergedList.Append(listA.Get(indexA));
                    indexA++;
                    mergedIndex++;
                    continue;
                }

                // If the index of A is the size of the list, so it reach it max value
                // so everything will be on the left list
                if (indexA == listA.Size())
                {
                    mergedList.Append(listB.Get(indexB));
                    indexB++;
                    mergedIndex++;
                    continue;
                }

                // Sorting the values on the list and increasing the indexes
                if (listA.Get(indexA) < listB.Get(indexB))
                {
                    mergedList.Append(listA.Get(indexA));
                    indexA++;
                }
                else
                {
                    mergedList.Append(listB.Get(indexB));
                    indexB++;
                }
                // Do it until the merged index reach the max.
                mergedIndex++;
            }

            // Return the merged list.
            return(mergedList);
        }
 public void Setup()
 {
     List = new DoubleLinkedList<double>();
 }
 private void AddLast(DoubleLinkedList <char> list)
 {
     list.AddLast('-');
 }
Пример #35
0
        public void EditByIndexTestNegative(int[] array, int index, int value)
        {
            DoubleLinkedList actual = new DoubleLinkedList(array);

            Assert.Throws <IndexOutOfRangeException>(() => actual[index] = value);
        }
        public void head_and_tail_must_have_correct_values()
        {
            // assemble
            var list = new DoubleLinkedList<int>();

            // act
            list.Add(5);
            list.Add(15);

            // assert
            Assert.AreEqual(5, list.First.Value);
            Assert.AreEqual(15, list.Last.Value);
        }
Пример #37
0
 private static DoubleLinkedList Join(DoubleLinkedList prefix, DoubleLinkedList suffix, in int treeData)
Пример #38
0
        static void Main(string[] args)
        {
            Person p = new Person("Elias", "Rist", new DateTime(2000, 4, 24));
            //Person p1 = new Person("Elias", "Rist", new DateTime(2000, 4, 24));
            Person p2 = new Person("Emil", "Rost", new DateTime(2000, 8, 28));
            Person p3 = new Person("Tobias", "Flöckinger", new DateTime(2000, 8, 3));
            Person p4 = new Person("Thomas", "Mairer", new DateTime(2000, 3, 3));
            //Person p5 = new Person("Rudolf", "Materhorn", new DateTime(1999, 3, 3));

            DoubleLinkedList <Person> dll = new DoubleLinkedList <Person>();

            dll.Add(p);
            dll.Add(p2);
            dll.Add(p3);
            dll.Add(p4);

            /*
             * --------------------------------------------------------------------
             * //Personen können gespeichert und abgerufen werden
             * DoubleLinkedListItem<Person> item = new DoubleLinkedListItem<Person>(p3,null,null);
             * Console.WriteLine(item);
             * --------------------------------------------------------------------
             */
            /*
             * ---------------------------------------------------------------------
             * //Methode Add Test
             * DoubleLinkedList<Person> dll = new DoubleLinkedList<Person>();
             *
             * if (dll.Add(p))
             * {
             *  Console.WriteLine("Person wurde hinzugefügt!");
             * }
             * else
             * {
             *  Console.WriteLine("Person konnte nicht hinzugefügt werden.");
             * }
             * if (dll.Add(new Person("Tobias", "Flöckinger", new DateTime(2000, 8, 12))))
             * {
             *  Console.WriteLine("Person wurde hinzugefügt!");
             * }
             * else
             * {
             *  Console.WriteLine("Person konnte nicht hinzugefügt werden.");
             * }
             * Console.WriteLine("komplette DLL ausgegeben.");
             * Console.WriteLine(dll);
             * --------------------------------------------------------------------
             */

            //Methode Remove Test
            if (dll.Remove(p4))
            {
                Console.WriteLine(" letztes Item wurde  gelöscht");
            }
            else
            {
                Console.WriteLine("wurde nicht gefunden ");
            }
            Console.WriteLine(dll);

            Console.ReadKey();
        }
Пример #39
0
        public void RemoveNElementsByIndex_WhenValidValuePassed_ShouldReturnArgumentException_NegativeTests(int n, int index, int[] actualArray)
        {
            DoubleLinkedList actual = DoubleLinkedList.Create(actualArray);

            Assert.Throws <ArgumentException>(() => actual.RemoveNElementsByIndex(n, index));
        }
    void Start()
    {
        Debug.Log("Comienzo test de lista enlazada ------------------>");

        //-------------------> Inserte aqui su lista enlazada.
        //-------------------> vvvvvvvvvvvvvvvvvvvvvvvv   <
        ILinkedList <int> dinamicArray = new DoubleLinkedList <int>();

        //-------------------> ^^^^^^^^^^^^^^^^^^^^^^^^   <

        dinamicArray.AddFirst(10);
        dinamicArray.AddFirst(20);
        dinamicArray.AddFirst(30);

        //print("E1: " + dinamicArray[0] + " E2: " + dinamicArray[1] + " E3: " + dinamicArray[2]);

        if (dinamicArray.Count != 3)
        {
            Debug.LogWarning("Count no vale lo que deberia.");
        }

        if (!CheckEquality(dinamicArray, new List <int>()
        {
            30, 20, 10
        }))
        {
            Debug.LogWarning("Los elementos contenidos no son los correctos.");
        }

        dinamicArray.AddLast(40);
        dinamicArray.AddLast(50);
        dinamicArray.AddLast(60);

        //print("E1: " + dinamicArray[0] + " E2: " + dinamicArray[1] + " E3: " + dinamicArray[2] + " E4: " + dinamicArray[3] + " E5: " + dinamicArray[4] + " E6: " + dinamicArray[5]);


        if (dinamicArray.Count != 6)
        {
            Debug.LogWarning("Count no vale lo que deberia.");
        }

        if (!CheckEquality(dinamicArray, new List <int>()
        {
            30, 20, 10, 40, 50, 60
        }))
        {
            Debug.LogWarning("Los elementos contenidos no son los correctos.");
        }

        if (dinamicArray.First != 30)
        {
            Debug.LogWarning("First no vale lo que deberia.");
        }

        if (dinamicArray.Last != 60)
        {
            Debug.LogWarning("Last no vale lo que deberia.");
        }

        dinamicArray.RemoveFirst();

        if (dinamicArray.Count != 5)
        {
            Debug.LogWarning("Count no vale lo que deberia.");
        }

        if (!CheckEquality(dinamicArray, new List <int>()
        {
            20, 10, 40, 50, 60
        }))
        {
            Debug.LogWarning("Los elementos contenidos no son los correctos.");
        }

        if (dinamicArray.First != 20)
        {
            Debug.LogWarning("First no vale lo que deberia.");
        }

        dinamicArray.RemoveLast();

        if (dinamicArray.Count != 4)
        {
            Debug.LogWarning("Count no vale lo que deberia.");
        }

        if (!CheckEquality(dinamicArray, new List <int>()
        {
            20, 10, 40, 50
        }))
        {
            Debug.LogWarning("Los elementos contenidos no son los correctos.");
        }

        if (dinamicArray.Last != 50)
        {
            Debug.LogWarning("First no vale lo que deberia.");
        }

        if (dinamicArray.Contains(30) || !dinamicArray.Contains(20))
        {
            Debug.LogWarning("Hay un problema con el contains");
        }

        dinamicArray.Clear();

        if (dinamicArray.Count != 0)
        {
            Debug.LogWarning("Count no vale lo que deberia.");
        }

        if (!CheckEquality(dinamicArray, new List <int>()))
        {
            Debug.LogWarning("Los elementos contenidos no son los correctos.");
        }

        Debug.Log("Si llega hasta aca sin loguear nada esta todo correcto.");

        Debug.Log("Fin de test de lista enlazada <--------------------");
    }
Пример #41
0
        public void Remove_WhenValidValuePassed_ShouldReturnNullReferenceException_NegativeTests(int[] actualArray)
        {
            DoubleLinkedList actual = DoubleLinkedList.Create(actualArray);

            Assert.Throws <NullReferenceException>(() => actual.Remove());
        }
Пример #42
0
    static void Main()
    {
        DoubleLinkedList list = new DoubleLinkedList();

        Console.Clear();
        Console.WriteLine("Double Linked List created. Possible commands are:");
        Console.WriteLine("----------------------------------------------");
        Console.WriteLine("a <Фамилия> <Средняя оценка> - добавление нового студента");
        Console.WriteLine("p - напечатать список");
        Console.WriteLine("l - вывести длину списка");
        Console.WriteLine("e - проверить - есть ли студенты в списке");
        Console.WriteLine("w <Фамилия> <Средняя оценка> - добавление нового студента в конец списка");
        Console.WriteLine("s <Фамилия> - поиск студента в списке");
        Console.WriteLine("r <Фамилия> - удаление студента из списка");
        Console.WriteLine("sn - отсортировать список по фамилиями");
        Console.WriteLine("sm - отсортировать список по оценкам");
        Console.WriteLine("x - exit");
        Console.WriteLine("----------------------------------------------");

        while (true)
        {
            Console.Write("> ");
            string[] str = Console.ReadLine().Split(' ');
            switch (str[0].ToCharArray()[0])
            {
            case 'a':
                list.add(str[1], float.Parse(str[2]));
                break;

            case 'p':
                list.print();
                break;

            case 'l':
                Console.WriteLine(list.length());
                break;

            case 'e':
                Console.WriteLine("Пуст? -" + list.isEmpty());
                break;

            case 'w':
                list.append(str[1], float.Parse(str[2]));
                break;

            case 's':
                if (str[0] == "s")
                {
                    list.search(str[1]);
                }
                if (str[0] == "sn")
                {
                    list.sortName();
                }
                if (str[0] == "sm")
                {
                    list.sortMark();
                }
                break;

            case 'r':
                list.remove(str[1]);
                break;

            case 'x':
                return;

            default:
                Console.WriteLine("No such command");
                break;
            }
        }
    }
Пример #43
0
 public LetterIterator(int currentIndex, DoubleLinkedList <T> doubleLinkedList)
     : base(currentIndex, doubleLinkedList)
 {
 }
 public void TestInsertRetrieveCurrent()
 {
     List += 13;
     Assert.AreEqual(13, List.Current.Value);
 }
Пример #45
0
 /// <summary>
 /// Internal use
 /// </summary>
 /// <param name="mlines">The mlines.</param>
 /// <param name="filename">The filename.</param>
 /// <returns></returns>
 internal virtual int Parse(DoubleLinkedList <TokenLine> mlines, string filename)
 {
     return(Parse(mlines, filename, null));
 }
 private void AddLast(DoubleLinkedList <string> list)
 {
     list.AddLast("Jomo Sono");
 }
Пример #47
0
 public PreprocessorTokenEnumerator(DoubleLinkedList <TokenLine> lines, string filename, Language lang)
     : base(lines, filename, lang)
 {
 }
        public void DeleteNElementsByIndexNegativeTest(int n, int index, int[] array)
        {
            DoubleLinkedList actual = new DoubleLinkedList(array);

            Assert.Throws <IndexOutOfRangeException>(() => actual.DeleteNElementsByIndex(n, index));
        }
 public void TestMultipleInsert()
 {
     List += 13;
     List += 1;
     List += 5;
     Assert.AreEqual(13, List.First.Value);
     Assert.AreEqual(13, List.Current.Value);
     Assert.AreEqual(5, List.Last.Value);
 }
        public void AddByIndexNegativeTest(int index, int value, int[] array)
        {
            DoubleLinkedList actual = new DoubleLinkedList(array);

            Assert.Throws <IndexOutOfRangeException>(() => actual.AddByIndex(index, value));
        }
 public void TestNullInsertException()
 {
     DoubleLinkedList<IComparable> list = new DoubleLinkedList<IComparable>();
     list += null;
 }
Пример #52
0
 public BubbleSortWithFlagAndPosition(DoubleLinkedList <Student> students) : base(students)
 {
 }
 public void TestSuccessor()
 {
     List += 5;
     List += 3;
     Assert.AreEqual(3, List.First.Successor.Value);
     Assert.AreEqual(List.Last.Value, List.First.Successor.Value);
     Assert.IsNull(List.Last.Successor);
 }
Пример #54
0
 public LinkEnumerator(DoubleLinkedList <LinkRegistration <T> > .Node?firstNode)
 {
     this._nextNode = firstNode;
     this.Current   = default !;
Пример #55
0
 //=====================//
 //Event Handler Methods//
 //=====================//
 private void HandleChange(DoubleLinkedList list)
 {
     UpdateDisplay();
 }
Пример #56
0
 public SelectionSortMinOrMax(DoubleLinkedList <Student> students) : base(students)
 {
 }
Пример #57
0
 private Singleton()
 {
     orders    = new DoubleLinkedList <PharmacyModel>();
     inventory = new DoubleLinkedList <PharmacyModel>();
     guide     = new BinaryTree <Drug>();
 }
Пример #58
0
        }                                                     //para que no se inicialice desde otro lugar

        public LlaveValor(int llave)
        {
            Llave = llave;
            Valor = new DoubleLinkedList <V>();
        }
 public void TestInsertRetrieveLast()
 {
     List += 13;
     Assert.AreEqual(13, List.Last.Value);
 }
        public void FindIndexOfMinElementNegativeTest(int[] array)
        {
            DoubleLinkedList actual = new DoubleLinkedList(array);

            Assert.Throws <ArgumentOutOfRangeException>(() => actual.FindIndexOfMinElement());
        }