Home | History | Annotate | Download | only in util
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 //  2016 and later: Unicode, Inc. and others.
      3 // License & terms of use: http://www.unicode.org/copyright.html#License
      4 /*
      5 ******************************************************************************
      6 * Copyright (C) 1996-2016, International Business Machines Corporation and   *
      7 * others. All Rights Reserved.                                               *
      8 ******************************************************************************
      9 */
     10 
     11 package android.icu.util;
     12 
     13 /**
     14  * <p>Interface for enabling iteration over sets of &lt;int, Object&gt;, where
     15  * int is the sorted integer index in ascending order, and Object its
     16  * associated value.
     17  * <p>The ValueIterator allows iterations over integer indexes in the range
     18  * of Integer.MIN_VALUE to Integer.MAX_VALUE inclusive. Implementations of
     19  * ValueIterator should specify their own maximum subrange within the above
     20  * range that is meaningful to its applications.
     21  * <p>Most implementations will be created by factory methods, such as the
     22  * character name iterator in UCharacter.getNameIterator. See example below.
     23  *
     24  * Example of use:<br>
     25  * <pre>
     26  * ValueIterator iterator = UCharacter.getNameIterator();
     27  * ValueIterator.Element result = new ValueIterator.Element();
     28  * iterator.setRange(UCharacter.MIN_VALUE, UCharacter.MAX_VALUE);
     29  * while (iterator.next(result)) {
     30  *     System.out.println("Codepoint \\u" +
     31  *                        Integer.toHexString(result.integer) +
     32  *                        " has the character name " + (String)result.value);
     33  * }
     34  * </pre>
     35  * @author synwee
     36  */
     37 public interface ValueIterator
     38 {
     39     // public inner class ---------------------------------------------
     40 
     41     /**
     42     * <p>The return result container of each iteration. Stores the next
     43     * integer index and its associated value Object.
     44     */
     45     public static final class Element
     46     {
     47         // public data members ----------------------------------------
     48 
     49         /**
     50         * Integer index of the current iteration
     51         */
     52         public int integer;
     53         /**
     54         * Gets the Object value associated with the integer index.
     55         */
     56         public Object value;
     57 
     58         // public constructor ------------------------------------------
     59 
     60         /**
     61          * Empty default constructor to make javadoc happy
     62          */
     63         public Element()
     64         {
     65         }
     66     }
     67 
     68     // public methods -------------------------------------------------
     69 
     70     /**
     71     * <p>Returns the next result for this iteration and returns
     72     * true if we are not at the end of the iteration, false otherwise.
     73     * <p>If this returns a false, the contents of elements will not
     74     * be updated.
     75     * @param element for storing the result index and value
     76     * @return true if we are not at the end of the iteration, false otherwise.
     77     * @see Element
     78     */
     79     public boolean next(Element element);
     80 
     81     /**
     82     * <p>Resets the iterator to start iterating from the integer index
     83     * Integer.MIN_VALUE or X if a setRange(X, Y) has been called previously.
     84     */
     85     public void reset();
     86 
     87     /**
     88      * <p>Restricts the range of integers to iterate and resets the iteration
     89      * to begin at the index argument start.
     90      * <p>If setRange(start, end) is not performed before next(element) is
     91      * called, the iteration will start from the integer index
     92      * Integer.MIN_VALUE and end at Integer.MAX_VALUE.
     93      * <p>
     94      * If this range is set outside the meaningful range specified by the
     95      * implementation, next(element) will always return false.
     96      *
     97      * @param start first integer in the range to iterate
     98      * @param limit one more than the last integer in the range
     99      * @exception IllegalArgumentException thrown when attempting to set an
    100      *            illegal range. E.g limit &lt;= start
    101      */
    102     public void setRange(int start, int limit);
    103 }
    104