#import <ObjectiveLib/Pair.h>
Inheritance diagram for OLPair:
Public Member Functions | |
(int) | - compare: |
Compare this pair to another object. | |
(id) | - copyWithZone: |
Make a copy of this pair allocating memory from the given zone. | |
(void) | - encodeWithCoder: |
Encode the 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 | |
(void) | - dealloc |
Finalize the pair and deallocate any allocated memory. | |
(id) | - initWithCoder: |
Initialize the pair by loading a stored pair from an archive. | |
(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) copyWithZone: | (NSZone *) | zone |
Make a copy of this pair allocating memory from the given zone.
zone | the zone from which to allocate memory |
- (void) dealloc |
Finalize the pair and deallocate any allocated memory.
- (void) encodeWithCoder: | (NSCoder *) | encoder |
Encode the pair.
The pair is saved to an archive using encoder and will be retrieved using the initializer initWithCoder:.
encoder | the coder used to store the pair |
- (id) first |
Return the first of the pair.
- (id) initWithCoder: | (NSCoder *) | decoder |
Initialize the pair by loading a stored pair from an archive.
The stored pair is decoded and its data are used to create a new pair, namely this one.
decoder | the coder which will decode the archived pair |
- (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.
|