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

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) copyWithZone: (NSZone *)  zone  

Make a copy of this pair allocating memory from the given zone.

Parameters:
zone the zone from which to allocate memory
Returns:
the copy

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

Parameters:
encoder the coder used to store the pair

- (id) first  

Return the first of the pair.

Returns:
the first object

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

Postcondition:
The pair returned will be identical to the pair set saved to the archive using the encodeWithCoder: message.
Parameters:
decoder the coder which will decode the archived pair
Returns:
a reference to this pair

- (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:13:42 2007, © 2004-2007 Will Mason
SourceForge.net Logo