#include <Association.h>
Inheritance diagram for Core::Association:
Public Member Functions | |
Association (Object *key, Object *value) | |
virtual String * | className (void) const |
Answer receiver class name. | |
Association (const Association &origin) | |
virtual Object * | key (void) |
virtual void | key (Object *) |
virtual Object * | value (void) |
virtual void | value (Object *) |
virtual long | hash (void) const |
Answer object hash value. | |
virtual bool | isEqual (const Object *object) const |
Compare receiver with given object. | |
virtual Object * | copy (void) |
Answer copy of the receiver. | |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual bool | isAssociation (void) const |
Answer if the receiver is an Association. | |
virtual void | visitBy (Visitor *visitor) |
Protected Attributes | |
Object * | _key |
Relation key. | |
Object * | _value |
Relation value associated with the key. |
It's used mainly by Dictionary.
Definition at line 38 of file Association.h.
|
Definition at line 29 of file Association.cc. Referenced by copy().
|
|
Definition at line 36 of file Association.cc.
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Object. Definition at line 44 of file Association.cc. 00045 { 00046 return new String("Association"); 00047 }
|
|
Answer copy of the receiver. Return value is definitely an Association. Definition at line 87 of file Association.cc. References Association(). 00088 { 00089 return new Association(*this); 00090 }
|
|
Answer object hash value. The value should be same for objects found equal with isEqual() method. So if you rewrite this method you should rewrite isEqual() method too. Reimplemented from Core::Object. Definition at line 71 of file Association.cc. References _key, Core::Object::hash(), and nil. 00072 { 00073 if (_key == nil) return Object::hash(); 00074 else return _key->hash(); 00075 }
|
|
Answer if the receiver is an Association.
Reimplemented from Core::Object. Definition at line 102 of file Association.cc. 00103 { 00104 return true; 00105 }
|
|
Compare receiver with given object. This method could compare objects with more sophisticated algorithm (eg. based on instance variables comparing or so). If you rewrite this method you should rewrite hash() too.
Reimplemented from Core::Object. Definition at line 77 of file Association.cc. References _key, _value, Core::Object::isAssociation(), and Core::Object::isEqual(). 00078 { 00079 if (object->isAssociation() && Object::isEqual(object)) { 00080 return _key == ((Association *) object)->key() && 00081 _value == ((Association *) object)->value(); 00082 } 00083 return false; 00084 }
|
|
Definition at line 50 of file Association.cc. References _key. 00051 { 00052 _key = object; 00053 }
|
|
Definition at line 55 of file Association.cc. References _key. Referenced by Core::Dictionary::findKeyOrNil(), Core::Dictionary::fixCollisionsFrom(), and Core::Visitor::visitAssociation(). 00056 { 00057 return _key; 00058 }
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented from Core::Object. Definition at line 93 of file Association.cc. References _key, _value, Core::Stream::nextPutAll(), nil, and Core::Stream::print(). 00094 { 00095 stream->print(_key); 00096 stream->nextPutAll("->"); 00097 if (_value == nil) stream->nextPutAll("nil"); 00098 else stream->print(_value); 00099 }
|
|
Definition at line 60 of file Association.cc. References _value. 00061 { 00062 _value = object; 00063 }
|
|
Definition at line 65 of file Association.cc. References _value. Referenced by Core::Dictionary::add(), Core::Dictionary::at(), Core::Dictionary::put(), Core::Dictionary::removeKey(), Core::Character::value(), and Core::Visitor::visitAssociation(). 00066 { 00067 return _value; 00068 }
|
|
Reimplemented from Core::Object. Definition at line 108 of file Association.cc. References Core::Visitor::visitAssociation(). 00109 { 00110 visitor->visitAssociation(this); 00111 }
|
|
Relation key.
Definition at line 41 of file Association.h. Referenced by Association(), hash(), isEqual(), key(), and printOn(). |
|
Relation value associated with the key.
Definition at line 42 of file Association.h. Referenced by Association(), isEqual(), printOn(), and value(). |