Return-Path: X-Original-To: apmail-lucenenet-commits-archive@www.apache.org Delivered-To: apmail-lucenenet-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 69C2C174A6 for ; Sun, 9 Nov 2014 22:07:46 +0000 (UTC) Received: (qmail 95468 invoked by uid 500); 9 Nov 2014 22:07:46 -0000 Delivered-To: apmail-lucenenet-commits-archive@lucenenet.apache.org Received: (qmail 95341 invoked by uid 500); 9 Nov 2014 22:07:46 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 95065 invoked by uid 99); 9 Nov 2014 22:07:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Nov 2014 22:07:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E78768BE8E8; Sun, 9 Nov 2014 22:07:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: mherndon@apache.org To: commits@lucenenet.apache.org Date: Sun, 09 Nov 2014 22:07:49 -0000 Message-Id: <6b471a1f5dd44562b21e780528fecfc6@git.apache.org> In-Reply-To: <5953233ebef74fdca438d57bb0b22c24@git.apache.org> References: <5953233ebef74fdca438d57bb0b22c24@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [5/7] lucenenet git commit: creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality. creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality. Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/4b4d4d93 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/4b4d4d93 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/4b4d4d93 Branch: refs/heads/pcl Commit: 4b4d4d93c9fcfadbd2afecd42d59150e87bdb962 Parents: d324216 Author: Michael Herndon Authored: Sat Aug 23 02:00:50 2014 -0400 Committer: Michael Herndon Committed: Sat Aug 23 02:00:50 2014 -0400 ---------------------------------------------------------------------- Lucene.vs2013.sln | 21 + Lucene.vs2013.sln.GhostDoc.user.dic | 1 + src/Lucene.Net.Core/Lucene.Net.Core.csproj | 3 + .../Support/BitArrayExtensions.cs | 4 + src/Lucene.Net.Core/Support/BitSet.cs | 17 + src/Lucene.Net.Core/Support/Class1.cs | 8 + src/Lucene.Net.Core/Util/OpenBitSet.cs | 138 ++- src/Lucene.Net.Java/Check.cs | 60 + src/Lucene.Net.Java/Lang/Int.cs | 24 + src/Lucene.Net.Java/Lang/Long.cs | 153 +++ src/Lucene.Net.Java/Lang/String.cs | 123 ++ src/Lucene.Net.Java/Lucene.Net.Java.csproj | 60 + src/Lucene.Net.Java/Lucene.Net.Java.kproj | 56 + src/Lucene.Net.Java/Properties/AssemblyInfo.cs | 21 + src/Lucene.Net.Java/Readme.md | 16 + src/Lucene.Net.Java/Util/Arrays.cs | 37 + src/Lucene.Net.Java/Util/DualPivotQuicksort.cs | 1090 ++++++++++++++++++ src/Lucene.Net.Java/Util/InsertionSort.cs | 68 ++ src/Lucene.Net.Java/default.ruleset | 87 ++ src/Lucene.Net.Java/packages.config | 4 + src/Lucene.Net.Java/project.json | 20 + .../Lucene.Net.Core.Tests.csproj | 11 +- .../Util/BaseSorterTestCase.cs | 6 +- .../Lucene.Net.Core.Tests/Util/TestBroadWord.cs | 11 +- .../Util/TestByteArrayRef.cs | 8 +- .../Util/TestByteBlockPool.cs | 10 +- test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs | 2 +- test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs | 16 +- .../Util/TestOpenBitSet.cs | 439 +++++++ .../Util/TestWeakIdentityMap.cs | 8 +- .../Lucene.Net.Java.Tests.csproj | 83 ++ .../Properties/AssemblyInfo.cs | 30 + .../Util/InsertionSortTests.cs | 71 ++ .../Lucene.Net.Java.Tests/Util/SortTestClass.cs | 39 + test/Lucene.Net.Java.Tests/packages.config | 27 + test/Lucene.Net.Java.Tests/project.json | 37 + .../CategoryAttribute.cs | 44 + .../ExtensionMethods.cs | 40 + .../Lucene.Net.TestFramework.Core.csproj | 71 ++ .../NightlyAttribute.cs | 18 + .../PerformanceAttribute.cs | 17 + .../Properties/AssemblyInfo.cs | 30 + .../RandomExtensions.cs | 30 + test/Lucene.Net.TestFramework.Core/Settings.cs | 16 + .../TestAttribute.cs | 30 + test/Lucene.Net.TestFramework.Core/TestClass.cs | 226 ++++ .../TicketAttribute.cs | 52 + .../packages.config | 27 + test/Lucene.Net.TestFramework.Core/project.json | 34 + .../Lucene.Net.TestFramework.csproj | 17 +- .../Random/RandomExtensions.cs | 7 +- .../Util/BaseDocIdSetTestCase.cs | 226 ++++ .../Util/ExtensionMethods.cs | 41 - .../Util/LuceneTestCase.cs | 225 +--- .../Util/TestAttribute.cs | 137 --- 55 files changed, 3593 insertions(+), 504 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/Lucene.vs2013.sln ---------------------------------------------------------------------- diff --git a/Lucene.vs2013.sln b/Lucene.vs2013.sln index 9170178..f2c2d53 100644 --- a/Lucene.vs2013.sln +++ b/Lucene.vs2013.sln @@ -13,6 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.TestFramework", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Core.Tests", "test\Lucene.Net.Core.Tests\Lucene.Net.Core.Tests.csproj", "{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Java", "src\Lucene.Net.Java\Lucene.Net.Java.csproj", "{4AD3FE35-AA0A-4C3C-A043-12711625DF74}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Java.Tests", "test\Lucene.Net.Java.Tests\Lucene.Net.Java.Tests.csproj", "{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.TestFramework.Core", "test\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj", "{438B8450-E93A-425F-9A9B-11D02E8896D5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -31,6 +37,18 @@ Global {C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Debug|Any CPU.Build.0 = Debug|Any CPU {C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Release|Any CPU.ActiveCfg = Release|Any CPU {C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Release|Any CPU.Build.0 = Release|Any CPU + {4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Release|Any CPU.Build.0 = Release|Any CPU + {06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Release|Any CPU.Build.0 = Release|Any CPU + {438B8450-E93A-425F-9A9B-11D02E8896D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {438B8450-E93A-425F-9A9B-11D02E8896D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {438B8450-E93A-425F-9A9B-11D02E8896D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {438B8450-E93A-425F-9A9B-11D02E8896D5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -39,5 +57,8 @@ Global {AD8901C0-209D-4132-80AA-257DBACEECB4} = {CD84C1EF-B845-4914-A9DD-D0F9ACC7DE6F} {F0D68FEA-B118-43B6-B760-3FB75CDE766D} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B} {C879C7A6-FBE5-4F22-B363-A4356C7B8E76} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B} + {4AD3FE35-AA0A-4C3C-A043-12711625DF74} = {CD84C1EF-B845-4914-A9DD-D0F9ACC7DE6F} + {06FE85CA-11BA-4E69-81B4-1FA6E031E0B7} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B} + {438B8450-E93A-425F-9A9B-11D02E8896D5} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B} EndGlobalSection EndGlobal http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/Lucene.vs2013.sln.GhostDoc.user.dic ---------------------------------------------------------------------- diff --git a/Lucene.vs2013.sln.GhostDoc.user.dic b/Lucene.vs2013.sln.GhostDoc.user.dic index 117fab3..7da4c3e 100644 --- a/Lucene.vs2013.sln.GhostDoc.user.dic +++ b/Lucene.vs2013.sln.GhostDoc.user.dic @@ -1,3 +1,4 @@ indices init +Quicksort Subword http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Lucene.Net.Core.csproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Lucene.Net.Core.csproj b/src/Lucene.Net.Core/Lucene.Net.Core.csproj index 26f3b3b..3d235a3 100644 --- a/src/Lucene.Net.Core/Lucene.Net.Core.csproj +++ b/src/Lucene.Net.Core/Lucene.Net.Core.csproj @@ -62,6 +62,9 @@ + + + http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Support/BitArrayExtensions.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/BitArrayExtensions.cs b/src/Lucene.Net.Core/Support/BitArrayExtensions.cs new file mode 100644 index 0000000..0174a00 --- /dev/null +++ b/src/Lucene.Net.Core/Support/BitArrayExtensions.cs @@ -0,0 +1,4 @@ + + + + http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Support/BitSet.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/BitSet.cs b/src/Lucene.Net.Core/Support/BitSet.cs new file mode 100644 index 0000000..473ce48 --- /dev/null +++ b/src/Lucene.Net.Core/Support/BitSet.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lucene.Net.Support +{ + public class BitSet + { + private const int BITS_PER_WORD = 1 << 6; + private const ulong WORD_MASK = 0xffffffffffffffffL; + + + + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Support/Class1.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Support/Class1.cs b/src/Lucene.Net.Core/Support/Class1.cs new file mode 100644 index 0000000..37fc23b --- /dev/null +++ b/src/Lucene.Net.Core/Support/Class1.cs @@ -0,0 +1,8 @@ + + +namespace Lucene.Net.Support +{ + class Class1 + { + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Util/OpenBitSet.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/OpenBitSet.cs b/src/Lucene.Net.Core/Util/OpenBitSet.cs index 7a176e3..2a0bca0 100644 --- a/src/Lucene.Net.Core/Util/OpenBitSet.cs +++ b/src/Lucene.Net.Core/Util/OpenBitSet.cs @@ -131,11 +131,21 @@ namespace Lucene.Net.Util this.numBits = wordLength * 64; } + /// + /// Provides a to access the set. + /// this implementation can return null if there + /// are no docs that match. + /// + /// DocIdSetIterator. public override DocIdSetIterator GetIterator() { return new OpenBitSetIterator(bits, this.wordLength); } + /// + /// Gets the bits. + /// + /// IBits. public override IBits GetBits() { return this; @@ -233,8 +243,8 @@ namespace Lucene.Net.Util } int bit = index & 0x3f; // mod 64 - long bitmask = 1L << bit; - return (bits[i] & bitmask) != 0; + long bitMask = 1L << bit; + return (bits[i] & bitMask) != 0; } /// @@ -248,8 +258,8 @@ namespace Lucene.Net.Util // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. int bit = index & 0x3f; // mod 64 - long bitmask = 1L << bit; - return (bits[i] & bitmask) != 0; + long bitMask = 1L << bit; + return (bits[i] & bitMask) != 0; } /// @@ -263,8 +273,8 @@ namespace Lucene.Net.Util return false; } int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - return (bits[i] & bitmask) != 0; + long bitMask = 1L << bit; + return (bits[i] & bitMask) != 0; } /// @@ -276,8 +286,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int i = (int)(index >> 6); // div 64 int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - return (bits[i] & bitmask) != 0; + long bitMask = 1L << bit; + return (bits[i] & bitMask) != 0; } /* @@ -288,7 +298,7 @@ namespace Lucene.Net.Util return ((bits[i]>>>bit) & 0x01) != 0; // this does a long shift and a bittest (on x86) vs // a long shift, and a long AND, (the test for zero is prob a no-op) - // testing on a P4 indicates this is slower than (bits[i] & bitmask) != 0; + // testing on a P4 indicates this is slower than (bits[i] & bitMask) != 0; } */ @@ -319,8 +329,8 @@ namespace Lucene.Net.Util { int wordNum = ExpandingWordNum(index); int bit = (int)index & 0x3f; - long bitmask = 1L << bit; - bits[wordNum] |= bitmask; + long bitMask = 1L << bit; + bits[wordNum] |= bitMask; } /// @@ -332,8 +342,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] |= bitmask; + long bitMask = 1L << bit; + bits[wordNum] |= bitMask; } /// @@ -345,8 +355,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = (int)(index >> 6); int bit = (int)index & 0x3f; - long bitmask = 1L << bit; - bits[wordNum] |= bitmask; + long bitMask = 1L << bit; + bits[wordNum] |= bitMask; } /// @@ -367,18 +377,18 @@ namespace Lucene.Net.Util // word to be changed. int endWord = ExpandingWordNum(endIndex - 1); - long startmask = -1L << (int)startIndex; - long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap + long startMask = -1L << (int)startIndex; + long endMask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap if (startWord == endWord) { - bits[startWord] |= (startmask & endmask); + bits[startWord] |= (startMask & endMask); return; } - bits[startWord] |= startmask; + bits[startWord] |= startMask; bits.Fill(startWord + 1, endWord, -1L); - bits[endWord] |= endmask; + bits[endWord] |= endMask; } protected internal virtual int ExpandingWordNum(long index) @@ -400,8 +410,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = index >> 6; int bit = index & 0x03f; - long bitmask = 1L << bit; - bits[wordNum] &= ~bitmask; + long bitMask = 1L << bit; + bits[wordNum] &= ~bitMask; // hmmm, it takes one more instruction to clear than it does to set... any // way to work around this? If there were only 63 bits per word, we could // use a right shift of 10111111...111 in binary to position the 0 in the @@ -420,8 +430,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = (int)(index >> 6); // div 64 int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] &= ~bitmask; + long bitMask = 1L << bit; + bits[wordNum] &= ~bitMask; } /// @@ -434,8 +444,8 @@ namespace Lucene.Net.Util return; } int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] &= ~bitmask; + long bitMask = 1L << bit; + bits[wordNum] &= ~bitMask; } /// @@ -461,26 +471,26 @@ namespace Lucene.Net.Util int endWord = ((endIndex - 1) >> 6); //LUCENE TO-DO - long startmask = -1L << startIndex; - long endmask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap + long startMask = -1L << startIndex; + long endMask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap // invert masks since we are clearing - startmask = ~startmask; - endmask = ~endmask; + startMask = ~startMask; + endMask = ~endMask; if (startWord == endWord) { - bits[startWord] &= (startmask | endmask); + bits[startWord] &= (startMask | endMask); return; } - bits[startWord] &= startmask; + bits[startWord] &= startMask; int middle = Math.Min(wordLength, endWord); bits.Fill(startWord + 1, middle, 0L); if (endWord < wordLength) { - bits[endWord] &= endmask; + bits[endWord] &= endMask; } } @@ -507,26 +517,26 @@ namespace Lucene.Net.Util int endWord = (int)((endIndex - 1) >> 6); //LUCENE TO-DO - long startmask = -1L << (int)startIndex; - long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap + long startMask = -1L << (int)startIndex; + long endMask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap // invert masks since we are clearing - startmask = ~startmask; - endmask = ~endmask; + startMask = ~startMask; + endMask = ~endMask; if (startWord == endWord) { - bits[startWord] &= (startmask | endmask); + bits[startWord] &= (startMask | endMask); return; } - bits[startWord] &= startmask; + bits[startWord] &= startMask; int middle = Math.Min(wordLength, endWord); bits.Fill(startWord + 1, middle, 0L); if (endWord < wordLength) { - bits[endWord] &= endmask; + bits[endWord] &= endMask; } } @@ -539,9 +549,9 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bool val = (bits[wordNum] & bitmask) != 0; - bits[wordNum] |= bitmask; + long bitMask = 1L << bit; + bool val = (bits[wordNum] & bitMask) != 0; + bits[wordNum] |= bitMask; return val; } @@ -554,9 +564,9 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = (int)(index >> 6); // div 64 int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bool val = (bits[wordNum] & bitmask) != 0; - bits[wordNum] |= bitmask; + long bitMask = 1L << bit; + bool val = (bits[wordNum] & bitMask) != 0; + bits[wordNum] |= bitMask; return val; } @@ -569,8 +579,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] ^= bitmask; + long bitMask = 1L << bit; + bits[wordNum] ^= bitMask; } /// @@ -582,8 +592,8 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = (int)(index >> 6); // div 64 int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] ^= bitmask; + long bitMask = 1L << bit; + bits[wordNum] ^= bitMask; } /// @@ -592,8 +602,8 @@ namespace Lucene.Net.Util { int wordNum = ExpandingWordNum(index); int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] ^= bitmask; + long bitMask = 1L << bit; + bits[wordNum] ^= bitMask; } /// @@ -605,9 +615,9 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] ^= bitmask; - return (bits[wordNum] & bitmask) != 0; + long bitMask = 1L << bit; + bits[wordNum] ^= bitMask; + return (bits[wordNum] & bitMask) != 0; } /// @@ -619,9 +629,9 @@ namespace Lucene.Net.Util Debug.Assert(index >= 0 && index < numBits); int wordNum = (int)(index >> 6); // div 64 int bit = (int)index & 0x3f; // mod 64 - long bitmask = 1L << bit; - bits[wordNum] ^= bitmask; - return (bits[wordNum] & bitmask) != 0; + long bitMask = 1L << bit; + bits[wordNum] ^= bitMask; + return (bits[wordNum] & bitMask) != 0; } /// @@ -650,23 +660,23 @@ namespace Lucene.Net.Util //LUCENE TO-DO - long startmask = -1L << (int)startIndex; - long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap + long startMask = -1L << (int)startIndex; + long endMask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap if (startWord == endWord) { - bits[startWord] ^= (startmask & endmask); + bits[startWord] ^= (startMask & endMask); return; } - bits[startWord] ^= startmask; + bits[startWord] ^= startMask; for (int i = startWord + 1; i < endWord; i++) { bits[i] = ~bits[i]; } - bits[endWord] ^= endmask; + bits[endWord] ^= endMask; } /* @@ -922,7 +932,7 @@ namespace Lucene.Net.Util public object Clone(bool deepCopy = true) { if (!deepCopy) - return new OpenBitSet((long[])this.bits.Copy(), this.wordLength); + return new OpenBitSet(this.bits.Copy(), this.wordLength); try { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Check.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Check.cs b/src/Lucene.Net.Java/Check.cs new file mode 100644 index 0000000..4439dac --- /dev/null +++ b/src/Lucene.Net.Java/Check.cs @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +namespace Java +{ + using System; + using System.Collections.Generic; + + internal class Check + { + + internal static void NotNull(string argument, T value, string message = null, params object[] args) where T : class + { + if (value == null) + { + if (message == null) + message = string.Format("The parameter, {0}, must not be null.", argument); + + if (args != null && args.Length > 0) + message = string.Format(message, args); + + + throw new ArgumentNullException(argument, message); + } + } + + internal static void Range(string argument, IList value, int start, int count) + { + if(start < 0) + throw new ArgumentOutOfRangeException("start", "The parameter, start, must be 0 or greater."); + + if(start >= value.Count) + throw new ArgumentOutOfRangeException("start", string.Format("The parameter, start, must not be equal or greater than {0}'s length.", argument)); + + if (count < 0) + throw new ArgumentOutOfRangeException("count", "The parameter, count, must be 0 or greater."); + + if (count > value.Count) + throw new ArgumentOutOfRangeException("count", string.Format("The parameter, count, must not be greater than {0}'s length.", argument)); + + if(start + count > value.Count) + throw new ArgumentOutOfRangeException("value,count", string.Format("The sum of start and count must not be greater than {0}'s length", argument)); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lang/Int.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Lang/Int.cs b/src/Lucene.Net.Java/Lang/Int.cs new file mode 100644 index 0000000..abf5248 --- /dev/null +++ b/src/Lucene.Net.Java/Lang/Int.cs @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Java.Lang +{ + public class Int + { + + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lang/Long.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Lang/Long.cs b/src/Lucene.Net.Java/Lang/Long.cs new file mode 100644 index 0000000..c532c84 --- /dev/null +++ b/src/Lucene.Net.Java/Lang/Long.cs @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Java.Lang +{ + using System; + + public class Long + { + public const int SIZE = 64; + + private static class DeBruijn64 + { + private static readonly int[] POSITIONS = + { + 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, + 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, + 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10, + 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12 + }; + + public static int Position(long value) + { + var v = value; + + return POSITIONS[(v & -v) * 0x022fdd63cc95386d >> 58]; + } + } + + + + + + /// + /// Returns the leading zeros from the value. + /// + /// The value. + /// System.Int32. + public static int NumberOfLeadingZeros(long value) + { + return (int)NumberOfLeadingZeros((ulong)value); + } + + /// + /// Returns the leading zeros from the value. + /// + /// The value. + /// System.UInt32. + [CLSCompliant(false)] + public static uint NumberOfLeadingZeros(ulong value) + { + if (value == 0) + return 64; + uint number = 1; + var test = value >> 32; + + + if (test == 0) + { + number += 32; + test = (uint)value; + } + + if (test >> 16 == 0) + { + number += 16; + test <<= 16; + } + + if (test >> 24 == 0) + { + number += 8; + test <<= 8; + } + + if (test >> 28 == 0) + { + number += 4; + test <<= 4; + } + + if (test >> 30 == 0) + { + number += 2; + test <<= 2; + } + number -= (uint)test >> 31; + + return number; + } + + // ReSharper disable once CSharpWarnings::CS1584 + /// + /// Returns the number of trailing zeros. i.e 100 has two trailing zeros. + /// + /// The value to be inspected for trailing zeros. + /// + /// + /// We're using the De Bruijn sequences based upon the various bit twiddling hacks found in + + /// an online paper stanford + /// + /// + /// It should be faster than Java's native + /// + /// Long.numberOfTrailingZeros + /// which uses the binary search method of finding trailing zeros. + /// + /// + /// The number of trailing zeros. + public static int NumberOfTrailingZeros(long value) + { + return DeBruijn64.Position(value); + } + + public static long RotateLeft(long value, int shift) + { + return (long)RotateLeft((ulong) value, shift); + } + + [CLSCompliant(false)] + public static ulong RotateLeft(ulong value, int shift) + { + return (value << shift) | (value >> -shift); + } + + + public static long RotateRight(long value, int shift) + { + return (long)RotateRight((ulong) value, shift); + } + + [CLSCompliant(false)] + public static ulong RotateRight(ulong value, int shift) + { + return (value >> shift) | (value << -shift); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lang/String.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Lang/String.cs b/src/Lucene.Net.Java/Lang/String.cs new file mode 100644 index 0000000..c27d07a --- /dev/null +++ b/src/Lucene.Net.Java/Lang/String.cs @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Java.Lang +{ + using System; + using System.Collections.Generic; + + public class String : IEnumerable + { + private readonly char[] value; + + + public String() + { + this.value = new char[0]; + } + + public String(string value) + { + this.value = value.ToCharArray(); + } + + public String(char[] value) + { + this.value = value; + } + + public static explicit operator String(string value) + { + return new String(value); + } + + public static explicit operator String(char[] value) + { + return new String(value); + } + + + public int Length + { + get { return this.value.Length; } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return new CharEnumerator(this.value); + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return new CharEnumerator(this.value); + } + + + private class CharEnumerator : IEnumerator + { + private char[] values; + private int position; + + public CharEnumerator(char[] values) + { + this.values = values; + this.position = -1; + } + + public char Current + { + get { return this.values[this.position]; } + } + + object System.Collections.IEnumerator.Current + { + get { return this.Current; } + } + + public bool MoveNext() + { + return this.position++ < this.values.Length; + + } + + public void Reset() + { + this.position = -1; + } + + public void Dispose() + { + GC.SuppressFinalize(this); + this.Dispose(true); + } + + private void Dispose(bool disposing) + { + if(!disposing) + return; + + this.values = null; + } + + ~CharEnumerator() + { + this.Dispose(false); + } + } + + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lucene.Net.Java.csproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Lucene.Net.Java.csproj b/src/Lucene.Net.Java/Lucene.Net.Java.csproj new file mode 100644 index 0000000..2a13128 --- /dev/null +++ b/src/Lucene.Net.Java/Lucene.Net.Java.csproj @@ -0,0 +1,60 @@ + + + + + 10.0 + Debug + AnyCPU + {4AD3FE35-AA0A-4C3C-A043-12711625DF74} + Library + Properties + Java + Lucene.Net.Java + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile259 + v4.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lucene.Net.Java.kproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Lucene.Net.Java.kproj b/src/Lucene.Net.Java/Lucene.Net.Java.kproj new file mode 100644 index 0000000..af2ce9d --- /dev/null +++ b/src/Lucene.Net.Java/Lucene.Net.Java.kproj @@ -0,0 +1,56 @@ + + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + caf32bea-5560-4e4a-a81f-11aa377f9929 + Library + Java + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Properties/AssemblyInfo.cs b/src/Lucene.Net.Java/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..42c05a0 --- /dev/null +++ b/src/Lucene.Net.Java/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System; +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +#if PORTABLE +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyTitle("Lucene.Net.Java")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Lucene.Net.Java")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] +#endif + +[assembly: CLSCompliant(true)] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Readme.md ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Readme.md b/src/Lucene.Net.Java/Readme.md new file mode 100644 index 0000000..c24d559 --- /dev/null +++ b/src/Lucene.Net.Java/Readme.md @@ -0,0 +1,16 @@ +# Lucene.Net.Java + +This project is a spin off of the Support folder of Lucene.Net. There is enough low level functionality +that the standard Java library has that is not found in .NET to warrant a separate assembly. + +Creating a separate project will let the .NET community leverage the functionality +without a required dependency to all of Lucene.Net. There is most likely similar +functionality in IVKM.NET, however, it's JDK falls under GPL v2 which is not compatible with +the Apache 2.0 License. + +The root namespace of the projeect is Java and not Lucene.Net.Java, so +that its easier to convert code with the namespaces. + +There will still be differences between this library and the Java implementation. The goal is to match the Java API +when possible while still using the correct .NET idioms. There are also differences in runtimes that will allow for +a simplified API with generics. [Comparing Generics Java and C#](http://www.jprl.com/Blog/archive/development/2007/Aug-31.html) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Util/Arrays.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Util/Arrays.cs b/src/Lucene.Net.Java/Util/Arrays.cs new file mode 100644 index 0000000..083f6f0 --- /dev/null +++ b/src/Lucene.Net.Java/Util/Arrays.cs @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Java.Util +{ + using System; + using System.Collections.Generic; + + public static class Arrays + { + + public static void Fill(IList list, Func factory) + { + Fill(list, 0, list.Count, factory); + } + + public static void Fill(IList list, int start, int count, Func factory) + { + for (var i = start; i < count; i++) + list[i] = factory(); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs b/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs new file mode 100644 index 0000000..d880c1a --- /dev/null +++ b/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs @@ -0,0 +1,1090 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Java.Util +{ + using System; + using System.Collections.Generic; + + // ReSharper disable CSharpWarnings::CS1574 + /// + /// A .NET implementation of Valdimir Yaroslavskiy's Dual-Pivot Quicksort + /// + /// + /// + /// The overloaded methods are to avoid the extra compare operations for + /// known value types: ,, + /// , and . + /// can be used for all other types + /// that implement . + /// + /// + // ReSharper disable FunctionRecursiveOnAllPaths + public class DualPivotQuicksort + { + private const int DIST_SIZE = 13; + + + + private static void Swap(IList array, int left, int right) + { + var reference = array[left]; + array[left] = array[right]; + array[right] = reference; + } + + public static IList Sort(IList list) + { + Check.NotNull("list", list); + + PerformSort(list, 0, list.Count); + + return list; + } + + public static IList Sort(IList list, int start, int count) + { + Check.NotNull("list", list); + Check.Range("list", list, start, count); + + PerformSort(list, start, count); + + return list; + } + + private static void PerformSort(IList array, int left, int right) + { + int length = right - left, + x, + pivot1, + pivot2; + + + + int sixth = length/6, + m1 = left + sixth, + m2 = m1 + sixth, + m3 = m2 + sixth, + m4 = m3 + sixth, + m5 = m4 + sixth; + + if (array[m1] > array[m2]) + Swap(array, m1, m2); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + if (array[m1] > array[m3]) + Swap(array, m1, m3); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m1] > array[m4]) + Swap(array, m2, m4); + + if (array[m3] > array[m4]) + Swap(array, m3, m4); + + if (array[m2] > array[m5]) + Swap(array, m2, m5); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + pivot1 = array[m2]; + pivot2 = array[m4]; + + var pivotsAreDifferent = pivot1 != pivot2; + + array[m2] = array[left]; + array[m4] = array[right]; + + int less = left + 1, + great = right - 1; + + if (pivotsAreDifferent) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + else + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + continue; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + array[left] = array[less - 1]; + array[left - 1] = pivot1; + + array[right] = array[great + 1]; + array[great + 1] = pivot2; + + PerformSort(array, left, less - 2); + PerformSort(array, great + 1, right); + + if (!pivotsAreDifferent) + return; + + + if (great - less > length - DIST_SIZE) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x == pivot2) + { + array[k] = array[great]; + array[great--] = x; + x = array[k]; + + + if (x != pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + PerformSort(array, less, great); + } + + + public static IList Sort(IList list) + { + Check.NotNull("list", list); + + PerformSort(list, 0, list.Count); + + return list; + } + + public static IList Sort(IList list, int start, int count) + { + Check.NotNull("list", list); + Check.Range("list", list, start, count); + + PerformSort(list, start, count); + + return list; + } + + private static void PerformSort(IList array, int left, int right) + { + int length = right - left; + char x, + pivot1, + pivot2; + + + + int sixth = length/6, + m1 = left + sixth, + m2 = m1 + sixth, + m3 = m2 + sixth, + m4 = m3 + sixth, + m5 = m4 + sixth; + + if (array[m1] > array[m2]) + Swap(array, m1, m2); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + if (array[m1] > array[m3]) + Swap(array, m1, m3); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m1] > array[m4]) + Swap(array, m2, m4); + + if (array[m3] > array[m4]) + Swap(array, m3, m4); + + if (array[m2] > array[m5]) + Swap(array, m2, m5); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + pivot1 = array[m2]; + pivot2 = array[m4]; + + bool pivotsAreDifferent = pivot1 != pivot2; + + array[m2] = array[left]; + array[m4] = array[right]; + + int less = left + 1, + great = right - 1; + + if (pivotsAreDifferent) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + else + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + continue; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + array[left] = array[less - 1]; + array[left - 1] = pivot1; + + array[right] = array[great + 1]; + array[great + 1] = pivot2; + + PerformSort(array, left, less - 2); + PerformSort(array, great + 1, right); + + if (!pivotsAreDifferent) + return; + + + if (great - less > length - DIST_SIZE) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x == pivot2) + { + array[k] = array[great]; + array[great--] = x; + x = array[k]; + + + if (x != pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + PerformSort(array, less, great); + } + + public static IList Sort(IList list) + { + Check.NotNull("list", list); + PerformSort(list, 0, list.Count); + return list; + } + + public static IList Sort(IList list, int start, int count) + { + Check.NotNull("list", list); + Check.Range("list", list, start, count); + PerformSort(list, start, count); + return list; + } + + private static void PerformSort(IList array, int left, int right) + { + var length = right - left; + short x, + pivot1, + pivot2; + + + + int sixth = length/6, + m1 = left + sixth, + m2 = m1 + sixth, + m3 = m2 + sixth, + m4 = m3 + sixth, + m5 = m4 + sixth; + + if (array[m1] > array[m2]) + Swap(array, m1, m2); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + if (array[m1] > array[m3]) + Swap(array, m1, m3); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m1] > array[m4]) + Swap(array, m2, m4); + + if (array[m3] > array[m4]) + Swap(array, m3, m4); + + if (array[m2] > array[m5]) + Swap(array, m2, m5); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + pivot1 = array[m2]; + pivot2 = array[m4]; + + bool pivotsAreDifferent = pivot1 != pivot2; + + array[m2] = array[left]; + array[m4] = array[right]; + + int less = left + 1, + great = right - 1; + + if (pivotsAreDifferent) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + else + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + continue; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + array[left] = array[less - 1]; + array[left - 1] = pivot1; + + array[right] = array[great + 1]; + array[great + 1] = pivot2; + + PerformSort(array, left, less - 2); + PerformSort(array, great + 1, right); + + if (!pivotsAreDifferent) + return; + + + if (great - less > length - DIST_SIZE) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x == pivot2) + { + array[k] = array[great]; + array[great--] = x; + x = array[k]; + + + if (x != pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + PerformSort(array, less, great); + } + + + public static IList Sort(IList list, int start, int count) + { + Check.NotNull("list", list); + Check.Range("list", list, start, count); + + PerformSort(list, start, count); + + return list; + } + + internal static void PerformSort(IList array, int left, int right) + { + int length = right - left; + byte x, + pivot1, + pivot2; + + + + int sixth = length/6, + m1 = left + sixth, + m2 = m1 + sixth, + m3 = m2 + sixth, + m4 = m3 + sixth, + m5 = m4 + sixth; + + if (array[m1] > array[m2]) + Swap(array, m1, m2); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + if (array[m1] > array[m3]) + Swap(array, m1, m3); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m1] > array[m4]) + Swap(array, m2, m4); + + if (array[m3] > array[m4]) + Swap(array, m3, m4); + + if (array[m2] > array[m5]) + Swap(array, m2, m5); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + pivot1 = array[m2]; + pivot2 = array[m4]; + + bool pivotsAreDifferent = pivot1 != pivot2; + + array[m2] = array[left]; + array[m4] = array[right]; + + int less = left + 1, + great = right - 1; + + if (pivotsAreDifferent) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + else + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + continue; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + array[left] = array[less - 1]; + array[left - 1] = pivot1; + + array[right] = array[great + 1]; + array[great + 1] = pivot2; + + PerformSort(array, left, less - 2); + PerformSort(array, great + 1, right); + + if (!pivotsAreDifferent) + return; + + + if (great - less > length - DIST_SIZE) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x == pivot2) + { + array[k] = array[great]; + array[great--] = x; + x = array[k]; + + + if (x != pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + PerformSort(array, less, great); + } + + public static long[] Sort(long[] array) + { + Check.NotNull("array", array); + PerformSort(array, 0, array.Length); + return array; + } + + public static long[] Sort(long[] array, int start, int count) + { + Check.NotNull("array", array); + Check.Range("array", array, start, count); + PerformSort(array, start, count); + return array; + } + + + internal static void PerformSort(long[] array, int left, int right) + { + int length = right - left; + long x, + pivot1, + pivot2; + + + + int sixth = length/6, + m1 = left + sixth, + m2 = m1 + sixth, + m3 = m2 + sixth, + m4 = m3 + sixth, + m5 = m4 + sixth; + + if (array[m1] > array[m2]) + Swap(array, m1, m2); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + if (array[m1] > array[m3]) + Swap(array, m1, m3); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m1] > array[m4]) + Swap(array, m2, m4); + + if (array[m3] > array[m4]) + Swap(array, m3, m4); + + if (array[m2] > array[m5]) + Swap(array, m2, m5); + + if (array[m2] > array[m3]) + Swap(array, m2, m3); + + if (array[m4] > array[m5]) + Swap(array, m4, m5); + + pivot1 = array[m2]; + pivot2 = array[m4]; + + bool pivotsAreDifferent = pivot1 != pivot2; + + array[m2] = array[left]; + array[m4] = array[right]; + + int less = left + 1, + great = right - 1; + + if (pivotsAreDifferent) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + else + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + continue; + + if (x < pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x > pivot2) + { + while (array[great] > pivot2 && k < great) + { + great--; + } + Swap(array, k, great--); + + if (x >= pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + array[left] = array[less - 1]; + array[left - 1] = pivot1; + + array[right] = array[great + 1]; + array[great + 1] = pivot2; + + PerformSort(array, left, less - 2); + PerformSort(array, great + 1, right); + + if (!pivotsAreDifferent) + return; + + + if (great - less > length - DIST_SIZE) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x == pivot1) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x == pivot2) + { + array[k] = array[great]; + array[great--] = x; + x = array[k]; + + + if (x != pivot1) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + PerformSort(array, less, great); + } + + private static bool LessThan(T left, T right) where T : IComparable + { + return left.CompareTo(right) < 0; + } + + private static bool GreaterThan(T left, T right) where T : IComparable + { + return left.CompareTo(right) > 0; + } + + private static bool GreaterThanOrEqualTo(T left, T right) where T : IComparable + { + var compare = left.CompareTo(right); + return compare > 0 || compare == 0; + } + + public static IList Sort(IList list) where T: IComparable + { + Check.NotNull("array", list); + PerformSort(list, 0, list.Count); + + return list; + } + + public static IList Sort(IList list, int start, int count) where T: IComparable + { + Check.NotNull("array", list); + Check.Range("array", list, start, count); + PerformSort(list, start, count); + + return list; + } + + + internal static void PerformSort(IList array, int left, int right) where T: IComparable + { + int length = right - left; + T x, pivot2, pivot1; + + + + int sixth = length / 6, + m1 = left + sixth, + m2 = m1 + sixth, + m3 = m2 + sixth, + m4 = m3 + sixth, + m5 = m4 + sixth; + + if (GreaterThan(array[m1] , array[m2])) + Swap(array, m1, m2); + + if (GreaterThan(array[m4] , array[m5])) + Swap(array, m4, m5); + + if (GreaterThan(array[m1] , array[m3])) + Swap(array, m1, m3); + + if (GreaterThan(array[m2], array[m3])) + Swap(array, m2, m3); + + if (GreaterThan(array[m1], array[m4])) + Swap(array, m2, m4); + + if (GreaterThan(array[m3], array[m4])) + Swap(array, m3, m4); + + if (GreaterThan(array[m2], array[m5])) + Swap(array, m2, m5); + + if (GreaterThan(array[m2],array[m3])) + Swap(array, m2, m3); + + if (GreaterThan(array[m4], array[m5])) + Swap(array, m4, m5); + + pivot1 = array[m2]; + pivot2 = array[m4]; + + bool pivotsAreDifferent = !pivot1.Equals(pivot2); + + array[m2] = array[left]; + array[m4] = array[right]; + + int less = left + 1, + great = right - 1; + + if (pivotsAreDifferent) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (LessThan(x , pivot1)) + { + array[k] = array[less]; + array[less++] = x; + } + else if (GreaterThan(x , pivot2)) + { + while (GreaterThan(array[great] , pivot2) && LessThan(k , great)) + { + great--; + } + Swap(array, k, great--); + + if (GreaterThanOrEqualTo(x , pivot1)) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + else + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (LessThan(x, pivot1)) + { + array[k] = array[less]; + array[less++] = x; + } + else if (GreaterThan(x, pivot2)) + { + while (GreaterThan(array[great], pivot2) && LessThan(k, great)) + { + great--; + } + Swap(array, k, great--); + + if (GreaterThanOrEqualTo(x, pivot1)) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + array[left] = array[less - 1]; + array[left - 1] = pivot1; + + array[right] = array[great + 1]; + array[great + 1] = pivot2; + + PerformSort(array, left, less - 2); + PerformSort(array, great + 1, right); + + if (!pivotsAreDifferent) + return; + + + if (great - less > length - DIST_SIZE) + { + for (var k = less; k <= great; k++) + { + x = array[k]; + + if (x.Equals(pivot1)) + { + array[k] = array[less]; + array[less++] = x; + } + else if (x.Equals(pivot2)) + { + array[k] = array[great]; + array[great--] = x; + x = array[k]; + + + if (! x.Equals(pivot1)) + continue; + + array[k] = array[less]; + array[less++] = x; + } + } + } + + PerformSort(array, less, great); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Util/InsertionSort.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/Util/InsertionSort.cs b/src/Lucene.Net.Java/Util/InsertionSort.cs new file mode 100644 index 0000000..5e27c58 --- /dev/null +++ b/src/Lucene.Net.Java/Util/InsertionSort.cs @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Java.Util +{ + using System; + using System.Collections.Generic; + + public static class InsertionSort + { + + + + private static void Swap(IList list,int left , int right ) + { + var reference = list[left]; + list[left] = list[right]; + list[right] = reference; + } + + + + + public static IList Sort(IList list) where T : IComparable + { + Check.NotNull("list", list); + + return PerformSort(list, 0, list.Count); + } + + public static IList Sort(IList list, int start, int count)where T: IComparable + { + Check.NotNull("list", list); + Check.Range("list", list, start, count); + + return PerformSort(list, start, count); + } + + internal static IList PerformSort(IList list, int start, int count) where T: IComparable + { + for (var i = start + 1; i < count; i++) + { + + for (var j = i; j > start && list[j - 1].CompareTo(list[j]) >= 0; j--) + { + // swap + Swap(list, j - 1, j); + } + } + + return list; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/default.ruleset ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/default.ruleset b/src/Lucene.Net.Java/default.ruleset new file mode 100644 index 0000000..7770345 --- /dev/null +++ b/src/Lucene.Net.Java/default.ruleset @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/packages.config ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/packages.config b/src/Lucene.Net.Java/packages.config new file mode 100644 index 0000000..786c80f --- /dev/null +++ b/src/Lucene.Net.Java/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/project.json ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Java/project.json b/src/Lucene.Net.Java/project.json new file mode 100644 index 0000000..5a7cce8 --- /dev/null +++ b/src/Lucene.Net.Java/project.json @@ -0,0 +1,20 @@ +{ + "licenses": [ "apache 2.0" ], + "version": "5.0.0.0", + "configurations" : { + "net451" : { + "dependencies": { + } + }, + "k10" : { + "dependencies": { + "System.Linq": "", + "System.Reflection": "", + "System.Runtime": "", + "System.Reflection.Extensions": "", + "System.Text.RegularExpressions": "", + "System.Diagnostics.Debug": "" + } + } + } +}