OLPair Class Reference

A pair of objects. More...

#import <ObjectiveLib/Pair.h>

Inheritance diagram for OLPair:

Inheritance graph
[legend]
List of all members.

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.

Detailed Description

A pair of objects.

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.


Member Function Documentation

- (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.

Parameters:
other the object with which to compare this one
Returns:
a value greater than, equal to, or less than zero accoringly as this object is greater than, equal to, or less than other

- (id) copy  

Make a copy of this pair.

Returns:
the copy

- (id) first  

Return the first of the pair.

Returns:
the first object

- (id) free  

Finalize the pair and deallocate any allocated memory.

- (id) initWithFirst: (id)  f
second: (id)  s 

Initialize the pair with its two values.

Parameters:
f the first in the pair
s the second in the pair
Returns:
a reference to this pair

- (id) initWithObjectInStream: (OLObjectInStream *)  stream  

Initialize the object.

Each instance variable is read from stream and all other initialization is performed.

Parameters:
stream the stream from which to read
Returns:
a reference to this object

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:.

Parameters:
object the object to test for equality
Returns:
YES if the two pairs are equal, NO otherwise

- (id) second  

Return the second of the pair.

Returns:
the second object

- (void) setFirst: (id)  f  

Set the first object to f.

Parameters:
f the new first object

- (void) setSecond: (id)  s  

Set the second object to s.

Parameters:
s the new first object

- (void) writeSelfToStream: (OLObjectOutStream *)  stream  

Write the object to a stream.

All instance variables are written to stream.

Parameters:
stream the stream to which to write.

Reimplemented from < OLStreamable >.


Member Data Documentation

- (id) first [protected]

The first of the pair.

- (id) second [protected]

The second of the pair.


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