Example #1
0
        public void Add(object data)
        {
            CustomListNode toAdd = new CustomListNode();

            toAdd.data = data;
            toAdd.next = head;
            head       = toAdd;
            length++;
        }
Example #2
0
        public void Set(int index, object data)
        {
            CustomListNode node = head;

            for (int i = 0; i < index; i++)
            {
                node = node.next;
            }
            node.data = data;
        }
Example #3
0
        public object Get(int index)
        {
            CustomListNode node = head;

            for (int i = 0; i < index; i++)
            {
                node = node.next;
            }
            return(node.data);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
 public CustomList(int maxCapacity = 0)
 {
     array  = new object[maxCapacity];
     length = 0;
     head   = new CustomListNode();
 }