+++ /dev/null
-
-/***************************************************************************
- * Copyright (C) 2006 by Wolfgang Gerlach *
- * No object matches key 'wgerlach'. *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-
-#ifndef Handle
-#define Handle Handle
-
-#ifndef uchar
-#define uchar unsigned char
-#endif
-#ifndef ulong
-#define ulong unsigned long
-#endif
-
-#include "rbtree.h"
-#include "pos.h"
-
-
-class Pos;
-class PosNode;
-
-void callHandleUpdateCounters(RBNode *n, RBTree *T);
-void callHandleUpdateCountersOnPathToRoot(RBNode *n, RBTree *T);
-
-
-class HandleNode : public RBNode {
- public:
- ulong key; //maximum for internal nodes
- ulong subtreeSize;
- ulong maxkey;
- PosNode *posNode;
-
- HandleNode()
- : RBNode(this), key(0), subtreeSize(0), maxkey(0){
- }
-
-
- HandleNode(HandleNode *n, ulong key)
- : RBNode(n), key(key), subtreeSize(1), maxkey(key){
- }
-
-
- HandleNode* getParent(){
- return ((HandleNode*) ((RBNode*) this)->parent);
- }
-
- HandleNode* getLeft(){
- return ((HandleNode*) ((RBNode*) this)->left);
- }
-
- HandleNode* getRight(){
- return ((HandleNode*) ((RBNode*) this)->right);
- }
-
- void setParent(HandleNode* n){
- ((RBNode*) this)->parent=(RBNode*)n;
- }
-
- void setLeft(HandleNode* n){
- ((RBNode*) this)->left=(RBNode*)n;
- }
-
- void setRight(HandleNode* n){
- ((RBNode*) this)->right=(RBNode*)n;
- }
-
-};
-
-class Handle : public RBTree{
- public:
- Pos *pos;
-
- Handle(){
- setNil(new HandleNode());
- setRoot(getNil());
- }
-
-
- void setRoot(HandleNode* n){
- ((RBTree*) this)->root=(RBNode*)n;
- }
-
- HandleNode* getRoot(){
- return ((HandleNode*) ((RBTree*) this)->root);
- }
-
- void setNil(HandleNode* n){
- ((RBTree*) this)->nil=(RBNode*)n;
- }
-
- HandleNode* getNil(){
- return ((HandleNode*) ((RBTree*) this)->nil);
- }
-
-
- ulong getSize(){
- return (getRoot()!=getNil())?getRoot()->subtreeSize:0;
- }
-
- ulong* getKeys();
-
- ulong getPos(ulong key);
- ulong* getEndPositions();
-
- HandleNode* getKey(ulong key);
- void deleteKey(ulong key);
- void updateCountersOnPathToRoot(HandleNode *n);
- void updateCounters(HandleNode *n);
-
- HandleNode* getNewKey();
-
-
-
-};
-
-#endif