All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.objectspace.jgl.OrderedMultiMap

java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----COM.objectspace.jgl.Map
                   |
                   +----COM.objectspace.jgl.OrderedMap
                           |
                           +----COM.objectspace.jgl.OrderedMultiMap

public class OrderedMultiMap
extends OrderedMap
Note: OrderedMultiMap is deprecated.

An OrderedMultiMap is an associative container that manages a set of ordered key/value pairs. The pairs are ordered by key, using a comparator. By default, a HashComparator is used, which orders keys based on their hash value. Any number of values may be associated with a particular key. A OrderedMultiMap's underlying data structure allows you to very efficiently find all of the values associated with a particular key.

A OrderedMultiMap is useful for implementing a collection of one-to-many mappings.

Strictly speaking, there is no reason why null is not a valid key. However, most comparators (including the default HashComparator) will fail and throw an exception if you attempt to add a null key because they cast the key to a class and then activate one of its methods. It is perfectly possible to hand-craft a comparator that will accept null as a valid key.

There are many different approaches that could be used to implementing an associative container. For example, most of the older libraries used a hashing scheme for positioning and retrieving items. This implementation use a data structure called a red-black tree. A red-black tree is a binary search tree that uses an extra field in every node to store the node's color. Red-black trees constrain the way that nodes may be colored in such a way that the tree remains reasonably balanced. This property is important for ensuring a good overall performance - red-black trees guarantee that the worst case performance for the most common dynamic set operations is O(log N). One conseqence of using a binary tree for storage of data is that the items remain in a sorted order. This allows JGL users to iterate through an associative container and access its elements in a sequenced manner. Each node of the red-black tree holds a Pair( key, value ). The comparator is used to order the Pairs based only on their keys.

Insertion does not affect iterators or references.

Removal only invalidates the iterators and references to the removed elements.

Version:
2.0.2
Author:
ObjectSpace, Inc.
See Also:
OrderedMap, BinaryPredicate, OrderedMultiMapExamples, OrderedMap

Constructor Index

 o OrderedMultiMap()
Construct myself to be an empty OrderedMultiMap that orders its keys based on their hash value.
 o OrderedMultiMap(BinaryPredicate)
Construct myself to be an empty OrderedMultiMap that orders its keys using a specified binary predicate.
 o OrderedMultiMap(OrderedMultiMap)
Construct myself to be a shallow copy of an existing OrderedMultiMap.

Method Index

 o clone()
Return a shallow copy of myself.
 o copy(OrderedMultiMap)
Become a shallow copy of an existing OrderedMultiMap.
 o equals(Object)
Return true if I'm equal to another object.
 o equals(OrderedMultiMap)
Return true if I contain the same items in the same order as another OrderedMultiMap.
 o swap(OrderedMultiMap)
Swap my contents with another OrderedMultiMap.
 o toString()
Return a string that describes me.

Constructors

 o OrderedMultiMap
 public OrderedMultiMap()
Construct myself to be an empty OrderedMultiMap that orders its keys based on their hash value.

 o OrderedMultiMap
 public OrderedMultiMap(BinaryPredicate comparator)
Construct myself to be an empty OrderedMultiMap that orders its keys using a specified binary predicate.

Parameters:
comparator - The predicate for ordering keys.
 o OrderedMultiMap
 public OrderedMultiMap(OrderedMultiMap map)
Construct myself to be a shallow copy of an existing OrderedMultiMap.

Parameters:
map - The OrderedMultiMap to copy.

Methods

 o clone
 public synchronized Object clone()
Return a shallow copy of myself.

Overrides:
clone in class OrderedMap
 o copy
 public synchronized void copy(OrderedMultiMap map)
Become a shallow copy of an existing OrderedMultiMap.

Parameters:
map - The OrderedMultiMap that I shall become a shallow copy of.
 o toString
 public synchronized String toString()
Return a string that describes me.

Overrides:
toString in class OrderedMap
 o equals
 public boolean equals(Object object)
Return true if I'm equal to another object.

Parameters:
object - The object to compare myself against.
Overrides:
equals in class OrderedMap
 o equals
 public synchronized boolean equals(OrderedMultiMap map)
Return true if I contain the same items in the same order as another OrderedMultiMap. Use equals() to compare the individual elements.

Parameters:
map - The OrderedMultiMap to compare myself against.
 o swap
 public synchronized void swap(OrderedMultiMap map)
Swap my contents with another OrderedMultiMap.

Parameters:
map - The OrderedMultiMap that I will swap my contents with.

All Packages  Class Hierarchy  This Package  Previous  Next  Index