property_map.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _KJS_PROPERTY_MAP_H_
00026 #define _KJS_PROPERTY_MAP_H_
00027
00028 #include "ustring.h"
00029 #include "value.h"
00030
00031 namespace KJS {
00032
00033 class PropertyMapNode {
00034 public:
00035 PropertyMapNode(const UString &n, ValueImp *v, int att, PropertyMapNode *p)
00036 : name(n), value(v), attr(att), left(0), right(0), parent(p), height(1) {}
00037
00038 UString name;
00039 ValueImp *value;
00040 int attr;
00041
00042 void setLeft(PropertyMapNode *newLeft);
00043 void setRight(PropertyMapNode *newRight);
00044 PropertyMapNode *findMax();
00045 PropertyMapNode *findMin();
00046
00047 PropertyMapNode *next();
00048
00049 PropertyMapNode *left;
00050 PropertyMapNode *right;
00051 PropertyMapNode *parent;
00052 int height;
00053
00054 private:
00055 void setParent(PropertyMapNode *newParent);
00056 };
00057
00069 class PropertyMap {
00070 public:
00071 PropertyMap();
00072 ~PropertyMap();
00073
00074 void put(const UString &name, ValueImp *value, int attr);
00075 void remove(const UString &name);
00076 ValueImp *get(const UString &name) const;
00077
00078 void clear(PropertyMapNode *node = 0);
00079 void dump(const PropertyMapNode *node = 0, int indent = 0) const;
00080 void checkTree(const PropertyMapNode *node = 0) const;
00081
00082 PropertyMapNode *getNode(const UString &name) const;
00083 PropertyMapNode *first() const;
00084
00085 private:
00086
00087 PropertyMapNode *remove(PropertyMapNode *node);
00088 void balance(PropertyMapNode* node);
00089 void updateHeight(PropertyMapNode* &node);
00090
00091 void rotateRR(PropertyMapNode* &node);
00092 void rotateLL(PropertyMapNode* &node);
00093 void rotateRL(PropertyMapNode* &node);
00094 void rotateLR(PropertyMapNode* &node);
00095
00096 PropertyMapNode *root;
00097 };
00098
00099 int uscompare(const UString &s1, const UString &s2);
00100
00101 }
00102
00103 #endif // _KJS_PROPERTY_MAP_H_
This file is part of the documentation for kdelibs Version 3.1.5.