#import <ObjectiveLib/HashMap.h>
Inheritance diagram for OLHashMultiMap:
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. |
Hash multimap is identical to hash map except that as many instances of a given key may be inserted as desired.
- (void) assignKey: | (id) | key | ||
value: | (id) | value | ||
Assign a value to a key.
This message always inserts the key-value pair (key, value)
.
hash
.key | the key to insert | |
value | the key's value |
Reimplemented from OLHashMap.
+ (id) hashMultiMap |
Create and return 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)
.
[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
.first | the first in the range of elements to insert | |
last | one beyond the last in the range of elements to insert |
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.
The argument right may be an instance of OLHashMap or of OLHashMultiMap.
right | the hash map to copy |
- (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.
hash
.keyValue | the element to insert |
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.
[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
.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).
object | the object to test |
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.
key | the key for which to search |
nil
Reimplemented from OLHashMap.
|