@@ -21,13 +21,11 @@ public class SuffixTree : SuffixTreeBase
2121
2222 /// <summary>Links between nodes</summary>
2323 private Lazy < List < int > > _nodeLinks ;
24- /// <summary>Comparer for nodes against a char</summary>
25- private Func < int , char , int > _childComparer ;
2624 // state: (activeNode_, activeChild_, activeLength_), pending_
2725 /// <summary>Index of the branch node</summary>
2826 private int _branchNodeIndex ;
2927 /// <summary>Index of the active edge (child node) of the branch node</summary>
30- private int _activeEdgeIndex ;
28+ private int _activeEdgeIndex ;
3129 /// <summary>The length of the current part of the active child</summary>
3230 private int activeLength_ ;
3331 /// <summary>Offset of the first suffix to insert</summary>
@@ -61,7 +59,6 @@ private void ResetLinks() => _nodeLinks =
6159 protected override void BuildFor ( int begin , int end )
6260 {
6361 Code . AssertState ( begin < end , "Invalid parameters passed" ) ;
64- _childComparer = GetComparer ( ) ;
6562 _branchNodeIndex = RootNodeIndex ;
6663 _activeEdgeIndex = InvalidNodeIndex ;
6764 activeLength_ = 0 ;
@@ -93,7 +90,6 @@ protected override void BuildFor(int begin, int end)
9390 }
9491 UpdateActiveEdgeAndCurentPosition ( ) ;
9592 }
96- _childComparer = null ;
9793 }
9894
9995 /// <summary>Finds the next branching point</summary>
@@ -113,10 +109,10 @@ private void FindBranchingPoint()
113109 childNodeIndex = InvalidNodeIndex ;
114110 activeEdge = default ( Node ) ;
115111 }
116- for ( ; ; )
112+ for ( ; ; )
117113 {
118114 if ( _activeEdgeIndex == InvalidNodeIndex )
119- {
115+ {
120116 DebugCode . AssertState ( activeLength_ == 0 , "Invalid active state" ) ;
121117 if ( _currentOffset == _end )
122118 {
@@ -128,7 +124,7 @@ private void FindBranchingPoint()
128124 return ;
129125 }
130126 var c = InternalData [ _currentOffset ] ;
131- var childIndex = children . LowerBound ( c , _childComparer ) ;
127+ var childIndex = children . LowerBound ( c , EdgeComparer ) ;
132128 if ( childIndex == children . Count )
133129 {
134130 // a new branch
@@ -219,7 +215,7 @@ private void UpdateActiveEdgeAndCurentPosition()
219215 DebugCode . AssertState ( ! branchNode . IsLeaf , "Invalid active state" ) ;
220216 var index = _currentOffset - activeLength_ ;
221217 var children = branchNode . Children ;
222- var childIndex = children . LowerBound ( InternalData [ index ] , _childComparer ) ;
218+ var childIndex = children . LowerBound ( InternalData [ index ] , EdgeComparer ) ;
223219 DebugCode . AssertState ( childIndex != children . Count , "Invalid active state" ) ;
224220 var edgeIndex = children [ childIndex ] ;
225221 var edgeNode = GetNode ( edgeIndex ) ;
@@ -295,7 +291,7 @@ private void InsertSuffix()
295291 {
296292 childNodeIndex = _currentOffset == _end
297293 ? 0 // empty nodes always at the beginning
298- : children . LowerBound ( InternalData [ _currentOffset ] , _childComparer ) ;
294+ : children . LowerBound ( InternalData [ _currentOffset ] , EdgeComparer ) ;
299295 }
300296 // now we have a non-empty children and an insertion index
301297 // just do an insert
@@ -328,7 +324,7 @@ protected override void PrintNodeText(StringBuilder sb, int nodeIndex)
328324 {
329325 var n = GetNode ( nodeIndex ) ;
330326 var nodeLink = _nodeLinks . IsValueCreated ? _nodeLinks . Value [ nodeIndex ] : InvalidNodeIndex ;
331- var linkText = nodeLink != InvalidNodeIndex ? $ " -> { nodeLink } " : string . Empty ;
327+ var linkText = nodeLink != InvalidNodeIndex ? $ " -> { nodeLink } " : string . Empty ;
332328 sb . AppendLine ( $ "({ nodeIndex } { linkText } , [{ n . Begin } -{ n . End } ), { InternalData . Substring ( n . Begin , n . End - n . Begin ) } )") ;
333329 }
334330 }
0 commit comments