You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by mh...@apache.org on 2014/08/09 05:46:28 UTC

[1/2] git commit: adding BitUtil.cs

Repository: lucenenet
Updated Branches:
  refs/heads/pcl 2c8e873b4 -> a5d9e83f8


adding BitUtil.cs


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/477b922b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/477b922b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/477b922b

Branch: refs/heads/pcl
Commit: 477b922bcc8892fe6f367d0fc191eca8f43ec1fd
Parents: 2c8e873
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Fri Aug 8 19:38:59 2014 -0400
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Fri Aug 8 19:38:59 2014 -0400

----------------------------------------------------------------------
 Lucene.vs2013.sln                   |  68 ++++++
 src/Lucene.Net.Core/Util/BitUtil.cs | 353 +++++++++++++++++++++++++++++++
 2 files changed, 421 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/477b922b/Lucene.vs2013.sln
----------------------------------------------------------------------
diff --git a/Lucene.vs2013.sln b/Lucene.vs2013.sln
new file mode 100644
index 0000000..c9972ff
--- /dev/null
+++ b/Lucene.vs2013.sln
@@ -0,0 +1,68 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C90AB34C-AFCE-4CA1-8AB6-F25FC241639C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E7E53642-2EDA-49CE-B730-95242CCF608D}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Lucene.Net.TestFramework", "test\Lucene.Net.TestFramework\Lucene.Net.TestFramework.kproj", "{E8C34852-CE11-4CD0-A34A-E777B0BD705A}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Lucene.Net.Core", "src\Lucene.Net.Core\Lucene.Net.Core.kproj", "{CAF32BEA-5560-4E4A-A81F-11AA377F9929}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Lucene.Net.Core.Tests", "test\Lucene.Net.Core.Tests\Lucene.Net.Core.Tests.kproj", "{46467889-DCDD-4E2B-B583-6AACCE996EAC}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "portable-src", "portable-src", "{CD84C1EF-B845-4914-A9DD-D0F9ACC7DE6F}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "portable-test", "portable-test", "{4B0484AA-03E4-47A5-9989-AC42DDE1E06B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Core", "src\Lucene.Net.Core\Lucene.Net.Core.csproj", "{AD8901C0-209D-4132-80AA-257DBACEECB4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.TestFramework", "test\Lucene.Net.TestFramework\Lucene.Net.TestFramework.csproj", "{F0D68FEA-B118-43B6-B760-3FB75CDE766D}"
+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
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Release|Any CPU.Build.0 = Release|Any CPU
+		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F0D68FEA-B118-43B6-B760-3FB75CDE766D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F0D68FEA-B118-43B6-B760-3FB75CDE766D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F0D68FEA-B118-43B6-B760-3FB75CDE766D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F0D68FEA-B118-43B6-B760-3FB75CDE766D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{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
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{E8C34852-CE11-4CD0-A34A-E777B0BD705A} = {E7E53642-2EDA-49CE-B730-95242CCF608D}
+		{CAF32BEA-5560-4E4A-A81F-11AA377F9929} = {C90AB34C-AFCE-4CA1-8AB6-F25FC241639C}
+		{46467889-DCDD-4E2B-B583-6AACCE996EAC} = {E7E53642-2EDA-49CE-B730-95242CCF608D}
+		{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}
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/477b922b/src/Lucene.Net.Core/Util/BitUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BitUtil.cs b/src/Lucene.Net.Core/Util/BitUtil.cs
new file mode 100644
index 0000000..bb2e8e9
--- /dev/null
+++ b/src/Lucene.Net.Core/Util/BitUtil.cs
@@ -0,0 +1,353 @@
+/*
+ * 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 Lucene.Net.Util
+{
+
+    /// <summary>
+    ///  A variety of high efficiency bit twiddling routines.
+    ///  </summary>
+    public static class BitUtil
+    {
+        /// <summary>
+        /// table of bytes
+        /// </summary>
+        private static readonly byte[] BYTE_COUNTS = new byte[] {
+            0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 
+            1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 
+            1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 
+            2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 
+            1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 
+            2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 
+            2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 
+            3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 
+            1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 
+            2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 
+            2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 
+            3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 
+            2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 
+            3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 
+            3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 
+            4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; 
+
+        // 
+        /// <summary>
+        ///The General Idea: instead of having an array per byte that has
+        /// the offsets of the next set bit, that array could be
+        /// packed inside a 32 bit integer (8 4 bit numbers).  That
+        /// should be faster than accessing an array for each index, and
+        /// the total array size is kept smaller (256*sizeof(int))=1K
+        /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///         <code language="python">
+        ///             *** the python code that generated bitlist
+        /// def bits2int(val):
+        ///     arr=0
+        ///     for shift in range(8,0,-1):
+        ///     if val & 0x80:
+        ///         arr = (arr << 4) | shift
+        ///     val = val << 1
+        ///     return arr
+        ///
+        /// def int_table():
+        ///     tbl = [ hex(bits2int(val)).strip('L') for val in range(256) ]
+        ///     return ','.join(tbl)
+        /// 
+        ///         </code>
+        ///     </para>
+        ///     <para>
+        ///         0x87654321 converts to unint, so an unchecked conversion to int is required. 
+        ///     </para>
+        /// </remarks>
+        private static readonly int[] BIT_LISTS = new int[] { 
+          0x0, 0x1, 0x2, 0x21, 0x3, 0x31, 0x32, 0x321, 0x4, 0x41, 0x42, 0x421, 0x43, 
+            0x431, 0x432, 0x4321, 0x5, 0x51, 0x52, 0x521, 0x53, 0x531, 0x532, 0x5321, 
+            0x54, 0x541, 0x542, 0x5421, 0x543, 0x5431, 0x5432, 0x54321, 0x6, 0x61, 0x62, 
+            0x621, 0x63, 0x631, 0x632, 0x6321, 0x64, 0x641, 0x642, 0x6421, 0x643, 
+            0x6431, 0x6432, 0x64321, 0x65, 0x651, 0x652, 0x6521, 0x653, 0x6531, 0x6532, 
+            0x65321, 0x654, 0x6541, 0x6542, 0x65421, 0x6543, 0x65431, 0x65432, 0x654321, 
+            0x7, 0x71, 0x72, 0x721, 0x73, 0x731, 0x732, 0x7321, 0x74, 0x741, 0x742,
+            0x7421, 0x743, 0x7431, 0x7432, 0x74321, 0x75, 0x751, 0x752, 0x7521, 0x753, 
+            0x7531, 0x7532, 0x75321, 0x754, 0x7541, 0x7542, 0x75421, 0x7543, 0x75431, 
+            0x75432, 0x754321, 0x76, 0x761, 0x762, 0x7621, 0x763, 0x7631, 0x7632, 
+            0x76321, 0x764, 0x7641, 0x7642, 0x76421, 0x7643, 0x76431, 0x76432, 0x764321, 
+            0x765, 0x7651, 0x7652, 0x76521, 0x7653, 0x76531, 0x76532, 0x765321, 0x7654, 
+            0x76541, 0x76542, 0x765421, 0x76543, 0x765431, 0x765432, 0x7654321, 0x8, 
+            0x81, 0x82, 0x821, 0x83, 0x831, 0x832, 0x8321, 0x84, 0x841, 0x842, 0x8421, 
+            0x843, 0x8431, 0x8432, 0x84321, 0x85, 0x851, 0x852, 0x8521, 0x853, 0x8531, 
+            0x8532, 0x85321, 0x854, 0x8541, 0x8542, 0x85421, 0x8543, 0x85431, 0x85432, 
+            0x854321, 0x86, 0x861, 0x862, 0x8621, 0x863, 0x8631, 0x8632, 0x86321, 0x864, 
+            0x8641, 0x8642, 0x86421, 0x8643, 0x86431, 0x86432, 0x864321, 0x865, 0x8651, 
+            0x8652, 0x86521, 0x8653, 0x86531, 0x86532, 0x865321, 0x8654, 0x86541, 
+            0x86542, 0x865421, 0x86543, 0x865431, 0x865432, 0x8654321, 0x87, 0x871, 
+            0x872, 0x8721, 0x873, 0x8731, 0x8732, 0x87321, 0x874, 0x8741, 0x8742, 
+            0x87421, 0x8743, 0x87431, 0x87432, 0x874321, 0x875, 0x8751, 0x8752, 0x87521, 
+            0x8753, 0x87531, 0x87532, 0x875321, 0x8754, 0x87541, 0x87542, 0x875421, 
+            0x87543, 0x875431, 0x875432, 0x8754321, 0x876, 0x8761, 0x8762, 0x87621, 
+            0x8763, 0x87631, 0x87632, 0x876321, 0x8764, 0x87641, 0x87642, 0x876421, 
+            0x87643, 0x876431, 0x876432, 0x8764321, 0x8765, 0x87651, 0x87652, 0x876521, 
+            0x87653, 0x876531, 0x876532, 0x8765321, 0x87654, 0x876541, 0x876542, 
+            0x8765421, 0x876543, 0x8765431, 0x8765432, unchecked((int)0x87654321)
+       };
+
+        /// <summary>
+        /// Gets the number of bits sets in the <paramref name="value"/>.
+        /// </summary>
+        /// <param name="value">A byte.</param>
+        /// <returns>The number of bits.</returns>
+        public static int BitCount(byte value)
+        {
+            return BYTE_COUNTS[value & 0xFF];
+        }
+
+
+        /// <summary>
+        /// Gets the number of bits which are encoded in <paramref name="value"/> .
+        /// </summary>
+        /// <remarks>
+        ///     <list>
+        ///     <item>
+        ///         <code>(i >>> (4 * n)) & 0x0F</code> is the offset of the n-th set bit of the given 
+        ///         byte. For example <see cref="GetBiteList"/>(12) returns 0x43.
+        ///     </item>
+        ///     <item>
+        ///         <code>0x43 & 0x0F</code> is 3, meaning the the first bit set is at offset 3-1 = 2.
+        ///     </item>
+        ///     <item>
+        ///         <code>(0x43 >>> 4) & 0x0F</code> is 4, meaning there is a second bit set at offset 4-1=3.
+        ///     </item>
+        ///     <item>
+        ///         <code>(0x43 >>> 8) & 0x0F</code> is 0, meaning there is no more bit set in this byte.
+        ///     </item>
+        ///     </para>
+        /// </remarks>
+        /// <param name="value"></param>
+        /// <returns></returns>
+        public static int BitList(byte value)
+        {
+            return BIT_LISTS[value & 0xFF];
+        }
+
+
+       
+        /// <summary>
+        /// Returns the number of set bits in an array of <see cref="System.Int34"/>.
+        /// </summary>
+        /// <param name="array">An array of <see cref="System.Int64"/></param>
+        /// <param name="wordOffset">The offset position.</param>
+        /// <param name="numberOfWords">The number of words, usually the length of the first array.</param>
+        /// <returns>The number of set bits.</returns>
+        public static long PopArray(long[] array, int wordOffset, int numberOfWords)
+        {
+            long count = 0;
+            int length = wordOffset + numberOfWords;
+            for (int i = wordOffset; i < length; ++i)
+            {
+                count += BitCount(array[i]);
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of the two sets, <paramref name="left"/> &amp; <paramref name="right" />,
+        /// after an intersection.
+        /// Neither array is modified.
+        /// </summary>
+        /// <param name="left">The array of <see cref="System.Int64"/> on the left side of the statement.</param>
+        /// <param name="right">The array of <see cref="System.Int64"/> on the right side of the statement.</param>
+        /// <param name="wordOffset">The offset position.</param>
+        /// <param name="numberOfWords">The number of words, usually the length of the first array.</param>
+        /// <returns>The number of set bits.</returns>
+        public static long PopIntersect(long[] left, long[] right, int wordOffset, int numWords)
+        {
+            long popCount = 0;
+            for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i)
+            {
+                popCount += BitCount(left[i] & right[i]);
+            }
+            return popCount;
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of the union of two sets, <paramref name="left"/> | <paramref name="right" />.
+        /// Neither array is modified.
+        /// </summary>
+        /// <param name="left">The array of <see cref="System.Int64"/> on the left side of the statement.</param>
+        /// <param name="right">The array of <see cref="System.Int64"/> on the right side of the statement.</param>
+        /// <param name="wordOffset">The offset position.</param>
+        /// <param name="numberOfWords">The number of words, usually the length of the first array.</param>
+        /// <returns>The number of set bits.</returns>
+        public static long PopUnion(long[] left, long[] right, int wordOffset, int numWords)
+        {
+            long popCount = 0;
+            for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i)
+            {
+                popCount += BitCount(left[i] | right[i]);
+            }
+            return popCount;
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of <paramref name="left" /> &amp; ~<paramref name="right" />
+        ///  Neither array is modified.
+        /// </summary>
+        /// <param name="left">The array of <see cref="System.Int64"/> on the left side of the statement.</param>
+        /// <param name="right">The array of <see cref="System.Int64"/> on the right side of the statement.</param>
+        /// <param name="wordOffset">The offset position.</param>
+        /// <param name="numberOfWords">The number of words, usually the length of the first array.</param>
+        /// <returns>The number of set bits.</returns>
+        public static long PopAndNot(long[] left, long[] right, int wordOffset, int numWords)
+        {
+            long popCount = 0;
+            for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i)
+            {
+                popCount += BitCount(left[i] & ~right[i]);
+            }
+            return popCount;
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of <paramref name="left" /> ^ <paramref name="right" />. 
+        /// Neither array is modified.
+        /// </summary>
+        /// <param name="left">The array of <see cref="System.Int64"/> on the left side of the statement.</param>
+        /// <param name="right">The array of <see cref="System.Int64"/> on the right side of the statement.</param>
+        /// <param name="wordOffset">The offset position.</param>
+        /// <param name="numberOfWords">The number of words, usually the length of the first array.</param>
+        /// <returns>The number of set bits.</returns>
+        public static long PopXor(long[] left, long[] right, int wordOffset, int numWords)
+        {
+         
+            long popCount = 0;
+            for (int i = wordOffset, end = wordOffset + numWords; i < end; ++i)
+            {
+                popCount += BitCount(left[i] ^ right[i]);
+            }
+            return popCount;
+        }
+
+        /// <summary>
+        /// Returns the next highest power of two or the 
+        /// current value if it's already a power of two or zero.
+        /// </summary>
+        /// <param name="value">The value used to find the next power of two.</param>
+        /// <returns>The next hightest power of two or current value.</returns>
+        public static int NextHighestPowerOfTwo(int value)
+        {
+            value--;
+            value |= value >> 1;
+            value |= value >> 2;
+            value |= value >> 4;
+            value |= value >> 8;
+            value |= value >> 16;
+            value++;
+            return value;
+        }
+
+        /// <summary>
+        /// Returns the next highest power of two or the current value if it's already a power of two or zero. 
+        /// </summary>
+        /// <param name="value">The value used to find the next power of two.</param>
+        /// <returns>The next hightest power of two or current value.</returns>
+        public static long NextHighestPowerOfTwo(long value)
+        {
+            value--;
+            value |= value >> 1;
+            value |= value >> 2;
+            value |= value >> 4;
+            value |= value >> 8;
+            value |= value >> 16;
+            value |= value >> 32;
+            value++;
+            return value;
+        }
+
+        /** Decode an int previously encoded with {@link #zigZagEncode(int)}. */
+        public static int ZigZagDecode(int value) 
+        {
+            return (int)(((uint)value >> 1) ^ -(value & 1));
+        }
+
+        /** Decode a long previously encoded with {@link #zigZagEncode(long)}. */
+        public static long zigZagDecode(long value) 
+        {
+            return ((value >>> 1) ^ -(value & 1));
+        }
+
+        /// <summary>
+        /// Zig-zag encode the value.  
+        /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///     <ahref="https://developers.google.com/protocol-buffers/docs/encoding#types">Zig-zag</a>
+        ///     encode the provided long. Assuming the input is a signed long whose
+        ///     absolute value can be stored on <tt>n</tt> bits, the returned value will
+        ///     be an unsigned long that can be stored on <tt>n+1</tt> bits.
+        ///     </para>
+        /// </remarks>
+        /// <param name="value">The value that will be encoded.</param>
+        /// <returns>The encoded value.</returns>
+        public static int ZigZagEncode(int value)
+        {
+            return (value >> 31) ^ (value << 1);
+        }
+
+        /// <summary>
+        /// Zig-zag encode the value.  
+        /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///     <ahref="https://developers.google.com/protocol-buffers/docs/encoding#types">Zig-zag</a>
+        ///     encode the provided long. Assuming the input is a signed long whose
+        ///     absolute value can be stored on <tt>n</tt> bits, the returned value will
+        ///     be an unsigned long that can be stored on <tt>n+1</tt> bits.
+        ///     </para>
+        /// </remarks>
+        /// <param name="value">The value that will be encoded.</param>
+        /// <returns>The encoded value.</returns>
+        public static long zigZagEncode(long value)
+        {
+            return (value >> 63) ^ (value << 1);
+        }
+
+        /// <summary>
+        /// Alternative for Java's Long.BitCount
+        /// </summary>
+        /// <param name="value">The value to be inspected.</param>
+        /// <returns></returns>
+        /// <seealso href="http://docs.oracle.com/javase/6/docs/api/java/lang/Long.html#bitCount(long)"/>
+        private static long BitCount(long value)
+        {
+            return SparseBitCount(value);
+        }
+        
+
+        private static long SparseBitCount(long value)
+        {
+            long count = 0;
+            while(value != 0)
+            {
+                count++;
+                value &= (value - 1);
+            }
+
+            return count;
+        }
+       
+    }
+}


[2/2] git commit: adding BroadWord class and initial test.

Posted by mh...@apache.org.
adding BroadWord class and initial test.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a5d9e83f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a5d9e83f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a5d9e83f

Branch: refs/heads/pcl
Commit: a5d9e83f8e4675f6a711036dc41aaccbac2bc4df
Parents: 477b922
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Fri Aug 8 23:45:06 2014 -0400
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Fri Aug 8 23:45:06 2014 -0400

----------------------------------------------------------------------
 Lucene.vs2013.sln                               | 25 -----
 src/Lucene.Net.Core/Lucene.Net.Core.csproj      | 11 ++-
 .../Support/NumberExtensionMethods.cs           | 97 ++++++++++++++++++++
 .../Support/SupportExtensionMethods.cs          |  3 +
 src/Lucene.Net.Core/Util/BitUtil.cs             | 20 ++--
 src/Lucene.Net.Core/Util/BroadWord.cs           | 87 ++++++++++++++++++
 src/Lucene.Net.Core/Util/SystemProps.cs         |  7 +-
 src/Lucene.Net.Core/packages.config             |  2 +-
 src/Lucene.Net.Core/project.json                |  6 +-
 .../Lucene.Net.Core.Tests.csproj                |  1 +
 .../Lucene.Net.Core.Tests/Util/TestBroadWord.cs | 32 +++++++
 11 files changed, 247 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/Lucene.vs2013.sln
----------------------------------------------------------------------
diff --git a/Lucene.vs2013.sln b/Lucene.vs2013.sln
index c9972ff..9170178 100644
--- a/Lucene.vs2013.sln
+++ b/Lucene.vs2013.sln
@@ -3,16 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 2013
 VisualStudioVersion = 12.0.30723.0
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C90AB34C-AFCE-4CA1-8AB6-F25FC241639C}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E7E53642-2EDA-49CE-B730-95242CCF608D}"
-EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Lucene.Net.TestFramework", "test\Lucene.Net.TestFramework\Lucene.Net.TestFramework.kproj", "{E8C34852-CE11-4CD0-A34A-E777B0BD705A}"
-EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Lucene.Net.Core", "src\Lucene.Net.Core\Lucene.Net.Core.kproj", "{CAF32BEA-5560-4E4A-A81F-11AA377F9929}"
-EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Lucene.Net.Core.Tests", "test\Lucene.Net.Core.Tests\Lucene.Net.Core.Tests.kproj", "{46467889-DCDD-4E2B-B583-6AACCE996EAC}"
-EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "portable-src", "portable-src", "{CD84C1EF-B845-4914-A9DD-D0F9ACC7DE6F}"
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "portable-test", "portable-test", "{4B0484AA-03E4-47A5-9989-AC42DDE1E06B}"
@@ -29,18 +19,6 @@ Global
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{E8C34852-CE11-4CD0-A34A-E777B0BD705A}.Release|Any CPU.Build.0 = Release|Any CPU
-		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{CAF32BEA-5560-4E4A-A81F-11AA377F9929}.Release|Any CPU.Build.0 = Release|Any CPU
-		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{46467889-DCDD-4E2B-B583-6AACCE996EAC}.Release|Any CPU.Build.0 = Release|Any CPU
 		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{AD8901C0-209D-4132-80AA-257DBACEECB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -58,9 +36,6 @@ Global
 		HideSolutionNode = FALSE
 	EndGlobalSection
 	GlobalSection(NestedProjects) = preSolution
-		{E8C34852-CE11-4CD0-A34A-E777B0BD705A} = {E7E53642-2EDA-49CE-B730-95242CCF608D}
-		{CAF32BEA-5560-4E4A-A81F-11AA377F9929} = {C90AB34C-AFCE-4CA1-8AB6-F25FC241639C}
-		{46467889-DCDD-4E2B-B583-6AACCE996EAC} = {E7E53642-2EDA-49CE-B730-95242CCF608D}
 		{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}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/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 03fa1d0..aed403a 100644
--- a/src/Lucene.Net.Core/Lucene.Net.Core.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
@@ -62,6 +62,7 @@
     <Compile Include="Support\EnumUtil.cs" />
     <Compile Include="Support\HashMap.cs" />
     <Compile Include="Support\ICloneable.cs" />
+    <Compile Include="Support\NumberExtensionMethods.cs" />
     <Compile Include="Support\SerializableAttribute.cs" />
     <Compile Include="Support\ShallowCloneNotSupportedException.cs" />
     <Compile Include="Support\StringExtensionMethods.cs" />
@@ -69,6 +70,8 @@
     <Compile Include="Util\ArrayInPlaceMergeSorter`.cs" />
     <Compile Include="Util\ArrayUtil.cs" />
     <Compile Include="Util\Bits.cs" />
+    <Compile Include="Util\BitUtil.cs" />
+    <Compile Include="Util\BroadWord.cs" />
     <Compile Include="Util\Constants.cs" />
     <Compile Include="Util\IAccountable.cs" />
     <Compile Include="Util\IAttribute.cs" />
@@ -80,12 +83,12 @@
     <Compile Include="Util\Version.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Reference Include="Microsoft.Framework.ConfigurationModel">
-      <HintPath>..\..\packages\Microsoft.Framework.ConfigurationModel.1.0.0-alpha3-10137\lib\portable-net451+win81+wpa81\Microsoft.Framework.ConfigurationModel.dll</HintPath>
-    </Reference>
+    <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="packages.config" />
+    <Reference Include="Microsoft.Framework.ConfigurationModel">
+      <HintPath>..\..\packages\Microsoft.Framework.ConfigurationModel\1.0.0-alpha4-10193\lib\portable-net451+win81+wpa81\Microsoft.Framework.ConfigurationModel.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs b/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
new file mode 100644
index 0000000..7d610fb
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.Support
+{
+    public static class NumberExtensionMethods
+    {
+        /// <summary>
+        /// FFS bit positions with De Bruijn sequences.
+        /// </summary>
+        static class DeBruijn32
+        {
+            static int[] s_positions = new int[32]
+	        {
+	            0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
+	            31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
+	        };
+
+            /// <summary>
+            /// Returns the first set bit (FFS), or 0 if no bits are set.
+            /// </summary>
+            public static int Position(int number)
+            {
+                uint res = unchecked((uint)(number & -number) * 0x077CB531U) >> 27;
+                return s_positions[res];
+            }
+        }
+
+
+        static class DeBruijn64
+        {
+
+
+            static int[] s_positions = new int[64] {
+                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 result = unchecked((uint)(value & -value) * 0x022fdd63cc95386d) >> 58;
+                return s_positions[result];
+            }
+        }
+
+
+        /// <summary>
+        /// Returns the number of trailing zeros. i.e 100 has two trailing zeros.
+        /// </summary>
+        /// <param name="value">The value to be inspected for trailing zeros.</param>
+        /// <remarks>
+        ///     <para>
+        ///         We're using the De Bruijn sequences based upon the various bit twiddling hacks found in 
+        ///         an online paper stanford <see cref="https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup" />
+        ///     </para>
+        ///     <para>
+        ///          It should be faster than Java's native 
+        ///          <see href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Integer.java#Integer.numberOfTrailingZeros%28int%29">
+        ///          Long.numberOfTrailingZeros
+        ///          </see> which uses the binary search method of finding trailing zeros.  
+        ///     </para>
+        /// </remarks>
+        /// <returns>The number of trailing zeros.</returns>
+        public static int NumberOfTrailingZeros(this int value)
+        {
+            return DeBruijn32.Position(value);
+        }
+
+        /// <summary>
+        /// Returns the number of trailing zeros. i.e 100 has two trailing zeros.
+        /// </summary>
+        /// <param name="value">The value to be inspected for trailing zeros.</param>
+        /// <remarks>
+        ///     <para>
+        ///         We're using the De Bruijn sequences based upon the various bit twiddling hacks found in 
+        ///         an online paper stanford <see cref="https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup" />
+        ///     </para>
+        ///     <para>
+        ///          It should be faster than Java's native 
+        ///          <see href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Integer.java#Integer.numberOfTrailingZeros%28int%29">
+        ///          Long.numberOfTrailingZeros
+        ///          </see> which uses the binary search method of finding trailing zeros.  
+        ///     </para>
+        /// </remarks>
+        /// <returns>The number of trailing zeros.</returns>
+        public static int NumberOfTrailingZeros(this long value)
+        {
+            return DeBruijn64.Position(value);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs b/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
index 5bdff41..76e82e4 100644
--- a/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
+++ b/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
@@ -25,6 +25,9 @@ namespace Lucene.Net.Support
     /// </summary>
     public static class SupportExtensionMethods
     {
+
+
+
         /// <summary>
         /// Clones and casts the new instance to the same type of the old instance. 
         /// </summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/Util/BitUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BitUtil.cs b/src/Lucene.Net.Core/Util/BitUtil.cs
index bb2e8e9..da5f735 100644
--- a/src/Lucene.Net.Core/Util/BitUtil.cs
+++ b/src/Lucene.Net.Core/Util/BitUtil.cs
@@ -277,16 +277,24 @@ namespace Lucene.Net.Util
             return value;
         }
 
-        /** Decode an int previously encoded with {@link #zigZagEncode(int)}. */
+        /// <summary>
+        /// Decode a long previously encoded with <see cref="ZigZagEndcode"/>.
+        /// </summary>
+        /// <param name="value">The value to be decoded.</param>
+        /// <returns>The decoded value.</returns>
         public static int ZigZagDecode(int value) 
         {
             return (int)(((uint)value >> 1) ^ -(value & 1));
         }
 
-        /** Decode a long previously encoded with {@link #zigZagEncode(long)}. */
-        public static long zigZagDecode(long value) 
+        /// <summary>
+        /// Decode a long previously encoded with <see cref="ZigZagEndcode"/>.
+        /// </summary>
+        /// <param name="value">The value to be decoded.</param>
+        /// <returns>The decoded value.</returns>
+        public static long ZigZagDecode(long value) 
         {
-            return ((value >>> 1) ^ -(value & 1));
+            return ((long)((ulong)value >> 1) ^ -(value & 1));
         }
 
         /// <summary>
@@ -320,7 +328,7 @@ namespace Lucene.Net.Util
         /// </remarks>
         /// <param name="value">The value that will be encoded.</param>
         /// <returns>The encoded value.</returns>
-        public static long zigZagEncode(long value)
+        public static long ZigZagEncode(long value)
         {
             return (value >> 63) ^ (value << 1);
         }
@@ -331,7 +339,7 @@ namespace Lucene.Net.Util
         /// <param name="value">The value to be inspected.</param>
         /// <returns></returns>
         /// <seealso href="http://docs.oracle.com/javase/6/docs/api/java/lang/Long.html#bitCount(long)"/>
-        private static long BitCount(long value)
+        public static long BitCount(long value)
         {
             return SparseBitCount(value);
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/Util/BroadWord.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BroadWord.cs b/src/Lucene.Net.Core/Util/BroadWord.cs
new file mode 100644
index 0000000..239cbe6
--- /dev/null
+++ b/src/Lucene.Net.Core/Util/BroadWord.cs
@@ -0,0 +1,87 @@
+/*
+    * 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 Lucene.Net.Util
+{
+
+    using System.Diagnostics;
+    using Lucene.Net.Support;
+
+    /// <summary>
+    /// Methods and constants inspired by the article
+    /// "Broadword Implementation of Rank/Select Queries" by Sebastiano Vigna, January 30, 2012:
+    /// </summary>
+    public sealed class BroadWord
+    {
+
+        private BroadWord() // no instance
+        {
+        }
+
+        /// <summary>
+        ///  L8  denotes the constant of 8-byte-counts or 8k.
+        ///  _L denotes that the number is an long format. 
+        /// </summary>
+        public const long L8_L = 0x0101010101010101L;
+
+        /// <summary>
+        ///  L9  denotes the constant of 8-byte-counts or 9k.
+        ///  _L denotes that the number is an long format. 
+        /// </summary>
+        public const long L9_L = unchecked((long)0x8040201008040201L);
+
+        /// <summary>
+        ///  L16  denotes the constant of 16-byte-counts or 16k.
+        ///  _L denotes that the number is an long format. 
+        /// </summary>
+        public const long L16_L = 0x0001000100010001L;
+
+        /// <summary>
+        /// H8 = L8 << (8-1) .
+        ///  These contain the high bit of each group of k bits.
+        ///  The suffix _L indicates the long implementation.
+        /// </summary>
+        public static readonly long H8_L = L8_L << 7;
+
+        /// H16 = L16 << (16-1) .
+        ///  These contain the high bit of each group of k bits.
+        ///  The suffix _L indicates the long implementation.
+        public static readonly long H16_L = L16_L << 15;
+
+        /// <summary>
+        /// Bit count of a long.
+        /// Only here to compare the implementation with <seealso cref="Select(long,int)"/>,
+        /// normally <seealso cref="Lucene.Net.Util.BitUtil.BitCount"/> is preferable. </summary>
+        /// <returns> The total number of 1 bits in x. </returns>
+        public static int BitCount(long value)
+        {
+            ulong x = (ulong)value;
+            // Step 0 leaves in each pair of bits the number of ones originally contained in that pair:
+            x = x - ((x & 0xAAAAAAAAAAAAAAAAL) >> 1);
+            // Step 1, idem for each nibble:
+            x = (x & 0x3333333333333333L) + ((x >> 2) & 0x3333333333333333L);
+            // Step 2, idem for each byte:
+            x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0FL;
+            // Multiply to sum them all into the high byte, and return the high byte:
+            return (int)((x * L8_L) >> 56);
+        }
+
+       
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/Util/SystemProps.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/SystemProps.cs b/src/Lucene.Net.Core/Util/SystemProps.cs
index f5fbf70..4f8338b 100644
--- a/src/Lucene.Net.Core/Util/SystemProps.cs
+++ b/src/Lucene.Net.Core/Util/SystemProps.cs
@@ -40,9 +40,8 @@ namespace Lucene.Net.Util
         /// Adds the <see cref="IConfigurationSource"/> to what is available in <see cref="SystemProps"/>.
         /// </summary>
         /// <param name="configurationSource"></param>
-#pragma warning disable "CS3001"
+        [CLSCompliant(false)]
         public static void Add(IConfigurationSource configurationSource)
-#pragma warning restore "CS3001"
         {
             s_config.Add(configurationSource);
         }
@@ -89,10 +88,8 @@ namespace Lucene.Net.Util
         /// 
         /// </summary>
         /// <param name="configuration"></param>
-
-#pragma warning disable "CS3001"
+        [CLSCompliant(false)]
         public static void UseConfiguration(Configuration configuration)
-#pragma warning restore "CS3001"
         {
             s_config = configuration;
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/packages.config
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/packages.config b/src/Lucene.Net.Core/packages.config
index 80dad80..9c1a013 100644
--- a/src/Lucene.Net.Core/packages.config
+++ b/src/Lucene.Net.Core/packages.config
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="Microsoft.Framework.ConfigurationModel" version="1.0.0-alpha3-10137" targetFramework="portable-net451+win81+wpa81" />
+  <package id="Microsoft.Framework.ConfigurationModel" version="1.0.0-alpha4-10193" targetFramework="portable-net451+win81+wpa81" />
 </packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/src/Lucene.Net.Core/project.json
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/project.json b/src/Lucene.Net.Core/project.json
index eebe593..8025e0e 100644
--- a/src/Lucene.Net.Core/project.json
+++ b/src/Lucene.Net.Core/project.json
@@ -1,8 +1,8 @@
 {
-    "licenses": ["apache 2.0"],
-     "version": "5.0.0.0",
+    "licenses": [ "apache 2.0" ],
+    "version": "5.0.0.0",
     "dependencies": {
-        "Microsoft.Framework.ConfigurationModel": "1.0.0-alpha2"
+        "Microsoft.Framework.ConfigurationModel": "1.0.0-alpha4-10193" 
     },
     "license": "apache 2.0",
     "configurations" : {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj b/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
index 3e31131..ec3e52c 100644
--- a/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
+++ b/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
@@ -62,6 +62,7 @@
     <Compile Include="Util\BaseSorterTestCase.cs" />
     <Compile Include="Util\TestArrayUtil.cs" />
     <Compile Include="Util\TestBits.cs" />
+    <Compile Include="Util\TestBroadWord.cs" />
     <Compile Include="Util\TestConstants.cs" />
     <Compile Include="Util\TestInPlaceMergeSorter.cs" />
     <Compile Include="Util\TestRamEstimatorUsage.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a5d9e83f/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs b/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
new file mode 100644
index 0000000..bca2806
--- /dev/null
+++ b/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
@@ -0,0 +1,32 @@
+
+
+namespace Lucene.Net.Util
+{
+    using System;
+
+    using Lucene.Net.Support;
+
+
+    public class TestBroadWord : LuceneTestCase
+    {
+
+
+        [Test]
+        public void TestRank()
+        {
+            AssertRank(0L);
+            AssertRank(1L);
+            AssertRank(3L);
+            AssertRank(0x100L);
+            AssertRank(0x300L);
+            AssertRank(unchecked((long)0x8000000000000001L));
+        }
+
+
+
+        private void AssertRank(long value)
+        {
+            Equal(BitUtil.BitCount(value), BroadWord.BitCount(value));
+        }
+    }
+}