1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.collections15;
17
18 /***
19 * Defines a map that maintains order and allows both forward and backward
20 * iteration through that order.
21 *
22 * @author Stephen Colebourne
23 * @version $Revision: 1.2 $ $Date: 2004/10/17 01:02:42 $
24 * @since Commons Collections 3.0
25 */
26 public interface OrderedMap <K, V> extends IterableMap<K, V>
27 {
28
29 /***
30 * Obtains an <code>OrderedMapIterator</code> over the map.
31 * <p/>
32 * A ordered map iterator is an efficient way of iterating over maps in both
33 * directions.
34 * <pre>
35 * BidiMap map = new TreeBidiMap();
36 * MapIterator it = map.mapIterator();
37 * while (it.hasNext()) {
38 * Object key = it.next();
39 * Object value = it.getValue();
40 * it.setValue("newValue");
41 * Object previousKey = it.previous();
42 * }
43 * </pre>
44 *
45 * @return a map iterator
46 */
47 OrderedMapIterator<K, V> orderedMapIterator();
48
49 /***
50 * Gets the first key currently in this map.
51 *
52 * @return the first key currently in this map
53 *
54 * @throws java.util.NoSuchElementException
55 * if this map is empty
56 */
57 K firstKey();
58
59 /***
60 * Gets the last key currently in this map.
61 *
62 * @return the last key currently in this map
63 *
64 * @throws java.util.NoSuchElementException
65 * if this map is empty
66 */
67 K lastKey();
68
69 /***
70 * Gets the next key after the one specified.
71 *
72 * @param key the key to search for next from
73 *
74 * @return the next key, null if no match or at end
75 */
76 K nextKey(Object key);
77
78 /***
79 * Gets the previous key before the one specified.
80 *
81 * @param key the key to search for previous from
82 *
83 * @return the previous key, null if no match or at start
84 */
85 K previousKey(Object key);
86 }