|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sadun.util.ListMapIterator
An iterator to go thru a Map of Lists, using a specific key list for deciding how to access the sublists.
Given a java.util.Map
binding each key Ki to a
java.util.List
Li, this Iterator allows to
browse the set { L1, L2, ... , Ln} , by
specifying the order in which the lists should be picked.
Such order is specified by providing a key list at construction time; if no list
is given, the order of iteration is the arbitrary order in which the keys are
stored in the java.util.Map
, as given by the iterator
provided by the iterator()
method of the
java.util.Map
's key set.
For example, if a Map is built by
list1.add("Elem 1.1"); list1.add("Elem 1.2"); list2.add("Elem 2.1"); list3.add("Elem 3.1"); list3.add("Elem 3.2"); list3.add("Elem 3.3"); map.add("1", list1); map.add("2", list2); map.add("3", list3);a
ListMapIterator
built by
ListMapIterator i = new ListMapIterator(map, new Arrays.asList(new String[] { "1", "2", "3")));will produce the iteration
Elem1.1, Elem1.2, Elem2.1, Elem3.1, Elem3.2, Elem3.3
.
Constructor Summary | |
ListMapIterator(java.util.Map map)
Create a ListMapIterator which uses default ordering (as provided by the set of keys in the map) |
|
ListMapIterator(java.util.Map map,
java.util.List keyorder)
Create a ListMapIterator which uses the key ordering defined in the given list |
|
ListMapIterator(java.util.Map map,
java.util.List keyorder,
boolean failOnUnknownKeys,
boolean requireUniqueKeys)
Create a ListMapIterator which uses the key ordering defined in the given list |
Method Summary | |
java.lang.Object |
getCurrentKey()
|
boolean |
hasNext()
|
static void |
main(java.lang.String[] args)
|
java.lang.Object |
next()
|
void |
remove()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ListMapIterator(java.util.Map map)
public ListMapIterator(java.util.Map map, java.util.List keyorder)
public ListMapIterator(java.util.Map map, java.util.List keyorder, boolean failOnUnknownKeys, boolean requireUniqueKeys)
keyorder
- the order with which the map Lists must be iterated.
* @param failOnUnknownKeys if true, the iterator will fail with
an IllegalArgumentException if one key in the
ordering list is not defined in the map.
Else, it will ignore the unknown key.
* @param requireUniqueKeys if true, the iterator will fail with
an IllegalArgumentException if the keys in the
ordering list are not unique.Method Detail |
public boolean hasNext()
hasNext
in interface java.util.Iterator
Iterator.hasNext()
public java.lang.Object next()
next
in interface java.util.Iterator
Iterator.next()
public void remove()
remove
in interface java.util.Iterator
Iterator.remove()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public java.lang.Object getCurrentKey()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |