Interface OrderedMap<Key extends Comparable<Key>,Value>

Type Parameters:
Key - the key type
Value - the value type
All Superinterfaces:
Container<MapItem<Key,Value>>, Iterable<MapItem<Key,Value>>, Map<Key,Value>
All Known Implementing Classes:
AVLTree, AVLTree, BinarySearchTree, BinarySearchTree, SortedArrayMap, SortedArrayMap

public interface OrderedMap<Key extends Comparable<Key>,Value> extends Map<Key,Value>
An ordered map.

A map whose n items have comparable keys, that is, have keys that can be ordered from least to greatest.

  • Method Details

    • previous

      MapItem<Key,Value> previous(Key key)
      Get the item that would be the predecessor of one with the given key.

      The map may or may not contain an item with the given key.

      Parameters:
      key - a key
      Returns:
      the previous item (by key), or null if there is none
    • next

      MapItem<Key,Value> next(Key key)
      Get the item that would be the successor of one with the given key.

      The map may or may not contain an item with the given key.

      Parameters:
      key - a key
      Returns:
      the next item (by key), or null if there is none
    • min

      MapItem<Key,Value> min()
      Get the item with the least key.
      Returns:
      the minimum item (by key), or null if there is none
    • max

      MapItem<Key,Value> max()
      Get the item with the greatest key.
      Returns:
      the maximum item (by key), or null if there is none
    • items

      Get a forward iterable that yields each item once.

      The items are iterated over in least-to-greatest order (by key).

      Specified by:
      items in interface Container<Key extends Comparable<Key>>
      Returns:
      an iterable over the items
    • reversed

      Iterable<MapItem<Key,Value>> reversed()
      Get a reverse iterable that yields each item once.

      The items are iterated over in greatest-to-least order (by key).

      Returns:
      an iterable over the items
    • keys

      default Iterable<Key> keys()
      Get a forward iterable that yields each key once.

      The items are iterated over in least-to-greatest order (by key).

      Specified by:
      keys in interface Map<Key extends Comparable<Key>,Value>
      Returns:
      an iterable over the keys
    • reversedKeys

      default Iterable<Key> reversedKeys()
      Get a reverse iterable that yields each key once.

      The items are iterated over in greatest-to-least order (by key).

      Returns:
      an iterable over the keys