public void Insert(int index, T item) { int i = 0; UMidiLinkedListNode <T> ptr = head; while (i < index) { ptr = ptr.Next; i++; } UMidiLinkedListNode <T> node = new UMidiLinkedListNode <T>(item); if (ptr == tail) { ptr.Next = node; node.Next = null; tail = node; } else { ptr.Next = node; node.Next = ptr.Next.Next; } }
void AddLast(T item) { UMidiLinkedListNode <T> node = new UMidiLinkedListNode <T>(item); tail.Next = node; tail = node; size++; }
public bool Remove(T item) { UMidiLinkedListNode <T> node = head; while (!node.Equals(tail)) { if (node.Value.Equals(item)) { } } return(false); }
public int IndexOf(T item) { UMidiLinkedListNode <T> node = head; for (int i = 0; i < Count; i++) { node = node.Next; if (item.Equals(node)) { return(i); } } return(-1); }
public int Add(T value) { UMidiLinkedListNode <T> node = new UMidiLinkedListNode <T>(value); if (head == null) { head = node; tail = node; } else { tail.Next = node; tail = node; } size++; return(size - 1); }
public void RemoveAt(int index) { int i = 0; UMidiLinkedListNode <T> ptr = head; while (i < index - 1) { ptr = ptr.Next; i++; } if (ptr.Next == tail) { } else { } }
public T this[int index] { get { UMidiLinkedListNode <T> ptr = head; for (int i = 0; i < index; i++) { ptr = ptr.Next; } return(ptr.Value); } set { UMidiLinkedListNode <T> ptr = head; for (int i = 0; i < index; i++) { ptr = ptr.Next; } ptr.Value = value; } }
public void CopyTo(T[] array, int arrayIndex) { int start = 0; UMidiLinkedListNode <T> ptr = head; while (start < arrayIndex) { ptr = ptr.Next; } for (int i = 0; i < array.Length; i++) { if (ptr == tail) { this.AddLast(array[i]); } else { ptr.Value = array[i]; ptr = ptr.Next; } } }
public void Clear() { head = null; size = 0; }
public UMidiLinkedListNode(T value) { Value = value; Next = null; }
public UMidiLinkedList() { head = null; size = 0; }