Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.collections
Interface OrderedMap

All Superinterfaces:
  IterableMap, Map

All Known Subinterfaces:
  OrderedBidiMap, SortedBidiMap

All Known Implementing Classes:
  AbstractLinkedMap, AbstractOrderedBidiMapDecorator, AbstractOrderedMapDecorator, AbstractSortedBidiMapDecorator, DualTreeBidiMap, ListOrderedMap, SingletonMap, TreeBidiMap

public interface OrderedMap
extends IterableMap

Defines a map that maintains order and allows both forward and backward iteration through that order.

Since:
  Commons Collections 3.0
Version:
  $Revision: 1.6 $ $Date: 2004/02/18 01:15:42 $
Author:
  Stephen Colebourne

Method Summary
`Object` | `firstKey()` Gets the first key currently in this map.
`Object` | `lastKey()` Gets the last key currently in this map.
`Object` | `nextKey(Object key)` Gets the next key after the one specified.
`OrderedMapIterator` | `orderedMapIterator()` Obtains an `OrderedMapIterator` over the map.
`Object` | `previousKey(Object key)` Gets the previous key before the one specified.

Methods inherited from interface org.apache.commons.collections.IterableMap
`mapIterator`

Methods inherited from interface java.util.Map
`clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values`

Method Detail

### orderedMapIterator

    public OrderedMapIterator orderedMapIterator()

  Obtains an `OrderedMapIterator` over the map.

  A ordered map iterator is an efficient way of iterating over maps in both directions.

       BidiMap map = new TreeBidiMap();
       MapIterator it = map.mapIterator();
       while (it.hasNext()) {
         Object key = it.next();
         Object value = it.getValue();
         it.setValue("newValue");
         Object previousKey = it.previous();
       }

  Returns:
    a map iterator

### firstKey

    public Object firstKey()

  Gets the first key currently in this map.

  Returns:
    the first key currently in this map
  Throws:
    `NoSuchElementException` - if this map is empty

### lastKey

    public Object lastKey()

  Gets the last key currently in this map.

  Returns:
    the last key currently in this map
  Throws:
    `NoSuchElementException` - if this map is empty

### nextKey

    public Object nextKey(Object key)

  Gets the next key after the one specified.

  Parameters:
    `key` - the key to search for next from
  Returns:
    the next key, null if no match or at end

### previousKey

    public Object previousKey(Object key)

  Gets the previous key before the one specified.

  Parameters:
    `key` - the key to search for previous from
  Returns:
    the previous key, null if no match or at start

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2004 Apache Software Foundation. All Rights Reserved.