public void ClearNonEmptyList(T[] items)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                list.Clear();
                Assert.Empty(list); //"Should be equal to 0."
            }
            public void InsertRangeList(T[] itemsX, T[] itemsY, int index, int repeat, Func <T[], IEnumerable <T> > constructIEnumerable)
            {
                var list = new DoublyCircularLinkedList <T>(constructIEnumerable(itemsX));

                for (var i = 0; i < repeat; i++)
                {
                    list.InsertRange(index, new DoublyCircularLinkedList <T>(constructIEnumerable(itemsY)));
                }

                foreach (var item in itemsY)
                {
                    Assert.Contains(item, list);                                    //"Should contain the item."
                }
                Assert.Equal(list.Count, itemsX.Length + (itemsY.Length * repeat)); //"Should have the same result."

                for (var i = 0; i < index; i++)
                {
                    Assert.Equal(list[i], itemsX[i]); //"Should have the same result."
                }

                for (var i = index; i < index + (itemsY.Length * repeat); i++)
                {
                    Assert.Equal(list[i], itemsY[(i - index) % itemsY.Length]); //"Should have the same result."
                }

                for (var i = index + (itemsY.Length * repeat); i < list.Count; i++)
                {
                    Assert.Equal(list[i], itemsX[i - (itemsY.Length * repeat)]); //"Should have the same result."
                }
            }
            public void BasicInsert(T[] items, T item, int index, int repeat)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                for (var i = 0; i < repeat; i++)
                {
                    list.Insert(index, item);
                }

                Assert.Contains(item, list);                     //"Expect it to contain the item."
                Assert.Equal(list.Count, items.Length + repeat); //"Expect to be the same."


                for (var i = 0; i < index; i++)
                {
                    Assert.Equal(list[i], items[i]); //"Expect to be the same."
                }

                for (var i = index; i < index + repeat; i++)
                {
                    Assert.Equal(list[i], item); //"Expect to be the same."
                }


                for (var i = index + repeat; i < list.Count; i++)
                {
                    Assert.Equal(list[i], items[i - repeat]); //"Expect to be the same."
                }
            }
            public void ClearEmptyList()
            {
                var list = new DoublyCircularLinkedList <T>();

                Assert.Empty(list); //"Should be equal to 0"
                list.Clear();
                Assert.Empty(list); //"Should be equal to 0."
            }
            public void NonExistingValues(T[] itemsX, T[] itemsY)
            {
                var list = new DoublyCircularLinkedList <T>(itemsX);

                for (var i = 0; i < itemsY.Length; i++)
                {
                    Assert.DoesNotContain(itemsY[i], list); //"Should not contain item"
                }
            }
            public void BasicContains(T[] items)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                for (var i = 0; i < items.Length; i++)
                {
                    Assert.Contains(items[i], list); //"Should contain item."
                }
            }
            public void ClearMultipleTimesNonEmptyList(T[] items, int times)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                for (var i = 0; i < times; i++)
                {
                    list.Clear();
                    Assert.Empty(list); //"Should be equal to 0."
                }
            }
            public void InsertValidations(T[] items)
            {
                var list = new DoublyCircularLinkedList <T>(items);
                var bad  = new int[] { items.Length + 1, items.Length + 2, int.MaxValue, -1, -2, int.MinValue };

                for (var i = 0; i < bad.Length; i++)
                {
                    Assert.Throws <ArgumentOutOfRangeException>(() => list.Insert(bad[i], items[0])); //"ArgumentOutOfRangeException expected."
                }
            }
Exemple #9
0
 // 동서남북에 있는 탑다운카메라리그를 리스트에 넣어줌
 private void ListSetUp()
 {
     Transform[] transforms = GetComponentsInChildren <Transform>();
     camList = new DoublyCircularLinkedList <Transform>();
     for (int i = 1; i < transforms.Length; ++i)
     {
         camList.Add(transforms[i]);
     }
     iter = camList.front;
 }
            public void RemovedValues(T[] items)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                for (var i = 0; i < items.Length; i++)
                {
                    list.Remove(items[i]);
                    Assert.DoesNotContain(items[i], list); //"Should not contain item"
                }
            }
