#include <coherence/util/TreeMap.hpp>
Inherits Object, and Map::Entry.
This class is used only within the TreeMap class and its derivations.
Public Types | |
typedef spec::Handle | Handle |
Node Handle definition. | |
typedef spec::View | View |
Node View definition. | |
typedef spec::Holder | Holder |
Node Holder definition. | |
Public Member Functions | |
virtual Object::View | getKey () const |
Return the key corresponding to this entry. | |
virtual Object::Holder | getValue () |
Return the value corresponding to this entry. | |
virtual TypedHandle < const String > | toString () const |
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |
virtual void | onInit () |
Event called once the Object has finished being constructed. Specifically when the first attachment is made. This provides a safe point at which Handles/Views to "this" can be created. It is not safe to create Handles/Views to an Object from within its constructor, thus any operations which rely upon this should be deferred until the onInit event is triggered. As with all event methods any derived implementation should include a call to the super class's implementation. Specifically delegation to Object::onInit() must eventually occur or an IllegalStateException will result.
The default implementation calls the onInit() method of each of the Object's SmartMembers. | |
Public Attributes | |
FinalView< Object > | f_vKey |
The key of the node. | |
MemberHolder< Object > | m_ohValue |
The value of the node. | |
int32_t | nBalance |
The AVL balance factor of the sub-tree. | |
MemberHandle< Node > | m_hParent |
The parent of this node. | |
MemberHandle< Node > | m_hLeft |
The left child of this node. | |
MemberHandle< Node > | m_hRight |
The right child of this node. | |
Protected Member Functions | |
virtual void | adopt (Node::Handle hChild, bool fLeft) |
Adopt a child node. | |
virtual Object::Holder | getValue () const |
Get the value associated with the node. | |
virtual Object::Holder | setValue (Object::Holder ohValue) |
Set the value associated with the node. | |
virtual bool | isLeaf () const |
Determine if this node is a part of a 2-3-4 leaf node (i.e. | |
virtual void | dissolve () |
Unlink this element and all sub elements. |
virtual void adopt | ( | Node::Handle | hChild, | |
bool | fLeft | |||
) | [protected, virtual] |
Adopt a child node.
hChild | the child to adopt | |
fLeft | the position of the child |
virtual Object::Holder getValue | ( | ) | const [protected, virtual] |
Get the value associated with the node.
Implements Map::Entry.
virtual Object::Holder setValue | ( | Object::Holder | ohValue | ) | [protected, virtual] |
Set the value associated with the node.
ohValue | the value assocaited with the node |
Implements Map::Entry.
virtual bool isLeaf | ( | ) | const [protected, virtual] |
Determine if this node is a part of a 2-3-4 leaf node (i.e.
at least one NULL child).
virtual Object::View getKey | ( | ) | const [virtual] |
Return the key corresponding to this entry.
Implements Map::Entry.
virtual Object::Holder getValue | ( | ) | [virtual] |
Return the value corresponding to this entry.
Implements Map::Entry.