public void Add(object data) { CustomListNode toAdd = new CustomListNode(); toAdd.data = data; toAdd.next = head; head = toAdd; length++; }
public void Set(int index, object data) { CustomListNode node = head; for (int i = 0; i < index; i++) { node = node.next; } node.data = data; }
public object Get(int index) { CustomListNode node = head; for (int i = 0; i < index; i++) { node = node.next; } return(node.data); }
public bool Contains(object element) { bool found = false; CustomListNode node = head; for (int i = 0; i < length; i++) { found = found || element.Equals(node.data); node = node.next; } return(found); }
public dynamic ToArray <T>() { T[] toReturn = new T[this.length]; CustomListNode node = head; for (int i = 0; i < length; i++) { toReturn[i] = (T)node.data; node = node.next; } return(toReturn); }
public CustomList(int maxCapacity = 0) { array = new object[maxCapacity]; length = 0; head = new CustomListNode(); }