Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 841ec34ec4
Fetching contributors…

Cannot retrieve contributors at this time

88 lines (69 sloc) 2.347 kB
using System;
using System.Collections;
using System.Collections.Specialized;
namespace Mercury
{
public class WordGraphNode
{
long _nodeId;
long _wordId;
int _ordinal;
String _word;
ArrayList _childNodes;
WordGraphNode _ancestorNode;
String _matchThisWord;
private WordGraphNode()
{
_nodeId = -1;
_wordId = -1;
_ordinal = 0;
_word = null;
_ancestorNode = null;
_matchThisWord = null;
_childNodes = new ArrayList();
}
private WordGraphNode(WordGraphNode copyNode) : this(copyNode.NodeId, copyNode.WordId, copyNode.AncestorNode, copyNode.Ordinal, copyNode.Word) {
_matchThisWord = copyNode.MatchThisWord;
_childNodes = new ArrayList();
foreach (WordGraphNode child in copyNode.ChildNodes) {
_childNodes.Add(child);
}
}
private WordGraphNode(long nodeId, long wordId, WordGraphNode ancestorNode, int ordinal, String word) : this() {
_nodeId = nodeId;
_wordId = wordId;
_ancestorNode = ancestorNode;
_ordinal = ordinal;
_word = word;
}
public long NodeId {get {return _nodeId;}}
public long WordId {get {return _wordId;}}
public int Ordinal {get {return _ordinal;}}
public String Word {get {return _word;}}
public IEnumerable ChildNodes {get {return _childNodes;}}
public WordGraphNode AncestorNode {get {return _ancestorNode;}}
public String MatchThisWord {get {return _matchThisWord;} set {_matchThisWord = value;} }
public String MatchThisPath {get {return _ancestorNode == null ? _matchThisWord : _ancestorNode.MatchThisPath + _matchThisWord;} }
public static WordGraphNode CreateRoot() {
return new WordGraphNode();
}
public WordGraphNode AddChild(long nodeId, long wordId, int ordinal, String word) {
WordGraphNode child = CreateChild(nodeId, wordId, ordinal, word);
_childNodes.Add(child);
return child;
}
public WordGraphNode CreateChild(long nodeId, long wordId, int ordinal, String word) {
WordGraphNode child = new WordGraphNode(nodeId, wordId, this, ordinal, word);
return child;
}
public WordGraphNode Copy() {
return new WordGraphNode(this);
}
public void RemoveChild(WordGraphNode child) {
_childNodes.Remove(child);
}
public void RemoveAllChildren() {
_childNodes.Clear();
}
}
}
Jump to Line
Something went wrong with that request. Please try again.