private IndexTree _buildTree(List <IPairTagMatch> openers) { uint inputL = (uint)input.Length; Boolean closerOutOfBounds; int closerStartAt; Dictionary <int, IPairTagMatch> closerIndices = new Dictionary <int, IPairTagMatch>(); IPairTagMatch mOp; IPairTagMatch mCl; IndexTree rootTree = new IndexTree(0, (int)inputL, 0, 0, null, null); int i = openers.Count; while (i-- > 0) { mOp = openers[i]; closerStartAt = (int)(mOp.tagIndex + mOp.tagLength); closerOutOfBounds = false; while (true) { mCl = pairTagMatcher.searchCloserFor(mOp, (uint)closerStartAt); if (mCl == null) { mCl = new VoidCloserTagMatch((int)inputL); closerOutOfBounds = true; } if (!closerIndices.ContainsKey(mCl.tagIndex)) { if (mCl.tagIndex < inputL) { closerIndices[mCl.tagIndex] = mCl; } IndexTree.insertLeaf(rootTree, new IndexTree(mOp.tagIndex, (int)(mCl.tagIndex + mCl.tagLength), (int)(mOp.tagLength), (int)(-mCl.tagLength), new PairTag(mOp, mCl), null)); break; } if (closerOutOfBounds) { break; } else if (mCl != null) { closerStartAt = mCl.tagIndex + 1; } } } return(rootTree); }
private IndexTree _buildTree(List<IPairTagMatch> openers) { uint inputL = (uint)input.Length; Boolean closerOutOfBounds; int closerStartAt; Dictionary<int, IPairTagMatch> closerIndices = new Dictionary<int, IPairTagMatch>(); IPairTagMatch mOp; IPairTagMatch mCl; IndexTree rootTree = new IndexTree(0, (int)inputL, 0, 0, null, null); int i = openers.Count; while (i-- > 0) { mOp = openers[i]; closerStartAt = (int)(mOp.tagIndex + mOp.tagLength); closerOutOfBounds = false; while (true) { mCl = pairTagMatcher.searchCloserFor(mOp, (uint)closerStartAt); if (mCl == null) { mCl = new VoidCloserTagMatch((int)inputL); closerOutOfBounds = true; } if (!closerIndices.ContainsKey(mCl.tagIndex)) { if (mCl.tagIndex < inputL) closerIndices[mCl.tagIndex] = mCl; IndexTree.insertLeaf(rootTree, new IndexTree(mOp.tagIndex, (int)(mCl.tagIndex + mCl.tagLength), (int)(mOp.tagLength), (int)(-mCl.tagLength), new PairTag(mOp, mCl), null)); break; } if (closerOutOfBounds) break; else if (mCl != null) closerStartAt = mCl.tagIndex + 1; } } return rootTree; }