Ejemplo n.º 1
0
        /**
         * Compare the specified object with this list for equality.  This
         * implementation uses exactly the code that is used to define the
         * list equals function in the documentation for the
         * <code>List.equals</code> method.
         *
         * @param o Object to be compared to this list
         */
        public override bool Equals(Object o)
        {
            // Simple tests that require no synchronization
            if (o == this)
            {
                return(true);
            }
            else if (!(o is java.util.List <Object>))
            {
                return(false);
            }
            java.util.List <Object> lo = (java.util.List <Object>)o;

            // Compare the sets of elements for equality
            if (fast)
            {
                java.util.ListIterator <Object> li1 = list.listIterator();
                java.util.ListIterator <Object> li2 = lo.listIterator();
                while (li1.hasNext() && li2.hasNext())
                {
                    Object o1 = li1.next();
                    Object o2 = li2.next();
                    if (!(o1 == null ? o2 == null : o1.equals(o2)))
                    {
                        return(false);
                    }
                }
                return(!(li1.hasNext() || li2.hasNext()));
            }
            else
            {
                lock (list)
                {
                    java.util.ListIterator <Object> li1 = list.listIterator();
                    java.util.ListIterator <Object> li2 = lo.listIterator();
                    while (li1.hasNext() && li2.hasNext())
                    {
                        Object o1 = li1.next();
                        Object o2 = li2.next();
                        if (!(o1 == null ? o2 == null : o1.equals(o2)))
                        {
                            return(false);
                        }
                    }
                    return(!(li1.hasNext() || li2.hasNext()));
                }
            }
        }
 //-----------------------------------------------------------------------
 public override bool Equals(Object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj is java.util.List <Object> == false)
     {
         return(false);
     }
     java.util.List <Object> other = (java.util.List <Object>)obj;
     if (other.size() != size())
     {
         return(false);
     }
     java.util.ListIterator <Object> it1 = listIterator();
     java.util.ListIterator <Object> it2 = other.listIterator();
     while (it1.hasNext() && it2.hasNext())
     {
         Object o1 = it1.next();
         Object o2 = it2.next();
         if (!(o1 == null ? o2 == null : o1.equals(o2)))
         {
             return(false);
         }
     }
     return(!(it1.hasNext() || it2.hasNext()));
 }
Ejemplo n.º 3
0
        public static void sort(java.util.List <T> list)
        {
            Object[] a = list.toArray();
            Array.Sort <Object>(a);
            ListIterator <T> i = list.listIterator();

            for (int j = 0; j < a.Length; j++)
            {
                i.next();
                i.set((T)a[j]);
            }
        }
Ejemplo n.º 4
0
        private int runLimit(java.util.List <IAC_Range> ranges)
        {
            int result = end;

            java.util.ListIterator <IAC_Range> it = ranges.listIterator(ranges.size());
            while (it.hasPrevious())
            {
                IAC_Range range = it.previous();
                if (range.end <= begin)
                {
                    break;
                }
                if (offset >= range.start && offset < range.end)
                {
                    return(inRange(range) ? range.end : result);
                }
                else if (offset >= range.end)
                {
                    break;
                }
                result = range.start;
            }
            return(result);
        }
 /**
  * Constructor that wraps a list.
  *
  * @param list  the list to create a reversed iterator for
  * @throws NullPointerException if the list is null
  */
 public ReverseListIterator(java.util.List<Object> list)
     : base()
 {
     this.list = list;
     iterator = list.listIterator(list.size());
 }
Ejemplo n.º 6
0
 /**
  * Resets the iterator back to the start of the list.
  */
 public void reset()
 {
     iterator = list.listIterator();
 }
 /**
  * Constructor that wraps a list.
  *
  * @param list  the list to create a reversed iterator for
  * @throws NullPointerException if the list is null
  */
 public ReverseListIterator(java.util.List <Object> list)
     : base()
 {
     this.list = list;
     iterator  = list.listIterator(list.size());
 }
 /**
  * Resets the iterator back to the start (which is the
  * end of the list as this is a reversed iterator)
  */
 public void reset()
 {
     iterator = list.listIterator(list.size());
 }