Exemple #11
0
        protected void VerifyList(DoublyCircularLinkedList <T> list, DoublyCircularLinkedList <T> expectedItems)
        {
            Assert.Equal(expectedItems.Count, list.Count);

            //Only verify the indexer. List should be in a good enough state that we
            //do not have to verify consistancy with any other method.
            for (var i = 0; i < list.Count; ++i)
            {
                Assert.True(list[i] == null ? expectedItems[i] == null : list[i].Equals(expectedItems[i]));
            }
        }
            public void BasicToArray(T[] items)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                var arr = list.ToArray();

                for (var i = 0; i < items.Length; i++)
                {
                    Assert.Equal(((Object)arr[i]), items[i]); //"Should be equal."
                }
            }
    public static void Main(string[] args)
    {
        DoublyCircularLinkedList ll = new DoublyCircularLinkedList();

        ll.addHead(1);
        ll.addHead(2);
        ll.addHead(3);
        ll.addHead(1);
        ll.addHead(2);
        ll.addHead(3);
        ll.print();
    }
            public void InsertRangeValidations(T[] items, Func <T[], IEnumerable <T> > constructIEnumerable)
            {
                var list = new DoublyCircularLinkedList <T>(constructIEnumerable(items));
                var bad  = new int[] { items.Length + 1, items.Length + 2, int.MaxValue, -1, -2, int.MinValue };

                for (var i = 0; i < bad.Length; i++)
                {
                    Assert.Throws <ArgumentOutOfRangeException>(() => list.InsertRange(bad[i], constructIEnumerable(items))); //"ArgumentOutOfRangeException expected"
                }

                Assert.Throws <ArgumentNullException>(() => list.InsertRange(0, null)); //"ArgumentNullException expected."
            }
Exemple #15
0
        public void Reverse()
        {
            var list       = Enumerable.Range(1, 10).ToList();
            var linkedList = new DoublyCircularLinkedList <int>(list);

            list.Reverse();
            linkedList.Reverse();
            for (var i = 0; i < list.Count; i++)
            {
                Assert.Equal(list[i], linkedList[i]);
            }
        }
            public void ContainsNullWhenReference(T[] items, T value)
            {
                if ((object)value != null)
                {
                    throw new ArgumentException("invalid argument passed to testcase");
                }

                var list = new DoublyCircularLinkedList <T>(items);

                list.Add(value);
                Assert.Contains(value, list); //"Should contain item."
            }
            public void AddRemoveValues(T[] items)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                for (var i = 0; i < items.Length; i++)
                {
                    list.Add(items[i]);
                    list.Remove(items[i]);
                    list.Add(items[i]);
                    Assert.Contains(items[i], list); //"Should contain item."
                }
            }
Exemple #18
0
        public void Constructor_IEnumerable(EnumerableType enumerableType, int listLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
        {
            var enumerable = CreateEnumerable(enumerableType, null, enumerableLength, 0, numberOfDuplicateElements);
            var list       = new DoublyCircularLinkedList <T>(enumerable);
            var expected   = enumerable.ToList();

            Assert.Equal(enumerableLength, list.Count); //"Number of items in list do not match the number of items given."

            for (var i = 0; i < enumerableLength; i++)
            {
                Assert.Equal(expected[i], list[i]); //"Expected object in item array to be the same as in the list"
            }
        }
            public void EnsureNotUnderlyingToArray(T[] items, T item)
            {
                var list = new DoublyCircularLinkedList <T>(items);
                var arr  = list.ToArray();

                list[0] = item;
                if (((Object)arr[0]) == null)
                {
                    Assert.NotNull(list[0]); //"Should NOT be null"
                }
                else
                {
                    Assert.NotEqual(((Object)arr[0]), list[0]); //"Should NOT be equal."
                }
            }
            public void MultipleValues(T[] items, int times)
            {
                var list = new DoublyCircularLinkedList <T>(items);

                for (var i = 0; i < times; i++)
                {
                    list.Add(items[items.Length / 2]);
                }

                for (var i = 0; i < times + 1; i++)
                {
                    Assert.Contains(items[items.Length / 2], list); //"Should contain item."
                    list.Remove(items[items.Length / 2]);
                }
                Assert.DoesNotContain(items[items.Length / 2], list); //"Should not contain item"
            }
Exemple #21
0
        public void Constructor_Default()
        {
            var list = new DoublyCircularLinkedList <T>();

            Assert.Empty(list); //"Do not expect anything to be in the list."
        }