static void Main() { var rev = new ReversedList<int>(); rev.Add(1); rev.Add(2); rev.Add(3); rev.Add(4); rev.Add(5); foreach (var item in rev) { Console.WriteLine(item); } Console.WriteLine(); Console.WriteLine("Count " + rev.Count); Console.WriteLine("Capacity " + rev.Capacity); Console.WriteLine("Element on index 0 -> " + rev[0]); Console.WriteLine("Remove element on index 0 -> " + rev.Remove(0)); Console.WriteLine("Count " + rev.Count); Console.WriteLine("Capacity " + rev.Capacity); Console.WriteLine(); rev[0] = 10; for (int i = 0; i < rev.Count; i++) { Console.WriteLine(rev[i]); } }
public static void Main() { var revList = new ReversedList <int>(); revList.Add(1); revList.Add(2); revList.Add(3); revList.Add(4); revList.Add(5); foreach (var num in revList) { Console.Write($"{num} "); } Console.WriteLine(); int indexOne = 0; int indexTwo = 4; Console.WriteLine(revList[indexOne]); Console.WriteLine(revList[indexTwo]); revList.RemoveAt(2); foreach (var num in revList) { Console.Write($"{num} "); } Console.WriteLine(); }
public void RemoveByIndexInFilledCollection() { var list = new ReversedList <int>(); list.Add(3); list.Add(45); list.Add(23000000); list.Add(24000000); list.Add(567); list.Remove(3); Assert.AreEqual(4, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(8, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); var items = new List <int>(); foreach (var item in list) { items.Add(item); } CollectionAssert.AreEqual(items, new List <int>() { 567, 24000000, 23000000, 3 }, MESSAGE_NOTCORRECTITEMS); }
public static void Main() { var reversedList = new ReversedList <int>(); // Add reversedList.Add(100); reversedList.Add(200); reversedList.Add(300); reversedList.Add(-400); // Indexer Console.WriteLine(reversedList[0]); reversedList[0] *= -1; Console.WriteLine(reversedList[0]); Print(reversedList); // RemoveAt for (int i = 0; i < 2; i++) { Console.WriteLine($"Removed: {reversedList.RemoveAt(reversedList.Count - 1)}"); Print(reversedList); Console.WriteLine($"Removed: {reversedList.RemoveAt(0)}"); Print(reversedList); } }
public static void Main() { var reversedList = new ReversedList<int>(4); reversedList.Add(1); reversedList.Add(2); reversedList.Add(3); reversedList.Add(4); // current list items are [4 3 2 1] // capacity will grow twice (8) then add 5 reversedList.Add(5); // current list items are [5 4 3 2 1] Console.WriteLine("Current list"); PrintList(reversedList); reversedList.Remove(4); // remove element at index 4 -> value 1 // current list items are [5 4 3 2] Console.WriteLine("\nRemove element at index 4"); PrintList(reversedList); Console.WriteLine("\nChange value = 10 of index 1"); reversedList[1] = 10; // change value = 10 of index 1 PrintList(reversedList); Console.WriteLine("\ncount: {0}", reversedList.Count); Console.WriteLine("capacity: {0}", reversedList.Capacity); }
static void Main(string[] args) { var testArr = new ReversedList<int>(); testArr.Add(1); testArr.Add(10); testArr.Add(5); testArr.Add(2); Console.WriteLine("Elements:"); testArr.ForEach(Console.WriteLine); Console.WriteLine("Count:"); Console.WriteLine(testArr.Count()); testArr.Add(-1); Console.WriteLine("Elements:"); testArr.ForEach(Console.WriteLine); Console.WriteLine("Count:"); Console.WriteLine(testArr.Count()); Console.WriteLine("Capacity:"); Console.WriteLine(testArr.Capacity()); Console.WriteLine("Elements:"); Console.WriteLine(string.Join(" ", testArr)); Console.WriteLine("Index 2:"); Console.WriteLine(testArr[2]); Console.WriteLine("Index 1:"); Console.WriteLine(testArr[1]); Console.WriteLine("Index 0:"); Console.WriteLine(testArr[0]); Console.WriteLine("Index 4:"); Console.WriteLine(testArr[4]); testArr.Sort(); Console.WriteLine("Sorted Elements:"); Console.WriteLine(string.Join(" ", testArr)); }
public static void Main(string[] args) { ReversedList<int> testList = new ReversedList<int>(); for (int i = 0; i < 100; i++) { testList.Add(i); } Console.WriteLine(testList[99]); Console.WriteLine(testList[0]); testList.Add(100); foreach (var number in testList) { Console.Write(number + ", "); } Console.WriteLine(); Console.WriteLine(testList.Count); testList.Remove(0); Console.WriteLine(testList.Count); }
public void Remove_InvalidIndex_ShouldThrow() { var list = new ReversedList<int>(); list.Add(1); list.Add(101); list.Remove(2); }
static void Main(string[] args) { var list = new ReversedList <int>(); list.Add(0); list.Add(1); list.Add(2); list.RemoveAt(0); Console.WriteLine(list[0]); }
public void RemoveSingleElementShouldHaveCorrectElements() { ReversedList <int> list = new ReversedList <int>(); list.Add(0); list.Add(1); list.Add(2); list.RemoveAt(0); Assert.AreEqual(1, list[0]); Assert.AreEqual(2, list[1]); }
public void CapacityResize_AddElements_ShouldResizeDouble() { var reversedList = new ReversedList <int>(2); reversedList.Add(5); reversedList.Add(5); reversedList.Add(5); reversedList.Add(5); reversedList.Add(5); Assert.AreEqual(8, reversedList.Capacity); }
public static void Main() { ReversedList <int> reversedList = new ReversedList <int>(); reversedList.Add(100); reversedList.Add(10); reversedList.Add(1); foreach (var number in reversedList) { Console.WriteLine(number); } }
static void Main(string[] args) { ReversedList <int> list = new ReversedList <int>(); list.Add(3); list.Add(5); list.Add(8); foreach (var item in list) { Console.WriteLine(item); } Console.ReadLine(); }
static void Main() { var list = new ReversedList<int>(2); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Remove(2); foreach (var element in list) { Console.WriteLine(element); } }
static void Main(string[] args) { var reversedList = new ReversedList<int>(); reversedList.Add(0); reversedList.Add(1); reversedList.Add(2); reversedList.Add(3); reversedList.Add(4); reversedList.Remove(2); Console.WriteLine(string.Join(" ", reversedList)); }
static void Main(string[] args) { var reversedList = new ReversedList <int>(); reversedList.Add(0); reversedList.Add(1); reversedList.Add(2); reversedList.Add(3); reversedList.Add(4); reversedList.Remove(2); Console.WriteLine(string.Join(" ", reversedList)); }
static void Main() { ReversedList<int> collection = new ReversedList<int>(); collection.Add(1); collection.Add(2); collection.Add(3); collection.Add(4); collection.Add(5); collection.Remove(0); Console.WriteLine(collection.Count); Console.WriteLine(collection.Capacity); Console.WriteLine(string.Join(", ", collection)); }
public void IndexatorGet_FullList_ValidIndex_ShouldReturnElement() { var reversedList = new ReversedList <int>(); reversedList.Add(1); reversedList.Add(2); reversedList.Add(3); reversedList.Add(4); reversedList.Add(5); var expectedElement = reversedList[0]; Assert.AreEqual(5, expectedElement); }
static void Main(string[] args) { ReversedList<int> proba = new ReversedList<int>(); proba.Add(5); proba.Add(6); proba.Add(7); proba.Remove(1); Console.WriteLine(proba[1]); foreach (var item in proba) { Console.Write(item + " "); } }
static void Main() { ReversedList <int> list = new ReversedList <int>(); list.Add(5); list.Add(2); for (int i = 0; i < list.Count; i++) { Console.WriteLine(list[i]); } Console.WriteLine(list.Count); Console.WriteLine(list.Capacity); }
public void RemoveBiggerIndexBetweenEndAndCapacity() { var list = new ReversedList <int>(); list.Add(3); list.Add(45); list.Add(23000000); list.Add(24000000); list.Add(567); list.Remove(6); Assert.AreEqual(5, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(8, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); }
static void Main(string[] args) { ReversedList <int> test = new ReversedList <int>(); test.Add(0); test.Add(1); test.Add(2); test.Add(3); test.Add(4); test.RemoveAt(1); foreach (var item in test) { Console.WriteLine(item); } }
public void RemoveIndexEqualToEnd() { var list = new ReversedList <int>(); list.Add(3); list.Add(45); list.Add(23000000); list.Add(24000000); list.Add(567); list.Remove(5); Assert.AreEqual(5, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(8, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); }
public static void Main() { ReversedList <int> proba = new ReversedList <int>(); proba.Add(1); proba.Add(2); proba.Add(3); proba.Add(4); proba.Add(5); Console.WriteLine("Count = " + proba.Count); Console.WriteLine("Capacity = " + proba.Capacity); foreach (int a in proba) { Console.WriteLine(a); } }
public void IndexatorSet_ValidIndex_ShouldAddElement() { var reversedList = new ReversedList <int>(); reversedList.Add(1); reversedList.Add(2); reversedList.Add(3); reversedList.Add(4); reversedList.Add(5); reversedList[0] = 69; var expectedElement = reversedList[0]; Assert.AreEqual(69, expectedElement); }
static void Main() { ReversedList<int> myRList = new ReversedList<int>(12); for (int i = 0; i < 20; i++) { myRList.Add(i + 1); } myRList[8] = 99; Console.WriteLine(myRList[8]); Console.WriteLine("{0}\n", string.Join("-", myRList)); var removedElement = myRList.Remove(2); Console.WriteLine("removed -> {0}", removedElement); foreach (var num in myRList) { Console.Write("{0}-", num); } removedElement = myRList.Remove(2); Console.WriteLine("\n\nremoved -> {0}", removedElement); foreach (var num in myRList) { Console.Write("{0}-", num); } Console.Read(); }
public void Add_EmptyList_ShouldAdd() { var emptyReversedList = new ReversedList <int>(); emptyReversedList.Add(5); Assert.AreEqual(1, emptyReversedList.Count); }
static void Main() { //Run and test ReversedList<int> rev = new ReversedList<int>(); rev.Add(1); rev.Add(2); rev.Add(3); rev.Add(4); Console.WriteLine(rev); foreach (var i in rev) { Console.WriteLine(i); } }
public static void Main() { ReversedList <int> reversedList = new ReversedList <int>(); reversedList.Add(5); reversedList.Add(6); reversedList.Add(7); reversedList.Add(8); foreach (var item in reversedList) { Console.Write(item + " "); } Console.WriteLine(); Console.WriteLine(reversedList[0]); }
public void Count_AddElement_ShouldIncreaseCount() { var reversedList = new ReversedList <int>(); reversedList.Add(5); Assert.AreEqual(1, reversedList.Count); }
public static void Main() { ReversedList <int> reverse = new ReversedList <int>(); reverse.Add(1); reverse.Add(2); reverse.Add(3); Console.WriteLine(reverse.RemoveAt(0)); Console.WriteLine(); foreach (var i in reverse) { Console.WriteLine(i); } }
public void AddAndGetSingleElement() { ReversedList <int> list = new ReversedList <int>(); list.Add(5); Assert.AreEqual(5, list[0]); }
public void AddSingleElementShouldIncreaseCount() { ReversedList <int> list = new ReversedList <int>(); list.Add(1); Assert.AreEqual(1, list.Count); }
public void Add_EmptyList_ShouldAddElement() { var list = new ReversedList<int>(); list.Add(1); Assert.AreEqual(1, list.Count); }
public void Add_NonEmptyList_ShouldAddAndResizeCapacity() { var list = new ReversedList<int>(4) { 1, 2, 3 }; list.Add(2); Assert.AreEqual(8, list.Capacity); }
public static void Main() { var rl = new ReversedList<int>(); // Add elements rl.Add(1); rl.Add(2); rl.Add(3); rl.Add(4); rl.Add(5); rl.Add(6); rl.Add(7); // Print elements Console.WriteLine("Print elements"); Console.WriteLine(string.Join(" ", rl)); // Remove elements rl.Remove(1); rl.Remove(3); rl.Remove(5); Console.WriteLine("After remove"); Console.WriteLine(string.Join(" ", rl)); }
public void AddElementsWithSingleCapacityDoubling() { var list = new ReversedList<int>(); list.Add(3); list.Add(45); list.Add(23000000); Assert.AreEqual(3, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(4, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); var items = new List<int>(); foreach (var item in list) { items.Add(item); } CollectionAssert.AreEqual(new List<int>() { 23000000, 45, 3 }, items, MESSAGE_NOTCORRECTITEMS); }
public void RemoveSingleElementShouldHaveCorrectCount() { ReversedList <int> list = new ReversedList <int>(); list.Add(0); list.RemoveAt(0); Assert.AreEqual(0, list.Count); }
public void SetSingleElement() { ReversedList <int> list = new ReversedList <int>(); list.Add(0); list[0] = 2; Assert.AreEqual(2, list[0]); }
public static void Main() { ReversedList <int> nums = new ReversedList <int>(); nums.Add(1); nums.Add(2); nums.Add(3); nums.Add(4); nums.Add(5); Console.WriteLine(nums[3]); Console.WriteLine(nums.Count); Console.WriteLine(nums.Capacity); nums.RemoveAt(4); foreach (var num in nums) { Console.WriteLine(num); } }
public void AddElementsWithDoubleCapacityDoubling() { var list = new ReversedList<int>(); list.Add(3); list.Add(45); list.Add(23000000); list.Add(24000000); list.Add(567); Assert.AreEqual(5, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(8, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); var items = new List<int>(); foreach (var item in list) { items.Add(item); } CollectionAssert.AreEqual(items, new List<int>() { 567, 24000000, 23000000, 45, 3 }, "Items are not correct or in the correct order."); }
public void AddMultipleElementShouldIncreaseCount() { ReversedList <int> list = new ReversedList <int>(); for (int i = 0; i < 100; i++) { list.Add(i); } Assert.AreEqual(100, list.Count); }
static void Main(string[] args) { ReversedList <int> reversed = new ReversedList <int>(); reversed.Add(1); reversed.Add(2); reversed.Add(3); reversed.Add(4); reversed.Add(5); Console.WriteLine(reversed.RemoveAt(1)); foreach (var item in reversed) { Console.WriteLine(item); } Console.WriteLine(); Console.WriteLine(reversed[1]); reversed[1] = 5; Console.WriteLine(reversed[1]); }
private static void Main(string[] args) { ReversedList<int> myList = new ReversedList<int>(); Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count); for (int i = 0; i < 4; i++) { myList.Add(i); Console.WriteLine(myList.ToString()); } Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count); myList.Add(4); Console.WriteLine(myList.ToString()); Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count); myList[1] = 666; Console.WriteLine(myList.ToString()); Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count); int remNum = myList.RemoveAt(1); Console.WriteLine("Removed value: {0}", remNum); Console.WriteLine(myList.ToString()); Console.WriteLine("Capacity: {0}; Count: {1}", myList.Capacity, myList.Count); }
static void Main(string[] args) { var reversedList = new ReversedList<int>(); reversedList.Add(1); reversedList.Add(2); reversedList.Add(3); reversedList.Add(4); reversedList.Add(5); System.Console.WriteLine("Elements: " + string.Join(" ", reversedList)); System.Console.WriteLine("Element count: {0}", reversedList.Count); System.Console.WriteLine(new string('-', 20)); var removeIndex = 1; reversedList.Remove(removeIndex); System.Console.WriteLine("Elements: {0} (removed element at index {1})", string.Join(" ", reversedList), removeIndex); System.Console.WriteLine("Element count: {0}", reversedList.Count); System.Console.WriteLine(new string('-', 20)); System.Console.WriteLine("Current capacity: {0}", reversedList.Capacity); System.Console.WriteLine("Current elements count: {0}", reversedList.Count); var elementsToAdd = 20; for (int i = 0; i < elementsToAdd; i++) { reversedList.Add(i + 1); } System.Console.WriteLine("{0} elements added", elementsToAdd); System.Console.WriteLine("Current capacity: {0}", reversedList.Capacity); System.Console.WriteLine("Current elements count: {0}", reversedList.Count); System.Console.WriteLine(new string('-', 20)); var indexCheck = 20; System.Console.WriteLine("Element at index {0}: {1}", indexCheck, reversedList[indexCheck]); }
static void Main() { var list = new ReversedList<int>(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.Add(0); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); Console.WriteLine("Count = {0}", list.Count); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); Console.WriteLine(list[3]); Console.WriteLine("--------------------"); var element = list.Remove(3); Console.WriteLine("Element to remove: " + element); Console.WriteLine("Count = {0}", list.Count); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); }
public void AddElementsWithSingleCapacityDoubling() { var list = new ReversedList <int>(); list.Add(3); list.Add(45); list.Add(23000000); Assert.AreEqual(3, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(4, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); var items = new List <int>(); foreach (var item in list) { items.Add(item); } CollectionAssert.AreEqual(new List <int>() { 23000000, 45, 3 }, items, MESSAGE_NOTCORRECTITEMS); }
static void Main(string[] args) { var rl = new ReversedList<int>(); rl.Add(4); rl.Add(14); rl.Add(8); rl.Add(3); rl.Add(18); rl.Add(23); rl.Add(67); rl.Add(91); rl.Remove(2); rl.Remove(2); Console.WriteLine(string.Join(" ", rl)); }
public void AddMultiplePerformanceTest() { ReversedList <int> list = new ReversedList <int>(); for (int i = 0; i < 100000; i++) { list.Add(i); } for (int i = 0; i < 100000; i++) { Assert.AreEqual(i, list[i]); } }
public void AddAndGetMultipleElements() { ReversedList <int> list = new ReversedList <int>(); for (int i = 0; i < 100; i++) { list.Add(i); } for (int i = 0; i < 100; i++) { Assert.AreEqual(i, list[i]); } }
static void Main() { var reversedList = new ReversedList<int>(); reversedList.Add(0); reversedList.Add(1); Console.WriteLine("Number of elements: {0}", reversedList.Count); reversedList.Add(2); reversedList.Add(3); Console.WriteLine("Capacity before resizing: {0}", reversedList.Capacity); reversedList.Add(4); Console.WriteLine("Capacity after adding and resizing: {0}", reversedList.Capacity); Console.WriteLine("Iterating:"); foreach (var element in reversedList) { Console.WriteLine(element); } reversedList.Remove(3); Console.WriteLine("Count after removing: {0}", reversedList.Count); Console.WriteLine("Iterating:"); foreach (var element in reversedList) { Console.WriteLine(element); } }
public void AddElementToEmptyList() { var list = new ReversedList<int>(); list.Add(2); Assert.AreEqual(1, list.Count, MESSAGE_NOTMATCHINGCOUNT); Assert.AreEqual(1, list.Capacity, MESSAGE_NOTMATCHINGCAPACITY); var items = new List<int>(); foreach (var item in list) { items.Add(item); } CollectionAssert.AreEqual(new List<int>() { 2 }, items, MESSAGE_NOTCORRECTITEMS); }
public void GetIndex_ValidIndex_ShouldReturnValueReversed() { const int N = 1000; var list = new ReversedList<int>(); for (int i = 0; i < N; i++) { list.Add(i); } for (int i = 0; i < N; i++) { var actualValue = list[i]; Assert.AreEqual(N - i - 1, actualValue); } }
static void Main(string[] args) { ReversedList<int> ints = new ReversedList<int>(); ints.Add(5); ints.Add(8); ints.Add(10); ints.Add(11); ints.Add(12); ints.Add(13); ints.Remove(2); ints.Remove(1); Console.WriteLine(ints[2]); }
public static void Main() { ReversedList<int> testList = new ReversedList<int>(); //List<int> testList = new List<int>(); for (int i = 0; i < 20; i++) { testList.Add(i); } Console.WriteLine(testList); testList.Remove(3); Console.WriteLine(testList); Console.WriteLine(testList.Count); Console.ReadLine(); }
public static void Main(string[] arg) { ReversedList<int> revList = new ReversedList<int>() {6, 5, 4, 3, 2, 1}; revList.Add(0); Console.WriteLine("Element with index(0) is " + revList[0]); Console.WriteLine("Element with index(5) is " + revList[5]); Console.WriteLine(); Console.WriteLine("Foreach for the Reversed List:"); Console.WriteLine(); int index = 0; foreach(var item in revList) { Console.WriteLine(index + "th el : " + item + ";"); index++; } Console.WriteLine(); Console.WriteLine("List Count: {0},\nList Capacity: {1}", revList.Count, revList.Capacity); Console.WriteLine(); Console.WriteLine("Removing element with value 6 =>"); revList.Remove(6); Console.WriteLine("List Count: {0},\nList Capacity: {1}", revList.Count, revList.Capacity); }
static void Main(string[] args) { ReversedList<int> test = new ReversedList<int>(); test.Add(4); test.Add(5); test.Add(1); test.Add(21); test.Remove(3); test.Add(10); test.Add(15); test[0] = 14; foreach (var num in test) { Console.WriteLine(num); } }
public static void Main() { ReversedList<int> numbers = new ReversedList<int>(2); Console.WriteLine("Adding elements in the list."); for (int i = 0; i < 10; i++) { Console.WriteLine("Count = " + numbers.Count); Console.WriteLine("Capacity = " + numbers.Capacity); numbers.Add(i); } Console.WriteLine("Removing the first indexes."); while (numbers.Count > 0) { foreach (var number in numbers) { Console.Write(number + " "); } Console.WriteLine(" -> Count = " + numbers.Count); numbers.Remove(0); } }
public void Remove_ValidIndex_ShouldRemoveCorrectly() { var list = new ReversedList<int>(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); list.Remove(2); Assert.AreEqual(4, list.Count); CollectionAssert.AreEqual(new List<int> { 5, 4, 2, 1 }, list.ToList()); }
public static void Main() { var reversedList = new ReversedList<int>(); reversedList.Add(5); reversedList.Add(10); reversedList.Add(15); reversedList.Add(20); reversedList.Add(25); Console.WriteLine(reversedList); foreach (var num in reversedList) { Console.Write(num + ", "); } Console.WriteLine(); Console.WriteLine(reversedList[4]); Console.WriteLine(reversedList.Capacity()); Console.WriteLine(reversedList.Count()); reversedList.Remove(4); Console.WriteLine(reversedList); reversedList.Add(30); reversedList.Add(31); reversedList.Add(32); reversedList.Add(33); reversedList.Add(34); reversedList.Add(35); reversedList.Add(36); reversedList.Add(37); reversedList.Add(38); reversedList.Add(39); reversedList.Add(40); reversedList.Add(30); reversedList.Add(31); reversedList.Add(32); Console.WriteLine(reversedList); }