Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

AIKBSplayTree.h

00001 
00002 //      Copyright (C) 2004 Dylan Blair
00003 //
00004 //      email: dblair@alumni.cs.utexas.edu
00005 //
00006 //      This library is free software; you can redistribute it and/or
00007 //      modify it under the terms of the GNU Lesser General Public
00008 //      License as published by the Free Software Foundation; either
00009 //      version 2.1 of the License, or (at your option) any later version.
00010 //
00011 //      This library is distributed in the hope that it will be useful,
00012 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //      Lesser General Public License for more details.
00015 //
00016 //      You should have received a copy of the GNU Lesser General Public
00017 //      License along with this library; if not, write to the Free Software
00018 //      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 #ifndef AIKBSplayTree_H
00022 #define AIKBSplayTree_H
00023 
00024 #include "AIBase.h"
00025 
00033 class AIKBSplayTree {
00034         friend class AIKB;
00035 
00036         class BinaryNode {
00037                 std::vector<AIException> elements;
00038                 BinaryNode* left;
00039                 BinaryNode* right;
00040 
00041                 BinaryNode() : left(0), right(0) {}
00042                 BinaryNode(const std::vector<AIException>& elements_, BinaryNode* left_, BinaryNode* right_)
00043                         : elements(elements_), left(left_), right(right_) {}
00044 
00045                 friend class AIKBSplayTree;
00046         };
00047 
00048         BinaryNode* root;
00049         BinaryNode* nullNode;
00050         AIException EXCEPTION_NOT_FOUND;
00051         const std::vector<AIException> VECTOR_NOT_FOUND;
00052         int totalsize;
00053 
00058         void reclaimMemory(BinaryNode* t) const;
00059 
00064         BinaryNode* clone(BinaryNode* t) const;
00065 
00067 
00068         void rotateWithLeftChild(BinaryNode*& k2) const;
00069         void rotateWithRightChild(BinaryNode*& k1) const;
00070 
00080         void splay(const AIException& x, BinaryNode*& t) const;
00082 
00083 public:
00084         AIKBSplayTree();
00085         AIKBSplayTree(const AIKBSplayTree& rhs);
00086         const AIKBSplayTree& operator=(const AIKBSplayTree& rhs);
00087         ~AIKBSplayTree();
00088 
00089         const std::vector<AIException>& find(const AIException& x);
00090         bool  isEmpty() const;
00091         int   totalSize() const;
00092 
00093         int   findStateScore(int stateID, BinaryNode* t, bool first) const;
00094 
00095         void  makeEmpty();
00096         bool  insert(const AIException& x, bool disallow_if_prem_name_exists_=false);
00097         void  remove(const AIException& x, bool all, int num_of_params_to_check_=-1);
00098 };
00099 
00100 #endif //AIKBSplayTree_H

Generated on Sun Apr 11 05:05:55 2004 for FSM_API by doxygen 1.3.6