All pastes #236752 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-11-04 00:55 UTC
rendered paste body
#ifndef TRIE_HPP
#define TRIE_HPP

#include <map>
#include <string>
#include <iostream>
#include "../Relationship/Relationship.hpp"
#define TrieRelationship map<Trie *, Relationship *>
#define TrieKids map<char, Trie *>
#define RelatedTries multimap<int, string>
using namespace std;
class Trie {
  public:
    Trie () :
      fullword(false), letter('\0'), parent(NULL) {};
      
    Trie (Trie * newparent, char newletter) :
      fullword(false), letter(newletter), parent(newparent) {};
      
    void AddWord(const string newword);
    Trie * FindWord(string newword);
    string GetName();
    void Relate(Trie * sibling, const int score);
    void Repr(string leader);
    
  private:
    bool fullword;
    char letter;
    Trie *parent;
    TrieRelationship related;
    TrieKids children;
    Trie * CreateChild(const char letter);
    void GiveRelate(RelatedTries & list);
    void SetFinal() { fullword = true; };
};  
#endif