linktrie.h
Go to the documentation of this file.00001 #ifndef LINKTRIE_H
00002 #define LINKTRIE_H
00003
00004 #include "bioseq.h"
00005 #include "matrix.h"
00006 #include <string>
00007 #include <iostream>
00008 #include <vector>
00009
00010 using namespace std;
00011
00012 struct intnode {
00013 intnode() : value(-1), next(0) { }
00014 intnode(int v) : value(v), next(0) { }
00015 int value;
00016 intnode* next;
00017 };
00018
00021 struct lnode {
00022 lnode() : data('0'), sibling(0), child(0), key(0), pos(0) { }
00023 lnode(char c) : data(c), sibling(0), child(0), key(0), pos(0) { }
00024
00025 void addChild(char c) { child=new lnode(c); }
00026 void addSibling(char c) { sibling= new lnode(c); }
00032 lnode* findSibling(char c);
00033
00034 void deleteSelf();
00035 friend void deleteNode(lnode* n);
00039 friend ostream& operator<<(ostream &ous, const lnode& n);
00040
00041 char data;
00042 lnode* sibling;
00043 lnode* child;
00044 char *key;
00045 intnode *pos;
00046
00047 };
00048
00052 class ltrie {
00053 public:
00054 ltrie() : root(new lnode), leafnodes(), ws(4) { }
00055 ltrie(int depth) : root(new lnode), leafnodes(), ws(depth) { }
00056 ltrie(const string &seq);
00057
00058 void build(const string &seq, const Matrix &mat, float T, float F);
00062 void insert(const char word[], int index);
00068 const lnode* find(const char word[]) const;
00069
00070 void showLeafs(ostream &ous) const;
00071 ~ltrie();
00072
00073 protected:
00074 lnode* root;
00075 int ws;
00076 vector<lnode*> leafnodes;
00077 };
00078
00079 #endif