Пример #1
0
        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;
            }
        }
Пример #2
0
        void AddLast(T item)
        {
            UMidiLinkedListNode <T> node = new UMidiLinkedListNode <T>(item);

            tail.Next = node;
            tail      = node;
            size++;
        }
Пример #3
0
        public bool Remove(T item)
        {
            UMidiLinkedListNode <T> node = head;

            while (!node.Equals(tail))
            {
                if (node.Value.Equals(item))
                {
                }
            }
            return(false);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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
            {
            }
        }
Пример #7
0
 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;
     }
 }
Пример #8
0
        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;
                }
            }
        }
Пример #9
0
 public void Clear()
 {
     head = null;
     size = 0;
 }
Пример #10
0
 public UMidiLinkedListNode(T value)
 {
     Value = value;
     Next  = null;
 }
Пример #11
0
 public UMidiLinkedList()
 {
     head = null;
     size = 0;
 }