You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2008/06/25 04:49:44 UTC

svn commit: r671400 - in /incubator/lucene.net/trunk/C#/src/Lucene.Net/Util: BitVector.cs Constants.cs Package.html PriorityQueue.cs StringHelper.cs ToStringUtils.cs

Author: aroush
Date: Tue Jun 24 19:49:43 2008
New Revision: 671400

URL: http://svn.apache.org/viewvc?rev=671400&view=rev
Log:
Release: Apache Lucene.Net.2.3.1 build 001 "Alpha"

Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Package.html
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/BitVector.cs?rev=671400&r1=671399&r2=671400&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/BitVector.cs Tue Jun 24 19:49:43 2008
@@ -33,9 +33,7 @@
 	/// <li>store and load, as bit set or d-gaps, depending on sparseness;</li> 
 	/// </ul>
 	/// </summary>
-	/// <author>  Doug Cutting
-	/// </author>
-	/// <version>  $Id: BitVector.java 494136 2007-01-08 18:11:08Z mikemccand $
+	/// <version>  $Id: BitVector.java 564236 2007-08-09 15:21:19Z gsingers $
 	/// </version>
 	public sealed class BitVector
 	{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/Constants.cs?rev=671400&r1=671399&r2=671400&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs Tue Jun 24 19:49:43 2008
@@ -20,28 +20,11 @@
 namespace Lucene.Net.Util
 {
 	
-	/// <summary> 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.
-	/// </summary>
-	
 	/// <summary> Some useful constants.
 	/// 
+	/// 
 	/// </summary>
-	/// <author>   Doug Cutting
-	/// </author>
-	/// <version>  $Id: Constants.java 472959 2006-11-09 16:21:50Z yonik $
+	/// <version>  $Id: Constants.java 564236 2007-08-09 15:21:19Z gsingers $
 	/// 
 	/// </version>
 	

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Package.html
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/Package.html?rev=671400&r1=671399&r2=671400&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Package.html (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Package.html Tue Jun 24 19:49:43 2008
@@ -1,10 +1,10 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
-   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-   <meta name="Author" content="Doug Cutting">
-</head>
-<body>
-Some utility classes.
-</body>
-</html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="Author" content="Doug Cutting">
+</head>
+<body>
+Some utility classes.
+</body>
+</html>

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/PriorityQueue.cs?rev=671400&r1=671399&r2=671400&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/PriorityQueue.cs Tue Jun 24 19:49:43 2008
@@ -20,31 +20,15 @@
 namespace Lucene.Net.Util
 {
 	
-	/// <summary> 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.
-	/// </summary>
-	
 	/// <summary>A PriorityQueue maintains a partial ordering of its elements such that the
 	/// least element can always be found in constant time.  Put()'s and pop()'s
 	/// require log(size) time. 
 	/// </summary>
 	public abstract class PriorityQueue
 	{
-		private System.Object[] heap;
 		private int size;
 		private int maxSize;
+		protected internal System.Object[] heap;
 		
 		/// <summary>Determines the ordering of objects in this priority queue.  Subclasses
 		/// must define this one method. 
@@ -55,14 +39,19 @@
 		protected internal void  Initialize(int maxSize)
 		{
 			size = 0;
-			int heapSize = maxSize + 1;
+			int heapSize;
+			if (0 == maxSize)
+                // We allocate 1 extra to avoid if statement in top()
+				heapSize = 2;
+			else
+				heapSize = maxSize + 1;
 			heap = new System.Object[heapSize];
 			this.maxSize = maxSize;
 		}
 		
 		/// <summary> Adds an Object to a PriorityQueue in log(size) time.
 		/// If one tries to add more objects than maxSize from initialize
-		/// a SystemException (ArrayIndexOutOfBound) is thrown.
+		/// a RuntimeException (ArrayIndexOutOfBound) is thrown.
 		/// </summary>
 		public void  Put(System.Object element)
 		{
@@ -74,34 +63,51 @@
 		/// <summary> Adds element to the PriorityQueue in log(size) time if either
 		/// the PriorityQueue is not full, or not lessThan(element, top()).
 		/// </summary>
-		/// <param name="">element
+		/// <param name="element">
 		/// </param>
 		/// <returns> true if element is added, false otherwise.
 		/// </returns>
 		public virtual bool Insert(System.Object element)
 		{
+			return InsertWithOverflow(element) != element;
+		}
+		
+		/// <summary> insertWithOverflow() is the same as insert() except its
+		/// return value: it returns the object (if any) that was
+		/// dropped off the heap because it was full. This can be
+		/// the given parameter (in case it is smaller than the
+		/// full heap's minimum, and couldn't be added), or another
+		/// object that was previously the smallest value in the
+		/// heap and now has been replaced by a larger one, or null
+		/// if the queue wasn't yet full with maxSize elements.
+		/// </summary>
+		public virtual System.Object InsertWithOverflow(System.Object element)
+		{
 			if (size < maxSize)
 			{
 				Put(element);
-				return true;
+				return null;
 			}
-			else if (size > 0 && !LessThan(element, Top()))
+			else if (size > 0 && !LessThan(element, heap[1]))
 			{
+				System.Object ret = heap[1];
 				heap[1] = element;
 				AdjustTop();
-				return true;
+				return ret;
 			}
 			else
-				return false;
+			{
+				return element;
+			}
 		}
 		
 		/// <summary>Returns the least element of the PriorityQueue in constant time. </summary>
 		public System.Object Top()
 		{
-			if (size > 0)
-				return heap[1];
-			else
-				return null;
+			// We don't need to check size here: if maxSize is 0,
+			// then heap is length 2 array with both entries null.
+			// If size is 0 then heap[1] is already null.
+			return heap[1];
 		}
 		
 		/// <summary>Removes and returns the least element of the PriorityQueue in log(size)
@@ -134,7 +140,6 @@
 			DownHeap();
 		}
 		
-		
 		/// <summary>Returns the number of elements currently stored in the PriorityQueue. </summary>
 		public int Size()
 		{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/StringHelper.cs?rev=671400&r1=671399&r2=671400&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/StringHelper.cs Tue Jun 24 19:49:43 2008
@@ -42,7 +42,7 @@
 		{
 			int len1 = s1.Length;
 			int len2 = s2.Length;
-			int len = len1 < len2?len1:len2;
+			int len = len1 < len2 ? len1:len2;
 			for (int i = 0; i < len; i++)
 			{
 				if (s1[i] != s2[i])

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/ToStringUtils.cs?rev=671400&r1=671399&r2=671400&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/ToStringUtils.cs Tue Jun 24 19:49:43 2008
@@ -22,6 +22,7 @@
 	
     public class ToStringUtils
     {
+		/// <summary>for printing boost only if not 1.0 </summary>
         public static System.String Boost(float boost)
         {
             if (boost != 1.0f)