#include <SearchTreeNode.h>
Inheritance diagram for Core::SearchTreeNode:
Public Member Functions | |
SearchTreeNode (void) | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual SearchTreeNode * | createNewNode (void) |
virtual Object * | at (SequenceableCollection *key) |
virtual Object * | at (SequenceableCollection *key, Object *ifAbsentValue) |
virtual void | put (SequenceableCollection *key, Object *value) |
virtual Object * | atLongestPrefixOf (SequenceableCollection *key) |
virtual bool | includesKey (SequenceableCollection *key) |
virtual Object * | valueAt (SequenceableCollection *key, int depth, bool prefix) |
virtual void | putValueAt (SequenceableCollection *key, Object *value, int depth) |
virtual Object * | privDeeperValueAt (SequenceableCollection *key, int depth, bool prefix) |
Protected Attributes | |
Dictionary * | branches |
Object * | _value |
|
Definition at line 34 of file SearchTreeNode.cc. References _value, branches, and nil. 00035 { 00036 branches = new Dictionary(2); 00037 _value = nil; 00038 }
|
|
Definition at line 57 of file SearchTreeNode.cc. References at(). 00058 { 00059 Object *obj; 00060 00061 try { 00062 obj = at(key); 00063 } 00064 catch (KeyNotFoundError *ex) { 00065 obj = ifAbsentValue; 00066 } 00067 return obj; 00068 }
|
|
Definition at line 52 of file SearchTreeNode.cc. References valueAt(). Referenced by at(), and includesKey(). 00053 { 00054 return valueAt(key, 0, false); 00055 }
|
|
Definition at line 75 of file SearchTreeNode.cc. References valueAt(). 00076 { 00077 return valueAt(key, 0, true); 00078 }
|
|
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 41 of file SearchTreeNode.cc. 00042 { 00043 return new String("SearchTreeNode"); 00044 }
|
|
Definition at line 46 of file SearchTreeNode.cc. Referenced by putValueAt(). 00047 { 00048 return new SearchTreeNode; 00049 }
|
|
Definition at line 81 of file SearchTreeNode.cc.
|
|
Definition at line 113 of file SearchTreeNode.cc. References Core::Dictionary::at(), branches, and valueAt(). Referenced by valueAt(). 00115 { 00116 SearchTreeNode *next; 00117 next = dynamic_cast<SearchTreeNode *>(branches->at(key->at(depth))); 00118 return next->valueAt(key, depth+1, prefix); 00119 }
|
|
Definition at line 70 of file SearchTreeNode.cc. References putValueAt(). 00071 { 00072 putValueAt(key, value, 0); 00073 }
|
|
Definition at line 121 of file SearchTreeNode.cc. References _value, Core::Dictionary::at(), branches, createNewNode(), Core::Dictionary::includesKey(), Core::Dictionary::put(), and putValueAt(). Referenced by put(), and putValueAt(). 00123 { 00124 if (key->size() > depth) { 00125 SearchTreeNode *next; 00126 if (branches->includesKey(key->at(depth))) 00127 next = dynamic_cast<SearchTreeNode *>(branches->at(key->at(depth))); 00128 else { 00129 next = createNewNode(); 00130 branches->put(key->at(depth), next); 00131 } 00132 next->putValueAt(key, value, depth+1); 00133 } else { 00134 _value = value; 00135 } 00136 }
|
|
Definition at line 87 of file SearchTreeNode.cc. References _value, branches, Core::Collection::isEmpty(), nil, privDeeperValueAt(), and Core::SequenceableCollection::size(). Referenced by at(), atLongestPrefixOf(), and privDeeperValueAt(). 00089 { 00090 if (key->size() > depth) { 00091 if (branches->isEmpty() && prefix) 00092 return _value; 00093 else { 00094 if (_value == nil || !prefix) { 00095 return privDeeperValueAt(key, depth, prefix); 00096 } else { 00097 /* I know the value. If there is no better answer, I got one. */ 00098 try { 00099 return privDeeperValueAt(key, depth, prefix); 00100 } 00101 catch (KeyNotFoundError *ex) { 00102 return _value; 00103 } 00104 } 00105 } 00106 } else { 00107 if (_value == nil) 00108 (new KeyNotFoundError(__PRETTY_FUNCTION__, key))->raiseFrom(this); 00109 return _value; 00110 } 00111 }
|
|
Definition at line 39 of file SearchTreeNode.h. Referenced by putValueAt(), SearchTreeNode(), and valueAt(). |
|
Definition at line 38 of file SearchTreeNode.h. Referenced by privDeeperValueAt(), putValueAt(), SearchTreeNode(), and valueAt(). |