Return-Path: Delivered-To: apmail-lucene-mahout-commits-archive@minotaur.apache.org Received: (qmail 24133 invoked from network); 25 Nov 2009 03:36:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Nov 2009 03:36:34 -0000 Received: (qmail 53849 invoked by uid 500); 25 Nov 2009 03:36:33 -0000 Delivered-To: apmail-lucene-mahout-commits-archive@lucene.apache.org Received: (qmail 53607 invoked by uid 500); 25 Nov 2009 03:36:33 -0000 Mailing-List: contact mahout-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mahout-dev@lucene.apache.org Delivered-To: mailing list mahout-commits@lucene.apache.org Received: (qmail 53594 invoked by uid 99); 25 Nov 2009 03:36:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Nov 2009 03:36:32 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Nov 2009 03:36:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9B4912388A4A; Wed, 25 Nov 2009 03:36:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r883973 [5/14] - in /lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix: ./ bitvector/ buffer/ function/ list/ list/adapter/ map/ Date: Wed, 25 Nov 2009 03:36:02 -0000 To: mahout-commits@lucene.apache.org From: srowen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091125033604.9B4912388A4A@eris.apache.org> Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3D.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3D.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3D.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3D.java Wed Nov 25 03:35:59 2009 @@ -12,40 +12,38 @@ /** * Fixed sized (non resizable) streaming buffer connected to a target DoubleBuffer3DConsumer to which data is automatically flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @Deprecated public class DoubleBuffer3D extends org.apache.mahout.matrix.PersistentObject implements DoubleBuffer3DConsumer { - protected DoubleBuffer3DConsumer target; - protected double[] xElements; - protected double[] yElements; - protected double[] zElements; + protected DoubleBuffer3DConsumer target; + protected double[] xElements; + protected double[] yElements; + protected double[] zElements; - // vars cached for speed - protected DoubleArrayList xList; - protected DoubleArrayList yList; - protected DoubleArrayList zList; - protected int capacity; - protected int size; + // vars cached for speed + protected DoubleArrayList xList; + protected DoubleArrayList yList; + protected DoubleArrayList zList; + protected int capacity; + protected int size; /** * Constructs and returns a new buffer with the given target. * @param target the target to flush to. * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target. */ public DoubleBuffer3D(DoubleBuffer3DConsumer target, int capacity) { - this.target = target; - this.capacity = capacity; - this.xElements = new double[capacity]; - this.yElements = new double[capacity]; - this.zElements = new double[capacity]; - this.xList = new DoubleArrayList(xElements); - this.yList = new DoubleArrayList(yElements); - this.zList = new DoubleArrayList(zElements); - this.size = 0; + this.target = target; + this.capacity = capacity; + this.xElements = new double[capacity]; + this.yElements = new double[capacity]; + this.zElements = new double[capacity]; + this.xList = new DoubleArrayList(xElements); + this.yList = new DoubleArrayList(yElements); + this.zList = new DoubleArrayList(zElements); + this.size = 0; } /** * Adds the specified point (x,y,z) to the receiver. @@ -55,10 +53,10 @@ * @param z the z-coordinate of the point to add. */ public void add(double x, double y, double z) { - if (this.size == this.capacity) flush(); - this.xElements[this.size] = x; - this.yElements[this.size] = y; - this.zElements[this.size++] = z; + if (this.size == this.capacity) flush(); + this.xElements[this.size] = x; + this.yElements[this.size] = y; + this.zElements[this.size++] = z; } /** * Adds all specified (x,y,z) points to the receiver. @@ -67,27 +65,27 @@ * @param zElements the y-coordinates of the points. */ public void addAllOf(DoubleArrayList xElements, DoubleArrayList yElements, DoubleArrayList zElements) { - int listSize = xElements.size(); - if (this.size + listSize >= this.capacity) flush(); - this.target.addAllOf(xElements, yElements, zElements); + int listSize = xElements.size(); + if (this.size + listSize >= this.capacity) flush(); + this.target.addAllOf(xElements, yElements, zElements); } /** * Sets the receiver's size to zero. * In other words, forgets about any internally buffered elements. */ public void clear() { - this.size = 0; + this.size = 0; } /** * Adds all internally buffered points to the receiver's target, then resets the current buffer size to zero. */ public void flush() { - if (this.size > 0) { - xList.setSize(this.size); - yList.setSize(this.size); - zList.setSize(this.size); - this.target.addAllOf(xList,yList,zList); - this.size = 0; - } + if (this.size > 0) { + xList.setSize(this.size); + yList.setSize(this.size); + zList.setSize(this.size); + this.target.addAllOf(xList,yList,zList); + this.size = 0; + } } } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3DConsumer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3DConsumer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3DConsumer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBuffer3DConsumer.java Wed Nov 25 03:35:59 2009 @@ -12,8 +12,6 @@ /** * Target of a streaming DoubleBuffer3D into which data is flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBufferConsumer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBufferConsumer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBufferConsumer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/DoubleBufferConsumer.java Wed Nov 25 03:35:59 2009 @@ -12,8 +12,6 @@ /** * Target of a streaming DoubleBuffer into which data is flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer.java Wed Nov 25 03:35:59 2009 @@ -12,32 +12,30 @@ /** * Fixed sized (non resizable) streaming buffer connected to a target IntBufferConsumer to which data is automatically flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @Deprecated public class IntBuffer extends org.apache.mahout.matrix.PersistentObject implements IntBufferConsumer { - protected IntBufferConsumer target; - protected int[] elements; + protected IntBufferConsumer target; + protected int[] elements; - // vars cached for speed - protected IntArrayList list; - protected int capacity; - protected int size; + // vars cached for speed + protected IntArrayList list; + protected int capacity; + protected int size; /** * Constructs and returns a new buffer with the given target. * @param target the target to flush to. * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target. */ public IntBuffer(IntBufferConsumer target, int capacity) { - this.target = target; - this.capacity = capacity; - this.elements = new int[capacity]; - this.list = new IntArrayList(elements); - this.size = 0; + this.target = target; + this.capacity = capacity; + this.elements = new int[capacity]; + this.list = new IntArrayList(elements); + this.size = 0; } /** * Adds the specified element to the receiver. @@ -45,33 +43,33 @@ * @param element the element to add. */ public void add(int element) { - if (this.size == this.capacity) flush(); - this.elements[size++] = element; + if (this.size == this.capacity) flush(); + this.elements[size++] = element; } /** * Adds all elements of the specified list to the receiver. * @param list the list of which all elements shall be added. */ public void addAllOf(IntArrayList list) { - int listSize = list.size(); - if (this.size + listSize >= this.capacity) flush(); - this.target.addAllOf(list); + int listSize = list.size(); + if (this.size + listSize >= this.capacity) flush(); + this.target.addAllOf(list); } /** * Sets the receiver's size to zero. * In other words, forgets about any internally buffered elements. */ public void clear() { - this.size = 0; + this.size = 0; } /** * Adds all internally buffered elements to the receiver's target, then resets the current buffer size to zero. */ public void flush() { - if (this.size > 0) { - list.setSize(this.size); - this.target.addAllOf(list); - this.size = 0; - } + if (this.size > 0) { + list.setSize(this.size); + this.target.addAllOf(list); + this.size = 0; + } } } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2D.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2D.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2D.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2D.java Wed Nov 25 03:35:59 2009 @@ -12,36 +12,34 @@ /** * Fixed sized (non resizable) streaming buffer connected to a target IntBuffer2DConsumer to which data is automatically flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @Deprecated public class IntBuffer2D extends org.apache.mahout.matrix.PersistentObject implements IntBuffer2DConsumer { - protected IntBuffer2DConsumer target; - protected int[] xElements; - protected int[] yElements; + protected IntBuffer2DConsumer target; + protected int[] xElements; + protected int[] yElements; - // vars cached for speed - protected IntArrayList xList; - protected IntArrayList yList; - protected int capacity; - protected int size; + // vars cached for speed + protected IntArrayList xList; + protected IntArrayList yList; + protected int capacity; + protected int size; /** * Constructs and returns a new buffer with the given target. * @param target the target to flush to. * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target. */ public IntBuffer2D(IntBuffer2DConsumer target, int capacity) { - this.target = target; - this.capacity = capacity; - this.xElements = new int[capacity]; - this.yElements = new int[capacity]; - this.xList = new IntArrayList(xElements); - this.yList = new IntArrayList(yElements); - this.size = 0; + this.target = target; + this.capacity = capacity; + this.xElements = new int[capacity]; + this.yElements = new int[capacity]; + this.xList = new IntArrayList(xElements); + this.yList = new IntArrayList(yElements); + this.size = 0; } /** * Adds the specified point (x,y) to the receiver. @@ -50,9 +48,9 @@ * @param y the y-coordinate of the point to add. */ public void add(int x, int y) { - if (this.size == this.capacity) flush(); - this.xElements[this.size] = x; - this.yElements[this.size++] = y; + if (this.size == this.capacity) flush(); + this.xElements[this.size] = x; + this.yElements[this.size++] = y; } /** * Adds all specified points (x,y) to the receiver. @@ -60,26 +58,26 @@ * @param y the y-coordinates of the points to add. */ public void addAllOf(IntArrayList x, IntArrayList y) { - int listSize = x.size(); - if (this.size + listSize >= this.capacity) flush(); - this.target.addAllOf(x, y); + int listSize = x.size(); + if (this.size + listSize >= this.capacity) flush(); + this.target.addAllOf(x, y); } /** * Sets the receiver's size to zero. * In other words, forgets about any internally buffered elements. */ public void clear() { - this.size = 0; + this.size = 0; } /** * Adds all internally buffered points to the receiver's target, then resets the current buffer size to zero. */ public void flush() { - if (this.size > 0) { - xList.setSize(this.size); - yList.setSize(this.size); - this.target.addAllOf(xList,yList); - this.size = 0; - } + if (this.size > 0) { + xList.setSize(this.size); + yList.setSize(this.size); + this.target.addAllOf(xList,yList); + this.size = 0; + } } } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2DConsumer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2DConsumer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2DConsumer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer2DConsumer.java Wed Nov 25 03:35:59 2009 @@ -12,8 +12,6 @@ /** * Target of a streaming IntBuffer2D into which data is flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3D.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3D.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3D.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3D.java Wed Nov 25 03:35:59 2009 @@ -12,40 +12,38 @@ /** * Fixed sized (non resizable) streaming buffer connected to a target IntBuffer3DConsumer to which data is automatically flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @Deprecated public class IntBuffer3D extends org.apache.mahout.matrix.PersistentObject implements IntBuffer3DConsumer { - protected IntBuffer3DConsumer target; - protected int[] xElements; - protected int[] yElements; - protected int[] zElements; + protected IntBuffer3DConsumer target; + protected int[] xElements; + protected int[] yElements; + protected int[] zElements; - // vars cached for speed - protected IntArrayList xList; - protected IntArrayList yList; - protected IntArrayList zList; - protected int capacity; - protected int size; + // vars cached for speed + protected IntArrayList xList; + protected IntArrayList yList; + protected IntArrayList zList; + protected int capacity; + protected int size; /** * Constructs and returns a new buffer with the given target. * @param target the target to flush to. * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target. */ public IntBuffer3D(IntBuffer3DConsumer target, int capacity) { - this.target = target; - this.capacity = capacity; - this.xElements = new int[capacity]; - this.yElements = new int[capacity]; - this.zElements = new int[capacity]; - this.xList = new IntArrayList(xElements); - this.yList = new IntArrayList(yElements); - this.zList = new IntArrayList(zElements); - this.size = 0; + this.target = target; + this.capacity = capacity; + this.xElements = new int[capacity]; + this.yElements = new int[capacity]; + this.zElements = new int[capacity]; + this.xList = new IntArrayList(xElements); + this.yList = new IntArrayList(yElements); + this.zList = new IntArrayList(zElements); + this.size = 0; } /** * Adds the specified point (x,y,z) to the receiver. @@ -55,10 +53,10 @@ * @param z the z-coordinate of the point to add. */ public void add(int x, int y, int z) { - if (this.size == this.capacity) flush(); - this.xElements[this.size] = x; - this.yElements[this.size] = y; - this.zElements[this.size++] = z; + if (this.size == this.capacity) flush(); + this.xElements[this.size] = x; + this.yElements[this.size] = y; + this.zElements[this.size++] = z; } /** * Adds all specified (x,y,z) points to the receiver. @@ -67,27 +65,27 @@ * @param zElements the y-coordinates of the points. */ public void addAllOf(IntArrayList xElements, IntArrayList yElements, IntArrayList zElements) { - int listSize = xElements.size(); - if (this.size + listSize >= this.capacity) flush(); - this.target.addAllOf(xElements, yElements, zElements); + int listSize = xElements.size(); + if (this.size + listSize >= this.capacity) flush(); + this.target.addAllOf(xElements, yElements, zElements); } /** * Sets the receiver's size to zero. * In other words, forgets about any internally buffered elements. */ public void clear() { - this.size = 0; + this.size = 0; } /** * Adds all internally buffered points to the receiver's target, then resets the current buffer size to zero. */ public void flush() { - if (this.size > 0) { - xList.setSize(this.size); - yList.setSize(this.size); - zList.setSize(this.size); - this.target.addAllOf(xList,yList,zList); - this.size = 0; - } + if (this.size > 0) { + xList.setSize(this.size); + yList.setSize(this.size); + zList.setSize(this.size); + this.target.addAllOf(xList,yList,zList); + this.size = 0; + } } } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3DConsumer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3DConsumer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3DConsumer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBuffer3DConsumer.java Wed Nov 25 03:35:59 2009 @@ -12,8 +12,6 @@ /** * Target of a streaming IntBuffer3D into which data is flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBufferConsumer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBufferConsumer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBufferConsumer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/IntBufferConsumer.java Wed Nov 25 03:35:59 2009 @@ -12,8 +12,6 @@ /** * Target of a streaming IntBuffer into which data is flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBuffer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBuffer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBuffer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBuffer.java Wed Nov 25 03:35:59 2009 @@ -12,32 +12,30 @@ /** * Fixed sized (non resizable) streaming buffer connected to a target ObjectBufferConsumer to which data is automatically flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. */ @Deprecated public class ObjectBuffer extends org.apache.mahout.matrix.PersistentObject implements ObjectBufferConsumer { - protected ObjectBufferConsumer target; - protected Object[] elements; + protected ObjectBufferConsumer target; + protected Object[] elements; - // vars cached for speed - protected ObjectArrayList list; - protected int capacity; - protected int size; + // vars cached for speed + protected ObjectArrayList list; + protected int capacity; + protected int size; /** * Constructs and returns a new buffer with the given target. * @param target the target to flush to. * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target. */ public ObjectBuffer(ObjectBufferConsumer target, int capacity) { - this.target = target; - this.capacity = capacity; - this.elements = new Object[capacity]; - this.list = new ObjectArrayList(elements); - this.size = 0; + this.target = target; + this.capacity = capacity; + this.elements = new Object[capacity]; + this.list = new ObjectArrayList(elements); + this.size = 0; } /** * Adds the specified element to the receiver. @@ -45,33 +43,33 @@ * @param element the element to add. */ public void add(Object element) { - if (this.size == this.capacity) flush(); - this.elements[size++] = element; + if (this.size == this.capacity) flush(); + this.elements[size++] = element; } /** * Adds all elements of the specified list to the receiver. * @param list the list of which all elements shall be added. */ public void addAllOf(ObjectArrayList list) { - int listSize = list.size(); - if (this.size + listSize >= this.capacity) flush(); - this.target.addAllOf(list); + int listSize = list.size(); + if (this.size + listSize >= this.capacity) flush(); + this.target.addAllOf(list); } /** * Sets the receiver's size to zero. * In other words, forgets about any internally buffered elements. */ public void clear() { - this.size = 0; + this.size = 0; } /** * Adds all internally buffered elements to the receiver's target, then resets the current buffer size to zero. */ public void flush() { - if (this.size > 0) { - list.setSize(this.size); - this.target.addAllOf(list); - this.size = 0; - } + if (this.size > 0) { + list.setSize(this.size); + this.target.addAllOf(list); + this.size = 0; + } } } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBufferConsumer.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBufferConsumer.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBufferConsumer.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/buffer/ObjectBufferConsumer.java Wed Nov 25 03:35:59 2009 @@ -12,8 +12,6 @@ /** * Target of a streaming ObjectBuffer into which data is flushed upon buffer overflow. * - * @author wolfgang.hoschek@cern.ch - * @version 1.0, 09/24/99 */ /** * @deprecated until unit tests are in place. Until this time, this class/interface is unsupported. Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ByteComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ByteComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ByteComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ByteComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(byte o1, byte o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/CharComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/CharComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/CharComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/CharComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(char o1, char o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double27Function.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double27Function.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double27Function.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double27Function.java Wed Nov 25 03:35:59 2009 @@ -23,16 +23,16 @@ * @return the result of the function. */ abstract public double apply( - double a000, double a001, double a002, - double a010, double a011, double a012, - double a020, double a021, double a022, + double a000, double a001, double a002, + double a010, double a011, double a012, + double a020, double a021, double a022, - double a100, double a101, double a102, - double a110, double a111, double a112, - double a120, double a121, double a122, + double a100, double a101, double a102, + double a110, double a111, double a112, + double a120, double a121, double a122, - double a200, double a201, double a202, - double a210, double a211, double a212, - double a220, double a221, double a222 + double a200, double a201, double a202, + double a210, double a211, double a212, + double a220, double a221, double a222 ); } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double9Function.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double9Function.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double9Function.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/Double9Function.java Wed Nov 25 03:35:59 2009 @@ -23,8 +23,8 @@ * @return the result of the function. */ abstract public double apply( - double a00, double a01, double a02, - double a10, double a11, double a12, - double a20, double a21, double a22 - ); + double a00, double a01, double a02, + double a10, double a11, double a12, + double a20, double a21, double a22 + ); } Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/DoubleComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/DoubleComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/DoubleComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/DoubleComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(double o1, double o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/FloatComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/FloatComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/FloatComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/FloatComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(float o1, float o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/IntComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/IntComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/IntComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/IntComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(int o1, int o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/LongComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/LongComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/LongComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/LongComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(long o1, long o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ShortComparator.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ShortComparator.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ShortComparator.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/function/ShortComparator.java Wed Nov 25 03:35:59 2009 @@ -19,8 +19,6 @@ * order for the data structure to serialize successfully, the comparator (if * provided) must implement Serializable.

* - * @author wolfgang.hoschek@cern.ch - * @version 0.1 01/09/99 * @see java.util.Comparator * @see org.apache.mahout.matrix.Sorting */ @@ -49,8 +47,8 @@ * * * @return a negative integer, zero, or a positive integer as the - * first argument is less than, equal to, or greater than the - * second. + * first argument is less than, equal to, or greater than the + * second. */ int compare(short o1, short o2); /** @@ -71,8 +69,8 @@ * * @param obj the reference object with which to compare. * @return true only if the specified object is also - * a comparator and it imposes the same ordering as this - * comparator. + * a comparator and it imposes the same ordering as this + * comparator. * @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#hashCode() */ Modified: lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/list/AbstractBooleanList.java URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/list/AbstractBooleanList.java?rev=883973&r1=883972&r2=883973&view=diff ============================================================================== --- lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/list/AbstractBooleanList.java (original) +++ lucene/mahout/trunk/matrix/src/main/java/org/apache/mahout/matrix/list/AbstractBooleanList.java Wed Nov 25 03:35:59 2009 @@ -18,13 +18,13 @@ */ @Deprecated public abstract class AbstractBooleanList extends AbstractList { - /** - * The size of the list. - * This is a READ_ONLY variable for all methods but setSizeRaw(int newSize) !!! - * If you violate this principle in subclasses, you should exactly know what you are doing. - * @serial - */ - protected int size; + /** + * The size of the list. + * This is a READ_ONLY variable for all methods but setSizeRaw(int newSize) !!! + * If you violate this principle in subclasses, you should exactly know what you are doing. + * @serial + */ + protected int size; /** * Makes this class non instantiable, but still let's others inherit from it. */ @@ -35,7 +35,7 @@ * @param element element to be appended to this list. */ public void add(boolean element) { - beforeInsert(size,element); + beforeInsert(size,element); } /** * Appends the part of the specified list between from (inclusive) and to (inclusive) to the receiver. @@ -46,7 +46,7 @@ * @exception IndexOutOfBoundsException index is out of range (other.size()>0 && (from<0 || from>to || to>=other.size())). */ public void addAllOfFromTo(AbstractBooleanList other, int from, int to) { - beforeInsertAllOfFromTo(size,other,from,to); + beforeInsertAllOfFromTo(size,other,from,to); } /** * Inserts the specified element before the specified position into the receiver. @@ -58,8 +58,8 @@ * @exception IndexOutOfBoundsException index is out of range (index < 0 || index > size()). */ public void beforeInsert(int index, boolean element) { - beforeInsertDummies(index,1); - set(index,element); + beforeInsertDummies(index,1); + set(index,element); } /** * Inserts the part of the specified list between otherFrom (inclusive) and otherTo (inclusive) before the specified position into the receiver. @@ -74,9 +74,9 @@ * @exception IndexOutOfBoundsException index is out of range (index < 0 || index > size()). */ public void beforeInsertAllOfFromTo(int index, AbstractBooleanList other, int from, int to) { - int length=to-from+1; - this.beforeInsertDummies(index, length); - this.replaceFromToWithFrom(index, index+length-1, other, from); + int length=to-from+1; + this.beforeInsertDummies(index, length); + this.replaceFromToWithFrom(index, index+length-1, other, from); } /** * Inserts length dummy elements before the specified position into the receiver. @@ -89,13 +89,13 @@ * @throws IndexOutOfBoundsException if index < 0 || index > size(). */ protected void beforeInsertDummies(int index, int length) { - if (index > size || index < 0) - throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size); - if (length > 0) { - ensureCapacity(size + length); - setSizeRaw(size + length); - replaceFromToWithFrom(index+length,size-1,this,index); - } + if (index > size || index < 0) + throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size); + if (length > 0) { + ensureCapacity(size + length); + setSizeRaw(size + length); + replaceFromToWithFrom(index+length,size-1,this,index); + } } /** * Searches the receiver for the specified value using @@ -108,17 +108,17 @@ * * @param key the value to be searched for. * @return index of the search key, if it is contained in the receiver; - * otherwise, (-(insertion point) - 1). The insertion - * point is defined as the the point at which the value would - * be inserted into the receiver: the index of the first - * element greater than the key, or receiver.size(), if all - * elements in the receiver are less than the specified key. Note - * that this guarantees that the return value will be >= 0 if - * and only if the key is found. + * otherwise, (-(insertion point) - 1). The insertion + * point is defined as the the point at which the value would + * be inserted into the receiver: the index of the first + * element greater than the key, or receiver.size(), if all + * elements in the receiver are less than the specified key. Note + * that this guarantees that the return value will be >= 0 if + * and only if the key is found. * @see java.util.Arrays */ public int binarySearch(boolean key) { - return this.binarySearchFromTo(key, 0, size-1); + return this.binarySearchFromTo(key, 0, size-1); } /** * Searches the receiver for the specified value using @@ -133,28 +133,28 @@ * @param from the leftmost search position, inclusive. * @param to the rightmost search position, inclusive. * @return index of the search key, if it is contained in the receiver; - * otherwise, (-(insertion point) - 1). The insertion - * point is defined as the the point at which the value would - * be inserted into the receiver: the index of the first - * element greater than the key, or receiver.size(), if all - * elements in the receiver are less than the specified key. Note - * that this guarantees that the return value will be >= 0 if - * and only if the key is found. + * otherwise, (-(insertion point) - 1). The insertion + * point is defined as the the point at which the value would + * be inserted into the receiver: the index of the first + * element greater than the key, or receiver.size(), if all + * elements in the receiver are less than the specified key. Note + * that this guarantees that the return value will be >= 0 if + * and only if the key is found. * @see java.util.Arrays */ public int binarySearchFromTo(boolean key, int from, int to) { - int low=from; - int high=to; - int intKey = toInt(key); - while (low <= high) { - int mid =(low + high)/2; - boolean midVal = get(mid); - - if (toInt(midVal) < intKey) low = mid + 1; - else if (toInt(midVal) > intKey) high = mid - 1; - else return mid; // key found - } - return -(low + 1); // key not found. + int low=from; + int high=to; + int intKey = toInt(key); + while (low <= high) { + int mid =(low + high)/2; + boolean midVal = get(mid); + + if (toInt(midVal) < intKey) low = mid + 1; + else if (toInt(midVal) > intKey) high = mid - 1; + else return mid; // key found + } + return -(low + 1); // key not found. } /** * Returns a deep copy of the receiver. @@ -162,7 +162,7 @@ * @return a deep copy of the receiver. */ public Object clone() { - return partFromTo(0,size-1); + return partFromTo(0,size-1); } /** * Returns true if the receiver contains the specified element. @@ -170,7 +170,7 @@ * @param element element whose presence in the receiver is to be tested. */ public boolean contains(boolean elem) { - return indexOfFromTo(elem,0,size-1) >=0; + return indexOfFromTo(elem,0,size-1) >=0; } /** * Deletes the first element from the receiver that is identical to the specified element. @@ -179,8 +179,8 @@ * @param element the element to be deleted. */ public void delete(boolean element) { - int index = indexOfFromTo(element, 0, size-1); - if (index>=0) remove(index); + int index = indexOfFromTo(element, 0, size-1); + if (index>=0) remove(index); } /** * Returns the elements currently stored, possibly including invalid elements between size and capacity. @@ -191,9 +191,9 @@ * @return the elements currently stored. */ public boolean[] elements() { - boolean[] myElements = new boolean[size]; - for (int i=size; --i >= 0; ) myElements[i]=getQuick(i); - return myElements; + boolean[] myElements = new boolean[size]; + for (int i=size; --i >= 0; ) myElements[i]=getQuick(i); + return myElements; } /** * Sets the receiver's elements to be the specified array. @@ -205,9 +205,9 @@ * @return the receiver itself. */ public AbstractBooleanList elements(boolean[] elements) { - clear(); - addAllOfFromTo(new BooleanArrayList(elements),0,elements.length-1); - return this; + clear(); + addAllOfFromTo(new BooleanArrayList(elements),0,elements.length-1); + return this; } /** * Ensures that the receiver can hold at least the specified number of elements without needing to allocate new internal memory. @@ -227,16 +227,16 @@ * @return true if the specified Object is equal to the receiver. */ public boolean equals(Object otherObj) { //delta - if (! (otherObj instanceof AbstractBooleanList)) {return false;} - if (this==otherObj) return true; - if (otherObj==null) return false; - AbstractBooleanList other = (AbstractBooleanList) otherObj; - if (size()!=other.size()) return false; - - for (int i=size(); --i >= 0; ) { - if (getQuick(i) != other.getQuick(i)) return false; - } - return true; + if (! (otherObj instanceof AbstractBooleanList)) {return false;} + if (this==otherObj) return true; + if (otherObj==null) return false; + AbstractBooleanList other = (AbstractBooleanList) otherObj; + if (size()!=other.size()) return false; + + for (int i=size(); --i >= 0; ) { + if (getQuick(i) != other.getQuick(i)) return false; + } + return true; } /** * Sets the specified range of elements in the specified array to the specified value. @@ -246,8 +246,8 @@ * @param val the value to be stored in the specified elements of the receiver. */ public void fillFromToWith(int from, int to, boolean val) { - checkRangeFromTo(from,to,this.size); - for (int i=from; i<=to;) setQuick(i++,val); + checkRangeFromTo(from,to,this.size); + for (int i=from; i<=to;) setQuick(i++,val); } /** * Applies a procedure to each element of the receiver, if any. @@ -256,20 +256,20 @@ * @return false if the procedure stopped before all elements where iterated over, true otherwise. */ public boolean forEach(BooleanProcedure procedure) { - for (int i=0; i= size || index < 0) - throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size); - return getQuick(index); + if (index >= size || index < 0) + throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size); + return getQuick(index); } /** * Returns the element at the specified position in the receiver; WARNING: Does not check preconditions. @@ -291,7 +291,7 @@ * @return the index of the first occurrence of the element in the receiver; returns -1 if the element is not found. */ public int indexOf(boolean element) { //delta - return indexOfFromTo(element, 0, size-1); + return indexOfFromTo(element, 0, size-1); } /** * Returns the index of the first occurrence of the specified @@ -306,12 +306,12 @@ * @exception IndexOutOfBoundsException index is out of range (size()>0 && (from<0 || from>to || to>=size())). */ public int indexOfFromTo(boolean element, int from, int to) { - checkRangeFromTo(from, to, size); + checkRangeFromTo(from, to, size); - for (int i = from ; i <= to; i++) { - if (element==getQuick(i)) return i; //found - } - return -1; //not found + for (int i = from ; i <= to; i++) { + if (element==getQuick(i)) return i; //found + } + return -1; //not found } /** * Returns the index of the last occurrence of the specified @@ -321,7 +321,7 @@ * @return the index of the last occurrence of the element in the receiver; returns -1 if the element is not found. */ public int lastIndexOf(boolean element) { - return lastIndexOfFromTo(element, 0, size-1); + return lastIndexOfFromTo(element, 0, size-1); } /** * Returns the index of the last occurrence of the specified @@ -336,12 +336,12 @@ * @exception IndexOutOfBoundsException index is out of range (size()>0 && (from<0 || from>to || to>=size())). */ public int lastIndexOfFromTo(boolean element, int from, int to) { - checkRangeFromTo(from, to, size()); + checkRangeFromTo(from, to, size()); - for (int i = to ; i >= from; i--) { - if (element==getQuick(i)) return i; //found - } - return -1; //not found + for (int i = to ; i >= from; i--) { + if (element==getQuick(i)) return i; //found + } + return -1; //not found } /** * Returns a new list of the part of the receiver between from, inclusive, and to, inclusive. @@ -351,12 +351,12 @@ * @exception IndexOutOfBoundsException index is out of range (size()>0 && (from<0 || from>to || to>=size())). */ public AbstractBooleanList partFromTo(int from, int to) { - checkRangeFromTo(from, to, size); + checkRangeFromTo(from, to, size); - int length = to-from+1; - BooleanArrayList part = new BooleanArrayList(length); - part.addAllOfFromTo(this,from,to); - return part; + int length = to-from+1; + BooleanArrayList part = new BooleanArrayList(length); + part.addAllOfFromTo(this,from,to); + return part; } /** * Removes from the receiver all elements that are contained in the specified list. @@ -366,17 +366,17 @@ * @return true if the receiver changed as a result of the call. */ public boolean removeAll(AbstractBooleanList other) { - if (other.size()==0) return false; //nothing to do - int limit = other.size()-1; - int j=0; - - for (int i=0; isize()>0 && (from<0 || from>to || to>=size())). */ public void removeFromTo(int from, int to) { - checkRangeFromTo(from, to, size); - int numMoved = size - to - 1; - if (numMoved > 0) { - replaceFromToWithFrom(from, from-1+numMoved, this, to+1); - //fillFromToWith(from+numMoved, size-1, 0.0f); //delta - } - int width = to-from+1; - if (width>0) setSizeRaw(size-width); + checkRangeFromTo(from, to, size); + int numMoved = size - to - 1; + if (numMoved > 0) { + replaceFromToWithFrom(from, from-1+numMoved, this, to+1); + //fillFromToWith(from+numMoved, size-1, 0.0f); //delta + } + int width = to-from+1; + if (width>0) setSizeRaw(size-width); } /** * Replaces a number of elements in the receiver with the same number of elements of another list. @@ -409,22 +409,22 @@ * @param otherFrom position of first element within other list to be copied. */ public void replaceFromToWithFrom(int from, int to, AbstractBooleanList other, int otherFrom) { - int length=to-from+1; - if (length>0) { - checkRangeFromTo(from, to, size()); - checkRangeFromTo(otherFrom,otherFrom+length-1,other.size()); - - // unambiguous copy (it may hold other==this) - if (from<=otherFrom) { - for (; --length >= 0; ) setQuick(from++,other.getQuick(otherFrom++)); - } - else { - int otherTo = otherFrom+length-1; - for (; --length >= 0; ) setQuick(to--,other.getQuick(otherTo--)); - } + int length=to-from+1; + if (length>0) { + checkRangeFromTo(from, to, size()); + checkRangeFromTo(otherFrom,otherFrom+length-1,other.size()); + + // unambiguous copy (it may hold other==this) + if (from<=otherFrom) { + for (; --length >= 0; ) setQuick(from++,other.getQuick(otherFrom++)); + } + else { + int otherTo = otherFrom+length-1; + for (; --length >= 0; ) setQuick(to--,other.getQuick(otherTo--)); + } - - } + + } } /** * Replaces the part between from (inclusive) and to (inclusive) with the other list's @@ -470,36 +470,36 @@ * */ public void replaceFromToWithFromTo(int from, int to, AbstractBooleanList other, int otherFrom, int otherTo) { - if (otherFrom>otherTo) { - throw new IndexOutOfBoundsException("otherFrom: "+otherFrom+", otherTo: "+otherTo); - } - - if (this==other && to-from!=otherTo-otherFrom) { // avoid stumbling over my own feet - replaceFromToWithFromTo(from, to, partFromTo(otherFrom, otherTo), 0, otherTo-otherFrom); - return; - } - - int length=otherTo-otherFrom+1; - int diff=length; - int theLast=from-1; - - if (to>=from) { - diff -= (to-from+1); - theLast=to; - } - - if (diff>0) { - beforeInsertDummies(theLast+1, diff); - } - else { - if (diff<0) { - removeFromTo(theLast+diff, theLast-1); - } - } - - if (length>0) { - replaceFromToWithFrom(from,from+length-1,other,otherFrom); - } + if (otherFrom>otherTo) { + throw new IndexOutOfBoundsException("otherFrom: "+otherFrom+", otherTo: "+otherTo); + } + + if (this==other && to-from!=otherTo-otherFrom) { // avoid stumbling over my own feet + replaceFromToWithFromTo(from, to, partFromTo(otherFrom, otherTo), 0, otherTo-otherFrom); + return; + } + + int length=otherTo-otherFrom+1; + int diff=length; + int theLast=from-1; + + if (to>=from) { + diff -= (to-from+1); + theLast=to; + } + + if (diff>0) { + beforeInsertDummies(theLast+1, diff); + } + else { + if (diff<0) { + removeFromTo(theLast+diff, theLast-1); + } + } + + if (length>0) { + replaceFromToWithFrom(from,from+length-1,other,otherFrom); + } } /** * Replaces the part of the receiver starting at from (inclusive) with all the elements of the specified collection. @@ -511,12 +511,12 @@ * @exception IndexOutOfBoundsException index is out of range (index < 0 || index >= size()). */ public void replaceFromWith(int from, java.util.Collection other) { - checkRange(from,size()); - java.util.Iterator e = other.iterator(); - int index=from; - int limit = Math.min(size()-from, other.size()); - for (int i=0; itrue if the receiver changed as a result of the call. */ public boolean retainAll(AbstractBooleanList other) { - if (other.size()==0) { - if (size==0) return false; - setSize(0); - return true; - } - - int limit = other.size()-1; - int j=0; - for (int i=0; i= 0) setQuick(j++, getQuick(i)); - } - - boolean modified = (j!=size); - setSize(j); - return modified; + if (other.size()==0) { + if (size==0) return false; + setSize(0); + return true; + } + + int limit = other.size()-1; + int j=0; + for (int i=0; i= 0) setQuick(j++, getQuick(i)); + } + + boolean modified = (j!=size); + setSize(j); + return modified; } /** * Reverses the elements of the receiver. * Last becomes first, second last becomes second first, and so on. */ public void reverse() { - boolean tmp; - int limit=size()/2; - int j=size()-1; - - for (int i=0; iindex < 0 || index >= size(). */ public void set(int index, boolean element) { - if (index >= size || index < 0) - throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size); - setQuick(index,element); + if (index >= size || index < 0) + throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size); + setQuick(index,element); } /** * Replaces the element at the specified position in the receiver with the specified element; WARNING: Does not check preconditions. @@ -598,7 +598,7 @@ * } */ protected void setSizeRaw(int newSize) { - size = newSize; + size = newSize; } /** * Randomly permutes the part of the receiver between from (inclusive) and to (inclusive). @@ -607,17 +607,17 @@ * @exception IndexOutOfBoundsException index is out of range (size()>0 && (from<0 || from>to || to>=size())). */ public void shuffleFromTo(int from, int to) { - checkRangeFromTo(from, to, size()); - - org.apache.mahout.jet.random.Uniform gen = new org.apache.mahout.jet.random.Uniform(new org.apache.mahout.jet.random.engine.DRand(new java.util.Date())); - for (int i=from; itimes times the receiver. * @param times the number of times the receiver shall be copied. */ public AbstractBooleanList times(int times) { - AbstractBooleanList newList = new BooleanArrayList(times*size()); - for (int i=times; --i >= 0; ) { - newList.addAllOfFromTo(this,0,size()-1); - } - return newList; + AbstractBooleanList newList = new BooleanArrayList(times*size()); + for (int i=times; --i >= 0; ) { + newList.addAllOfFromTo(this,0,size()-1); + } + return newList; } /** * Transforms a boolean value to an integer (false --> 0, true --> 1) */ protected static int toInt(boolean value) { - return value ? 1 : 0; + return value ? 1 : 0; } /** * Returns a java.util.ArrayList containing all the elements in the receiver. */ public java.util.ArrayList toList() { - int mySize = size(); - java.util.ArrayList list = new java.util.ArrayList(mySize); - for (int i=0; i < mySize; i++) list.add(new Boolean(get(i))); - return list; + int mySize = size(); + java.util.ArrayList list = new java.util.ArrayList(mySize); + for (int i=0; i < mySize; i++) list.add(new Boolean(get(i))); + return list; } /** * Returns a string representation of the receiver, containing * the String representation of each element. */ public String toString() { - return org.apache.mahout.matrix.Arrays.toString(partFromTo(0, size()-1).elements()); + return org.apache.mahout.matrix.Arrays.toString(partFromTo(0, size()-1).elements()); } }