public void DeleteTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(1); lst.Add(2); lst.Add(3); lst.Add(4); lst.Add(5); lst.Delete(2); int expected = 4; NUnit.Framework.Assert.AreEqual(expected, lst[2]); }
public void InsertTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(1); lst.Add(2); lst.Add(3);// lst.Add(4); lst.Add(5); lst.Insert(2, 10); int expected = 10; NUnit.Framework.Assert.AreEqual(expected, lst[2]); }
public void RemoveTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(5); lst.Add(3); int expected = 1; lst.Remove(5); NUnit.Framework.Assert.AreEqual(expected, lst.Count()); }
public void ClearTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(5); lst.Add(4); lst.Add(3); lst.Add(2); lst.Add(1); int expected = 0; lst.Clear(); NUnit.Framework.Assert.AreEqual(expected, lst.Count()); }
public mListPrev() { data = 0; next = null; previous = null; }
public void AddTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(5); int expected = 5; NUnit.Framework.Assert.AreEqual(expected, lst[0]); }
public mListPrev(int value) { data = value; next = null; previous = null; }
public void Remove(int value) { var temp = first; mListPrev current = null; int k = 0; while(temp!=null) { if (temp.Data == value && temp.Data != last.Data && temp.Data != first.Data&& k==0) { current.Next = temp.Next; temp = temp.Next; size = size - 1; k++; } else if(temp.Data==value && temp.Data==last.Data&& k==0) { last = temp.Previous; last.Next = null; size = size - 1; k++; break; } current = temp; temp = temp.Next; if (first.Data == value&& k==0 ) { k++; current = temp; first = current; current.Previous = null; temp = temp.Next; size = size - 1; } } }
public void AddToStart(int value) { var temp = first; mListPrev current = null; current = new mListPrev(value); current.Next = temp; first = current; temp.Previous=first; temp = first; size++; }
public void DelFirst() { first = first.Next; first.Previous = null; size = size - 1; }
public void Insert (int position, int value) { var temp = first; mListPrev current = null; int counter = 0; int k=0; while (temp!=null) { if (position == 0 && k == 0) { this.AddToStart(value); k++; } else if (position==counter) { current = new mListPrev(value); current.Next = temp; current.Previous = temp.Previous; temp.Previous = current; var tempPrevios = current.Previous; tempPrevios.Next = current; temp = current; size++; } else if (counter == size-1 && position==size) { current = new mListPrev(value); current.Next = null; current.Previous = temp; temp.Next = current; last = current; size++; break; } current = temp; temp = temp.Next; counter++; } }
public void Delete(int position) { var temp = first; mListPrev current = null; int k = 0; int counter = 0; while (temp != null) { if (position == 0 && k==0) { this.DelFirst(); k++; } else if (position == size-1) { last = last.Previous; last.Next = null; size = size - 1; k++; break; } else if (position == counter) { current.Next = temp.Next; temp = temp.Next; size = size - 1; } current = temp; temp = temp.Next; counter++; } }
public void Clear() { mListPrev temp = first; mListPrev current=null; while (temp!=null) { current = temp; temp = temp.Next; current = null; } last = null; first = null; size=0; }
public void AddToStartTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(1); lst.Add(2); lst.Add(3); lst.AddToStart(10); int expected = 10; NUnit.Framework.Assert.AreEqual(expected, lst[0]); }
public mListPrev(int value, mListPrev res) { data = value; next = res; previous = null; }
public void DelFirstTest() { MyList.mListPrev lst = new MyList.mListPrev(); lst.Add(1); lst.Add(2); lst.Add(3); lst.DelFirst(); int expected = 2; NUnit.Framework.Assert.AreEqual(expected, lst[0]); }
public void Add(int value) { mListPrev current = new mListPrev(value); if (first == null) { first = current; last = current; } else { last.Next = current; var temp = last; last = current; last.Previous = temp; } size++; }