+++ /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. *
- ***************************************************************************/
-
-
- //TODO check star color of the nodes pos and handle!
-
-#ifndef Pos
-#define Pos Pos
-
-#ifndef uchar
-#define uchar unsigned char
-#endif
-#ifndef ulong
-#define ulong unsigned long
-#endif
-
-#include "rbtree.h"
-#include "handle.h"
-
-class Handle;
-class HandleNode;
-
-void callPosUpdateCounters(RBNode *n, RBTree *T);
-void callPosUpdateCountersOnPathToRoot(RBNode *n, RBTree *T);
-
-class PosNode : public RBNode {
- public:
-
- HandleNode *handleNode;
- ulong subtreeSize;
- ulong textSize; // size including endmarker!
- //ulong sumTextSize; // sum of textlength of all texts located in this subtree;
-
- PosNode() // NIL
- : RBNode(this),subtreeSize(0),textSize(0) {
- }
-
- PosNode(PosNode *n, ulong textSize)
- : RBNode(n),subtreeSize(1),textSize(textSize) {
- }
-
-
- PosNode* getParent(){
- return ((PosNode*) ((RBNode*) this)->parent);
- }
-
- PosNode* getLeft(){
- return ((PosNode*) ((RBNode*) this)->left);
- }
-
- PosNode* getRight(){
- return ((PosNode*) ((RBNode*) this)->right);
- }
-
- void setParent(PosNode* n){
- ((RBNode*) this)->parent=(RBNode*)n;
- }
-
- void setLeft(PosNode* n){
- ((RBNode*) this)->left=(RBNode*)n;
- }
-
- void setRight(PosNode* n){
- ((RBNode*) this)->right=(RBNode*)n;
- }
-};
-
-class Pos: public RBTree
-{
- public:
-
- Handle* handle;
-
- ulong textNumber;
- ulong matchPosition;
-
- ulong sampleInterval;
-
- Pos(ulong sampleInterval){
- setNil(new PosNode());
- setRoot(getNil());
- this->sampleInterval=sampleInterval;
- }
-
- void setRoot(PosNode* n){
- ((RBTree*) this)->root=(RBNode*)n;
- }
-
- PosNode* getRoot(){
- return ((PosNode*) ((RBTree*) this)->root);
- }
-
- void setNil(PosNode* n){
- ((RBTree*) this)->nil=(RBNode*)n;
- }
-
- PosNode* getNil(){
- return ((PosNode*) ((RBTree*) this)->nil);
- }
-
- ulong getSize(){
- return (getRoot()!=getNil())?getRoot()->subtreeSize:0;
- }
-
-
-
- ulong getPos(PosNode *n);
-
-
- PosNode* getPosNode(ulong text);
- ulong getTextSize(ulong pos);
- void deleteText(ulong pos);
- void deletePosNode(PosNode *n);
- ulong appendText(ulong textSize);
-
- void updateCountersOnPathToRoot(PosNode *n);
- void updateCounters(PosNode *n);
-
-};
-
-#endif