Beispiel #1
0
 public void AddElement(MyItem item)
 {
     head = new MyListElement
     {
         Item = item,
         Next = head
     };
 }
Beispiel #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            MyListElement el = head;

            while (el != null)
            {
                sb.Append(" { " + el.Item.ToString() + " } ");
                el = el.Next;
            }
            return(sb.ToString());
        }
Beispiel #3
0
        public int Count()
        {
            int           count = 0;
            MyListElement t     = head;

            while (t != null)
            {
                count++;
                t = t.Next;
            }
            return(count);
        }
Beispiel #4
0
        public override MyItem GetElement()
        {
            MyListElement el = head;

            while (el.Next.Next != null)
            {
                el = el.Next;
            }
            MyItem i = el.Next.Item;;

            el.Next = null;
            return(i);
        }