public void ListOnlyHasOneNodeHeadIsTail() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); Assert.Equal(list.Head, list.Tail); }
public void ListOnlyHasTwoTermsNextValueIsEqualToPrevious() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); list.AddLast(2); Assert.Equal(list.Find(2), list.Head.Prev); }
public void HeadPrevIsTailAndTailNextIsHead(int first, int last) { var list = new CircularlyLinkedList <int>(); list.AddFirst(first); list.AddLast(last); Assert.Equal(list.Find(last), list.Find(first).Prev); Assert.Equal(list.Find(first), list.Find(last).Next); }
public void AddingLastMakesNewValueTheTail() { var list = new CircularlyLinkedList <int>(); for (int i = 10; i > 0; i--) { list.AddLast(i); } Assert.Equal(1, list.Tail.Value); }
public void RemovingHeadMakesNextValueNewHead() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); list.AddLast(2); list.AddLast(3); list.RemoveFirst(); Assert.Equal(2, list.Head.Value); }
public void LastItemNextIsHead() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); list.AddLast(2); list.AddAfter(list.Find(2), 3); Assert.Equal(1, list.Tail.Next.Value); //Assert.Equal(3, list.Head.Prev.Value); }
public void AddFirstChangesHeadToNewValue() { var list = new CircularlyLinkedList <int>(); for (int i = 0; i < 11; i++) { list.AddFirst(i); } Assert.Equal(10, list.Head.Value); }
public void RemovingValueSetsPreviousValuesNextToTheRemovedValuesNext() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); list.AddLast(3); list.AddLast(5); list.AddLast(7); list.Remove(5); Assert.Equal(7, list.Find(3).Next.Value); }
public void RemovingLastTailIsShiftedToNewValue() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); list.AddLast(2); list.AddLast(3); list.AddLast(4); list.RemoveLast(); Assert.Equal(3, list.Tail.Value); }
public void AddingAndRemovingIncrementsAndDecrementsTheCount() { var list = new CircularlyLinkedList <int>(); list.AddFirst(1); list.AddAfter(list.Find(1), 3); list.AddBefore(list.Find(3), 2); list.AddLast(4); Assert.Equal(4, list.Count); list.RemoveFirst(); list.RemoveLast(); list.Remove(3); Assert.Equal(1, list.Count); }
static void Main(string[] args) { var list = new CircularlyLinkedList <int>(); list.AddLast(5); list.AddLast(15); list.AddLast(25); list.AddLast(35); list.AddLast(45); foreach (var item in list) { ; } Console.ReadKey(); }