Esempio n. 1
0
 public void add(N item)
 {
     if (count == 0)
     {
         first.Member = last.Member = item;
         first.Next   = last.Next = null;
     }
     else
     {
         last.Next = new turn <N>(item);
         last      = last.Next;
     }
     count++;
 }
Esempio n. 2
0
        public int IndexOf(N item)
        {
            turn <N> temp = first;

            for (int i = 0; i < count; i++)
            {
                if (temp.Member.Equals(item))
                {
                    return(i);
                }
                temp = temp.Next;
            }
            return(-1);
        }
Esempio n. 3
0
 public N this[int index]
 {
     get{
         if (index < count)
         {
             turn <N> temp_member = first;
             for (int i = 0; i < index; i++)
             {
                 temp_member = temp_member.Next;
             }
             return(temp_member.Member);
         }
         else
         {
             throw new ArgumentException();
         }
     }
 }
Esempio n. 4
0
 public void remove(N item)
 {
     if (count > 1)
     {
         turn <N> temp = first;
         while (temp.Next != null)
         {
             if (temp.Next.Member.Equals(item))
             {
                 temp.Next = temp.Next.Next;
                 count--;
             }
         }
     }
     else
     {
         if ((first.Member.Equals(item)) && (count == 1))
         {
             first = last = null;
             count = 0;
         }
     }
 }
Esempio n. 5
0
 public collection()
 {
     first = null;
     last  = null;
     count = 0;
 }
Esempio n. 6
0
 public turn(N _member)
 {
     member = _member;
     next   = null;
 }