/**
         * Gets the next element.
         * The next element is the previous in the list.
         *
         * @return the next element in the iterator
         */
        public Object next()
        {
            Object obj = iterator.previous();

            validForUpdate = true;
            return(obj);
        }
        private bool setPreviousObject()
        {
            // if nextObjectSet,
            // then we've walked back one step in the
            // underlying list (due to a hasNext() call)
            // so skip ahead one matching object
            if (nextObjectSet)
            {
                clearNextObject();
                if (!setPreviousObject())
                {
                    return(false);
                }
                else
                {
                    clearPreviousObject();
                }
            }

            while (iterator.hasPrevious())
            {
                Object obj = iterator.previous();
                if (predicate.evaluate(obj))
                {
                    previousObject    = obj;
                    previousObjectSet = true;
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
 public E previous()
 {
     if (iterator.previousIndex() >= start)
     {
         return(iterator.previous());
     }
     throw new java.util.NoSuchElementException();
 }
Пример #4
0
 /**
  * Returns the previous object in the list.
  * <p>
  * If at the beginning of the list, return the last element. Note
  * that in this case, traversal to find that element takes linear time.
  *
  * @return the object before the last element returned
  * @throws NoSuchElementException if there are no elements in the list
  */
 public Object previous()
 {
     if (list.isEmpty())
     {
         throw new java.util.NoSuchElementException(
                   "There are no elements for this iterator to loop on");
     }
     if (iterator.hasPrevious() == false)
     {
         Object result = null;
         while (iterator.hasNext())
         {
             result = iterator.next();
         }
         iterator.previous();
         return(result);
     }
     else
     {
         return(iterator.previous());
     }
 }
Пример #5
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);
        }
Пример #6
0
        /**
         * Applies a given attribute to the given range of this string.
         *
         * @param attribute
         *            the attribute that will be applied to this string.
         * @param value
         *            the value of the attribute that will be applied to this
         *            string.
         * @param start
         *            the start of the range where the attribute will be applied.
         * @param end
         *            the end of the range where the attribute will be applied.
         * @throws IllegalArgumentException
         *             if {@code start < 0}, {@code end} is greater than the length
         *             of this string, or if {@code start >= end}.
         * @throws NullPointerException
         *             if {@code attribute} is {@code null}.
         */
        public void addAttribute(AttributedCharacterIteratorNS.Attribute attribute,
                                 System.Object value, int start, int end)
        {
            if (null == attribute)
            {
                throw new java.lang.NullPointerException();
            }
            if (start < 0 || end > text.Length || start >= end)
            {
                throw new java.lang.IllegalArgumentException();
            }

            if (value == null)
            {
                return;
            }

            java.util.List <IAC_Range> ranges = attributeMap.get(attribute);
            if (ranges == null)
            {
                ranges = new java.util.ArrayList <IAC_Range>(1);
                ranges.add(new IAC_Range(start, end, value));
                attributeMap.put(attribute, ranges);
                return;
            }
            java.util.ListIterator <IAC_Range> it = ranges.listIterator();
            while (it.hasNext())
            {
                IAC_Range range = it.next();
                if (end <= range.start)
                {
                    it.previous();
                    break;
                }
                else if (start < range.end ||
                         (start == range.end && value.Equals(range.value)))
                {
                    IAC_Range r1 = null, r3;
                    it.remove();
                    r1 = new IAC_Range(range.start, start, range.value);
                    r3 = new IAC_Range(end, range.end, range.value);

                    while (end > range.end && it.hasNext())
                    {
                        range = it.next();
                        if (end <= range.end)
                        {
                            if (end > range.start ||
                                (end == range.start && value.Equals(range.value)))
                            {
                                it.remove();
                                r3 = new IAC_Range(end, range.end, range.value);
                                break;
                            }
                        }
                        else
                        {
                            it.remove();
                        }
                    }

                    if (value.Equals(r1.value))
                    {
                        if (value.Equals(r3.value))
                        {
                            it.add(new IAC_Range(r1.start <start?r1.start : start,
                                                           r3.end> end ? r3.end : end, r1.value));
                        }
                        else
                        {
                            it.add(new IAC_Range(r1.start < start ? r1.start : start,
                                                 end, r1.value));
                            if (r3.start < r3.end)
                            {
                                it.add(r3);
                            }
                        }
                    }
                    else
                    {
                        if (value.Equals(r3.value))
                        {
                            if (r1.start < r1.end)
                            {
                                it.add(r1);
                            }
                            it.add(new IAC_Range(start, r3.end > end ? r3.end : end,
                                                 r3.value));
                        }
                        else
                        {
                            if (r1.start < r1.end)
                            {
                                it.add(r1);
                            }
                            it.add(new IAC_Range(start, end, value));
                            if (r3.start < r3.end)
                            {
                                it.add(r3);
                            }
                        }
                    }
                    return;
                }
            }
            it.add(new IAC_Range(start, end, value));
        }
 public virtual Object previous()
 {
     last = (java.util.MapNS.Entry <Object, Object>)iterator.previous();
     return(last.getKey());
 }
Пример #8
0
 public Object previous()
 {
     return(iterator.previous());
 }
Пример #9
0
 public virtual Object previous()
 {
     return(iterator.previous());
 }
Пример #10
0
 public Object previous()
 {
     lastReturnedIndex = iter.previousIndex();
     return(iter.previous());
 }
 public virtual Object previous()
 {
     last     = iterator.previous();
     readable = true;
     return(last);
 }