static void Main(string[] args) { SinglyLinkedList PlayList = new SinglyLinkedList(); PlayList.Add(2).Add(5).Add(6).Remove(); PlayList.Add(22); PlayList.Add(2222); PlayList.Add(2222222); PlayList.Remove(); PlayList.RemoveAt(1); PlayList.Display(); // SllNode target = PlayList.Find(22); // Console.WriteLine(target.Value); Console.WriteLine("Hello World!"); }
static void Main(string[] args) { SinglyLinkedList list = new SinglyLinkedList(); list.Add(4); list.Add(7); list.Add(5); list.Add(2); list.Add(3); list.PrintValues(); Console.WriteLine("-----"); list.Remove(); list.PrintValues(); Console.WriteLine("-----"); // list.RemoveAt(2); // list.PrintValues(); }
static void Main(string[] args) { SinglyLinkedList MyList = new SinglyLinkedList(); MyList.Add(1); MyList.Add(2); MyList.Add(3); MyList.Add(4); MyList.Add(5); MyList.Add(6); MyList.Add(7); MyList.Add(8); MyList.Add(9); MyList.Add(10); MyList.PrintValues(); MyList.Remove(); MyList.PrintValues(); }
static void Main(string[] args) { //Single Linked List are Ideal for creating a que for say a playlist. SinglyLinkedList list = new SinglyLinkedList(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); // find (2)---this will print the value for val in list--(2) list.PrintVal(); // remove- similar to arrays we can specify the index to remove as well list.Remove();//the last item in the list list.PrintVal();//this should print All Node values.... 1,2,3,4,5 except the 0 index which is one. //expeted output should be 2,3,4,5 on the last print line. }
public void CountChangesOnRemoval() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("foo"); Assert.AreEqual(2, list.Count()); list.Remove("bar"); Assert.AreEqual(1, list.Count()); list.Remove("grille"); Assert.AreEqual(0, list.Count()); }
public void ListRemoveWithDuplicateNodes() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille", "bar"); list.Remove("bar"); var expected = new string[] { "foo", "grille", "bar" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveNonExistentNode() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("cat"); var expected = new string[] { "foo", "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveLastItemFromList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("grille"); var expected = new string[] { "foo", "bar" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void IndexOfRemovedElement() { SinglyLinkedList list = new SinglyLinkedList(); list.AddLast("foo"); list.AddLast("bar"); list.AddLast("grille"); list.Remove("foo"); Assert.AreEqual(-1, list.IndexOf("foo")); }
public void ListRemoveItemFromMiddleOfList() { SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo", "bar", "grille"); list.Remove("bar"); var expected = new string[] { "foo", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveFirstNode() { SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo", "bar", "grille"); list.Remove("foo"); var expected = new string[] { "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
static void Main(string[] args) { SinglyLinkedList list = new SinglyLinkedList(); list.AddToFront(1); list.AddToFront(2); list.AddToFront(3); list.AddToBack(45); list.AddToBack(55); list.AddToBack(65); Console.WriteLine(list.Size()); Console.WriteLine("------------------------------------1"); Console.WriteLine(list.Contains(5)); Console.WriteLine("------------------------------------2"); Console.WriteLine(list.Contains(55)); Console.WriteLine("------------------------------------3"); list.Show(); Console.WriteLine("------------------------------------4"); list.Insert(10, 3); list.Show(); Console.WriteLine("------------------------------------5"); list.Insert(10, 7); list.Show(); Console.WriteLine("------------------------------------6"); list.Insert(10, 9); list.Insert(10, 0); list.Remove(5); list.Show(); Console.WriteLine("------------------------------------7"); list.Remove(list.Size()); list.Show(); Console.WriteLine("------------------------------------8"); list.Remove(2); list.Show(); Console.WriteLine("------------------------------------9"); list.Remove(1); list.Show(); Console.WriteLine("-----------------------------------10"); list.Insert(100, 1); list.Show(); Console.WriteLine("-----------------------------------11"); list.Remove(list.Size()); list.Show(); Console.WriteLine("-----------------------------------12"); list.Remove(list.Size()); list.Show(); Console.WriteLine("-----------------------------------13"); list.Remove(list.Size()); list.Show(); Console.WriteLine("-----------------------------------14"); list.Remove(list.Size()); list.Show(); Console.WriteLine("-----------------------------------15"); list.Remove(list.Size()); list.Show(); Console.WriteLine("-----------------------------------16"); list.Remove(list.Size()); list.Show(); Console.WriteLine("-----------------------------------17"); list.Insert(200, 2); list.Insert(100, 1); list.Insert(0, 0); // this is the same as add to front list.Insert(10, list.Size()); // this is the same as add to back but will fail if list is null list.Show(); Console.WriteLine("-----------------------------------18"); list.Remove(1); list.Show(); Console.WriteLine("-----------------------------------19"); // I think I need to edit how insert and remove work. Currently, Remove will remove the specified number (non 0 based index) and insert inserts after the specified index (or at 0 based) }
public void CountChangesOnRemoval() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); // throw new ArgumentException(list.Count().ToString()); list.Remove("foo"); Assert.AreEqual(2, list.Count()); list.Remove("bar"); Assert.AreEqual(1, list.Count()); list.Remove("grille"); Assert.AreEqual(0, list.Count()); }
public void ListRemoveFirstNode() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("foo"); var expected = new string[] { "bar", "grille" }; //throw new ArgumentException(list.ToString()); CollectionAssert.AreEqual(expected, list.ToArray()); }