Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 88 lines (69 sloc) 2.347 kb
bb15f0f Initial prototype commit
(no author) authored
1 using System;
2 using System.Collections;
3 using System.Collections.Specialized;
4
5 namespace Mercury
6 {
7 public class WordGraphNode
8 {
9 long _nodeId;
10 long _wordId;
11 int _ordinal;
12 String _word;
13 ArrayList _childNodes;
14 WordGraphNode _ancestorNode;
15 String _matchThisWord;
16
17 private WordGraphNode()
18 {
19 _nodeId = -1;
20 _wordId = -1;
21 _ordinal = 0;
22 _word = null;
23 _ancestorNode = null;
24
25 _matchThisWord = null;
26
27 _childNodes = new ArrayList();
28 }
29
cdc60f2 Preliminary switch to async word graph traversal; still broken but getti...
(no author) authored
30 private WordGraphNode(WordGraphNode copyNode) : this(copyNode.NodeId, copyNode.WordId, copyNode.AncestorNode, copyNode.Ordinal, copyNode.Word) {
31 _matchThisWord = copyNode.MatchThisWord;
95a3ab5 Working a little faster now, but the graph traversal really needs to be ...
(no author) authored
32 _childNodes = new ArrayList();
33 foreach (WordGraphNode child in copyNode.ChildNodes) {
34 _childNodes.Add(child);
35 }
cdc60f2 Preliminary switch to async word graph traversal; still broken but getti...
(no author) authored
36 }
37
bb15f0f Initial prototype commit
(no author) authored
38 private WordGraphNode(long nodeId, long wordId, WordGraphNode ancestorNode, int ordinal, String word) : this() {
39 _nodeId = nodeId;
40 _wordId = wordId;
41 _ancestorNode = ancestorNode;
42
43 _ordinal = ordinal;
44 _word = word;
45 }
46
47 public long NodeId {get {return _nodeId;}}
48 public long WordId {get {return _wordId;}}
49 public int Ordinal {get {return _ordinal;}}
50 public String Word {get {return _word;}}
51 public IEnumerable ChildNodes {get {return _childNodes;}}
52 public WordGraphNode AncestorNode {get {return _ancestorNode;}}
53
54 public String MatchThisWord {get {return _matchThisWord;} set {_matchThisWord = value;} }
55 public String MatchThisPath {get {return _ancestorNode == null ? _matchThisWord : _ancestorNode.MatchThisPath + _matchThisWord;} }
56
57 public static WordGraphNode CreateRoot() {
58 return new WordGraphNode();
59 }
60
61 public WordGraphNode AddChild(long nodeId, long wordId, int ordinal, String word) {
62 WordGraphNode child = CreateChild(nodeId, wordId, ordinal, word);
63
64 _childNodes.Add(child);
65
66 return child;
67 }
68
69 public WordGraphNode CreateChild(long nodeId, long wordId, int ordinal, String word) {
70 WordGraphNode child = new WordGraphNode(nodeId, wordId, this, ordinal, word);
71
72 return child;
73 }
74
cdc60f2 Preliminary switch to async word graph traversal; still broken but getti...
(no author) authored
75 public WordGraphNode Copy() {
76 return new WordGraphNode(this);
77 }
78
bb15f0f Initial prototype commit
(no author) authored
79 public void RemoveChild(WordGraphNode child) {
80 _childNodes.Remove(child);
81 }
82
83 public void RemoveAllChildren() {
84 _childNodes.Clear();
85 }
86 }
87 }
Something went wrong with that request. Please try again.