Repository: lucenenet Updated Branches: refs/heads/api-work 267421007 -> e103f24e7
Lucene.Net.TestFramework.Analysis.MockCharFilter: Replaced SortedDictionary with TreeDictionary and eliminated the LowerEntry extension method in Support.DictionaryExtensions (replacing with TreeDictionary.TryPredecessor) Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ae7ddb40 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ae7ddb40 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ae7ddb40 Branch: refs/heads/api-work Commit: ae7ddb404bdae49c5bdd85b5abdc9c3a835af2d1 Parents: 2674210 Author: Shad Storhaug <[email protected]> Authored: Wed Mar 22 06:03:06 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Wed Mar 22 06:03:06 2017 +0700 ---------------------------------------------------------------------- .../Support/DictionaryExtensions.cs | 20 -------------------- .../Analysis/MockCharFilter.cs | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ae7ddb40/src/Lucene.Net.Core/Support/DictionaryExtensions.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/DictionaryExtensions.cs b/src/Lucene.Net.Core/Support/DictionaryExtensions.cs index e680cdb..4285ad7 100644 --- a/src/Lucene.Net.Core/Support/DictionaryExtensions.cs +++ b/src/Lucene.Net.Core/Support/DictionaryExtensions.cs @@ -31,25 +31,5 @@ namespace Lucene.Net.Support dict[key] = value; return oldValue; } - - public static KeyValuePair<int, TValue> LowerEntry<TValue>(this SortedDictionary<int, TValue> sd, int keyLimit) - { - KeyValuePair<int, TValue> retKVPair = default(KeyValuePair<int, TValue>); - - foreach (var kvPair in sd) - { - if (kvPair.Key < keyLimit) - { - retKVPair = kvPair; - } - else - { - // No other key lesser key found - break; - } - } - - return retKVPair; - } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ae7ddb40/src/Lucene.Net.TestFramework/Analysis/MockCharFilter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.TestFramework/Analysis/MockCharFilter.cs b/src/Lucene.Net.TestFramework/Analysis/MockCharFilter.cs index af2f0e3..7858850 100644 --- a/src/Lucene.Net.TestFramework/Analysis/MockCharFilter.cs +++ b/src/Lucene.Net.TestFramework/Analysis/MockCharFilter.cs @@ -95,8 +95,18 @@ namespace Lucene.Net.Analysis protected override int Correct(int currentOff) { - KeyValuePair<int, int> lastEntry = corrections.LowerEntry(currentOff + 1); - int ret = lastEntry.Equals(default(KeyValuePair<int, int>)) ? currentOff : currentOff + lastEntry.Value; + Support.C5.KeyValuePair<int, int> lastEntry; + int ret; + // LUCENENET NOTE: TryPredecessor is equivalent to TreeMap.lowerEntry() in Java + if (corrections.TryPredecessor(currentOff + 1, out lastEntry)) + { + ret = currentOff + lastEntry.Value; + } + else + { + ret = currentOff; + } + Debug.Assert(ret >= 0, "currentOff=" + currentOff + ",diff=" + (ret - currentOff)); return ret; } @@ -106,6 +116,6 @@ namespace Lucene.Net.Analysis corrections[off] = cumulativeDiff; } - internal SortedDictionary<int, int> corrections = new SortedDictionary<int, int>(); + internal TreeDictionary<int, int> corrections = new TreeDictionary<int, int>(); } } \ No newline at end of file
