2 ******************************************************************************
\r
3 * Copyright (C) 1996-2010, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 ******************************************************************************
\r
8 package com.ibm.icu.util;
\r
11 * <p>Interface for enabling iteration over sets of <int index, int value>,
\r
12 * where index is the sorted integer index in ascending order and value, its
\r
13 * associated integer value.</p>
\r
14 * <p>The result for each iteration is the consecutive range of
\r
15 * <int index, int value> with the same value. Result is represented by
\r
16 * <start, limit, value> where</p>
\r
18 * <li> start is the starting integer of the result range
\r
19 * <li> limit is 1 after the maximum integer that follows start, such that
\r
20 * all integers between start and (limit - 1), inclusive, have the same
\r
21 * associated integer value.
\r
22 * <li> value is the integer value that all integers from start to (limit - 1)
\r
26 * Hence value(start) = value(start + 1) = .... = value(start + n) = .... =
\r
27 * value(limit - 1). However value(start -1) != value(start) and
\r
28 * value(limit) != value(start).
\r
30 * <p>Most implementations will be created by factory methods, such as the
\r
31 * character type iterator in UCharacter.getTypeIterator. See example below.
\r
33 * Example of use:<br>
\r
35 * RangeValueIterator iterator = UCharacter.getTypeIterator();
\r
36 * RangeValueIterator.Element result = new RangeValueIterator.Element();
\r
37 * while (iterator.next(result)) {
\r
38 * System.out.println("Codepoint \\u" +
\r
39 * Integer.toHexString(result.start) +
\r
40 * " to codepoint \\u" +
\r
41 * Integer.toHexString(result.limit - 1) +
\r
42 * " has the character type " + result.value);
\r
48 public interface RangeValueIterator
\r
50 // public inner class ---------------------------------------------
\r
53 * Return result wrapper for com.ibm.icu.util.RangeValueIterator.
\r
54 * Stores the start and limit of the continous result range and the
\r
55 * common value all integers between [start, limit - 1] has.
\r
58 public class Element
\r
60 // public data member ---------------------------------------------
\r
63 * Starting integer of the continuous result range that has the same
\r
69 * (End + 1) integer of continuous result range that has the same
\r
75 * Gets the common value of the continous result range
\r
80 // public constructor --------------------------------------------
\r
83 * Empty default constructor to make javadoc happy
\r
91 // public methods -------------------------------------------------
\r
94 * <p>Returns the next maximal result range with a common value and returns
\r
95 * true if we are not at the end of the iteration, false otherwise.</p>
\r
96 * <p>If this returns a false, the contents of elements will not
\r
98 * @param element for storing the result range and value
\r
99 * @return true if we are not at the end of the iteration, false otherwise.
\r
103 public boolean next(Element element);
\r
106 * Resets the iterator to the beginning of the iteration.
\r
109 public void reset();
\r