public void Insert_LinkArrayToLinkedList_ReturnArrayHaveSameItems()
        {
            var linkedList = new UnrolledLinkedList(6);
            var contest    = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

            foreach (var number in contest)
            {
                linkedList.Insert(number);
            }

            var result = linkedList.GetRolledItems();

            result.Should().BeEquivalentTo(contest);
        }
Ejemplo n.º 2
0
        public void CanFindElements()
        {
            var sut = new UnrolledLinkedList <int>();

            for (var i = 0; i < 6; i++)
            {
                sut.Add(i);
            }

            var node = sut.Find(5);

            Assert.Equal(1, node.CurrentIndex);
            Assert.Equal(5, node.Values[0]);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var list = new UnrolledLinkedList<int>(5);

            for (int i = 0; i < 15000; i++)
            {
                list.Add(i);
            }

            Console.Write(list.Sum() + " / ");
            Console.Write(list.Count() + " = ");
            Console.WriteLine(list.Average());
            Console.WriteLine(list.Print());
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public void UnrolledLinkedListUnrollsIntoArray()
        {
            var sut = new UnrolledLinkedList <int>();

            for (var i = 0; i < 10000; i++)
            {
                sut.Add(i);
            }

            var unrolled = sut.Unroll();

            for (var i = 0; i < 10000; i++)
            {
                Assert.Equal(i, unrolled[i]);
            }
        }