source: liacs/da/opdr2b/trie.h@ 129

Last change on this file since 129 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 1.8 KB
Line 
1/* Author : Rick van der Zwet
2 * S-number : 0433373
3 * Version : $Id: trie.h 322 2007-11-22 14:09:00Z rick $
4 * Copyright : FreeBSD Licence
5 */
6
7#ifndef TRIE_H
8#define TRIE_H
9template <class InfoTp>
10class TrieNode
11{
12 public:
13 TrieNode();
14 ~TrieNode();
15 InfoTp Value; // Value of TrieNode
16 TrieNode *One, // Pointer to node if bit is set 1
17 *Zero, // Pointer to node if bit is set 0
18 *Parent; // Pointer to parent node
19};
20
21
22template <class InfoTp>
23class Trie
24{ public:
25 // Constructor, create new Trie, only root
26 Trie ();
27 // Destructor
28 ~Trie ();
29 //Test wether window is at leaf
30 bool AtLeaf ();
31 // Place window on Root
32 void GoRoot ();
33 // Check wether current knob has child K
34 bool ExistsChild (char K);
35 // Place window at child K of current knob
36 void GoChild (char K);
37 // First child of current knob, '\0' if child has no children
38 char FirstChild ();
39 // Get next child of current knob, '\0' if none
40 char NextChild (char K);
41 // Add child K, if already exists do nothing
42 void AddChild (char K);
43 // Remove child, do nothing if not exists
44 void RemoveChild (char K);
45 // Place information in current knob
46 void PutInfo (InfoTp I);
47 // Get information of current knob
48 InfoTp GetInfo ();
49 // PLace window of knob provided
50 void GotoNode (TrieNode<InfoTp> *Nd);
51 // Get address of current knob
52 TrieNode<InfoTp> *GetNode ();
53 private:
54 TrieNode<InfoTp> *Window, //het venster
55 *NodeFound, //store value node if exists
56 *Root; //de wortel
57};
58
59
60#endif
Note: See TracBrowser for help on using the repository browser.