示例#1
0
        public void AllocationFreeing()
        {
            MonitoredUnmanagedMemory mem  = new MonitoredUnmanagedMemory();
            XorLinkedList            list = new XorLinkedList(mem);

            list.Append(1);
            list.Append(2);
            list.Append(3);
            list.RemoveAt(0);
            Assert.Equal(2, mem.currentAllocations.Count);
            list.RemoveAt(0);
            Assert.Single(mem.currentAllocations);
            list.RemoveAt(0);
            Assert.Empty(mem.currentAllocations);
        }
示例#2
0
        public void RemoveAt()
        {
            XorLinkedList list = new XorLinkedList(new MonitoredUnmanagedMemory());

            list.Append(1);
            list.Append(2);
            list.Append(3);
            list.Append(4);
            list.Append(5);

            Assert.Equal(3, list.RemoveAt(2));
            Assert.Equal(1, list.RemoveAt(0));
            Assert.Equal(5, list.RemoveAt(2));

            Assert.Equal(2, list.GetAt(0));
            Assert.Equal(4, list.GetAt(1));
            Assert.Null(list.GetAt(2));

            Assert.Null(list.RemoveAt(-1));
            Assert.Equal(2, list.RemoveAt(0));
            Assert.Equal(4, list.RemoveAt(0));
            Assert.Null(list.RemoveAt(0));
        }