#import <ObjectiveLib/Pair.h>
Inheritance diagram for OLPair:
Public Member Functions | |
(int) | - compare: |
Compare this pair to another object. | |
(id) | - copy |
Make a copy of this pair. | |
(id) | - first |
Return the first of the pair. | |
(BOOL) | - isEqual: |
Return whether this pair is equal to another one. | |
(id) | - second |
Return the second of the pair. | |
(void) | - setFirst: |
Set the first object to f. | |
(void) | - setSecond: |
Set the second object to s. | |
(void) | - writeSelfToStream: |
Write the object to a stream. | |
Initializers and Deallocators | |
(id) | - free |
Finalize the pair and deallocate any allocated memory. | |
(id) | - initWithFirst:second: |
Initialize the pair with its two values. | |
(id) | - initWithObjectInStream: |
Initialize the object. | |
Protected Attributes | |
id | first |
The first of the pair. | |
id | second |
The second of the pair. |
Pairs are used extensively in associative containers, like maps, as the underlying storage for a key and its value. It is simply a convenient way to keep two related objects together.
- (int) compare: | (id) | other |
Compare this pair to another object.
If the other object is of type OLPair, then the first object of the pair is compared to the first object of the other pair using the compare:
method. If the result is zero, then the same comparison is subsequently performed on the two pairs' second objects.
other | the object with which to compare this one |
- (id) copy |
Make a copy of this pair.
- (id) first |
Return the first of the pair.
- (id) free |
Finalize the pair and deallocate any allocated memory.
- (id) initWithFirst: | (id) | f | ||
second: | (id) | s | ||
Initialize the pair with its two values.
f | the first in the pair | |
s | the second in the pair |
- (id) initWithObjectInStream: | (OLObjectInStream *) | stream |
Initialize the object.
Each instance variable is read from stream and all other initialization is performed.
stream | the stream from which to read |
Reimplemented from < OLStreamable >.
- (BOOL) isEqual: | (id) | object |
Return whether this pair is equal to another one.
Two pairs are considered equal only if this pair's first value is equal to object's first value and this pair's second value is equal to object's second value. Equality of the members is determined using the method isEqual:
.
object | the object to test for equality |
- (id) second |
Return the second of the pair.
- (void) setFirst: | (id) | f |
Set the first object to f.
f | the new first object |
- (void) setSecond: | (id) | s |
Set the second object to s.
s | the new first object |
- (void) writeSelfToStream: | (OLObjectOutStream *) | stream |
Write the object to a stream.
All instance variables are written to stream.
stream | the stream to which to write. |
Reimplemented from < OLStreamable >.
- (id) first [protected] |
The first of the pair.
- (id) second [protected] |
The second of the pair.
|