OLHashMultiMap Class Reference
[Containers]

A hash map that allows many values to be associated with equivilant keys. More...

#import <ObjectiveLib/HashMap.h>

Inheritance diagram for OLHashMultiMap:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - assignKey:value:
 Assign a value to a key.
(id) - insert:
 Insert a key-value pair into the map.
(void) - insertFrom:to:
 Insert a range of key-value pairs into the map.
(BOOL) - isEqual:
 Test whether another map is equal to this one.
(id) - valueForKey:
 Find the value of a given key.

Static Public Member Functions

(id) + hashMultiMap
 Create and return a new hash map.
(id) + hashMultiMapFrom:to:
 Create and return a new hash map.
(id) + hashMultiMapWithHashMap:
 Create and return a new hash map.

Detailed Description

A hash map that allows many values to be associated with equivilant keys.

Hash multimap is identical to hash map except that as many instances of a given key may be inserted as desired.

See also:
OLHashMap, OLHashIterator


Member Function Documentation

- (void) assignKey: (id)  key
value: (id)  value 

Assign a value to a key.

This message always inserts the key-value pair (key, value).

Precondition:
key must respond to the message hash.
Parameters:
key the key to insert
value the key's value

Reimplemented from OLHashMap.

+ (id) hashMultiMap  

Create and return a new hash map.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Returns:
a new hash map

+ (id) hashMultiMapFrom: (OLForwardIterator *)  first
to: (OLForwardIterator *)  last 

Create and return a new hash map.

The hash map is initialized with the contents of the range [first, last).

Precondition:
Each element in the range [first, last) must be an instance of OLPair. The first element of the pair is the key and the second element is the key's value. Additionally, each key object must respond to the message hash.
Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
first the first in the range of elements to insert
last one beyond the last in the range of elements to insert
Returns:
a reference to this map

a new hash map

+ (id) hashMultiMapWithHashMap: (OLHashMap *)  right  

Create and return a new hash map.

The hash map is initialized with the contents of right.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.

The argument right may be an instance of OLHashMap or of OLHashMultiMap.

Parameters:
right the hash map to copy
Returns:
a new hash map

- (id) insert: (OLPair *)  keyValue  

Insert a key-value pair into the map.

The pair is inserted and an instance of OLHashIterator is returned indicating the position of keyValue in the set. The object to which the iterator points is an instance of OLPair. The first element of the pair is the key and the second element of the pair is the key's value.

Precondition:
The first element of keyValue must be the key and the second element must be the key's value. Additionally, the key object must resopnd to the message hash.
Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
keyValue the element to insert
Returns:
an instance of OLHashIterator pointing to the newly inserted object

Reimplemented from OLHashMap.

- (void) insertFrom: (OLForwardIterator *)  first
to: (OLForwardIterator *)  last 

Insert a range of key-value pairs into the map.

An attempt is made to insert all pairs in the range [first, last), however there is no guarantee that any of the elements in the range will actually be inserted if they already exist in the map.

Precondition:
All elements in the range [first, last) must be instances of OLPair where the first element of the pair is the key and the second element is the key's value. Additionally, each key object must respond to the message hash.
Parameters:
first the first in the range of pairs to insert
last one position beyond the last in the range of pairs to insert

Reimplemented from OLHashMap.

- (BOOL) isEqual: (id)  object  

Test whether another map is equal to this one.

Two maps are considered equal if they contain the same number of objects and the and the value of each key is equal to the value of the corresponding key in the other map. Values are always compared using the message isEqual:, while keys are compared using the functor returned by the message keyEqual (OLHashMap).

Note:
When two maps each contain a range of equal keys, the values that correspond to those keys do not have to appear in the same order. They just have to exist.
Parameters:
object the object to test
Returns:
YES if object is equal to this map, NO otherwise

Reimplemented from OLHashMap.

- (id) valueForKey: (id)  key  

Find the value of a given key.

Since a hash multimap can have any number of values associated with equivilent keys, this message does nothing. The value nil is always returned.

Parameters:
key the key for which to search
Returns:
nil

Reimplemented from OLHashMap.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:13:17 2007, © 2004-2007 Will Mason
SourceForge.net Logo