package refactoring
git-svn-id: https://osmand.googlecode.com/svn/trunk@603 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
d1f0dd612d
commit
7b74443a8e
40 changed files with 1 additions and 8830 deletions
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry excluding="net/osmand/ExceptionHandler.java|net/osmand/LogUtil.java|net/osmand/osm/io/OsmStorageWriter.java|net/osmand/osm/util/|net/osmand/swing/|net/osmand/data/index/IndexBatchCreator.java|net/osmand/data/preparation/DataExtraction.java|net/osmand/data/preparation/IndexCreator.java|crosby/binary/|rtree/|net/osmand/data/index/DataIndexWriter.java" kind="src" path="use"/>
|
||||
<classpathentry excluding="net/osmand/ExceptionHandler.java|net/osmand/LogUtil.java|net/osmand/osm/io/OsmStorageWriter.java|net/osmand/osm/util/|net/osmand/swing/|net/osmand/data/index/IndexBatchCreator.java|net/osmand/data/preparation/DataExtraction.java|net/osmand/data/preparation/IndexCreator.java|rtree/|net/osmand/data/index/DataIndexWriter.java" kind="src" path="use"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="lib" path="lib/bzip2-20090327.jar"/>
|
||||
<classpathentry kind="lib" path="lib/tuprolog.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junidecode-0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/osm-pbf.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
Binary file not shown.
|
@ -1,316 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
import gnu.trove.iterator.TFloatIterator;
|
||||
import gnu.trove.procedure.TFloatProcedure;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An interface that mimics the <tt>Collection</tt> interface.
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden
|
||||
* @author Jeff Randall
|
||||
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TFloatCollection extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
float getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this collection (its cardinality). If this
|
||||
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of elements in this collection (its cardinality)
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this collection contains no elements.
|
||||
*
|
||||
* @return <tt>true</tt> if this collection contains no elements
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this collection contains the specified element.
|
||||
*
|
||||
* @param entry an <code>float</code> value
|
||||
* @return true if the collection contains the specified element.
|
||||
*/
|
||||
boolean contains( float entry );
|
||||
|
||||
|
||||
/**
|
||||
* Creates an iterator over the values of the collection. The iterator
|
||||
* supports element deletion.
|
||||
*
|
||||
* @return an <code>TFloatIterator</code> value
|
||||
*/
|
||||
TFloatIterator iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this collection.
|
||||
* If this collection makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the
|
||||
* elements in the same order.
|
||||
*
|
||||
* <p>The returned array will be "safe" in that no references to it
|
||||
* are maintained by this collection. (In other words, this method must
|
||||
* allocate a new array even if this collection is backed by an array).
|
||||
* The caller is thus free to modify the returned array.
|
||||
*
|
||||
* <p>This method acts as bridge between array-based and collection-based
|
||||
* APIs.
|
||||
*
|
||||
* @return an array containing all the elements in this collection
|
||||
*/
|
||||
float[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing elements in this collection.
|
||||
*
|
||||
* <p>If this collection fits in the specified array with room to spare
|
||||
* (i.e., the array has more elements than this collection), the element in
|
||||
* the array immediately following the end of the collection is collection to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
|
||||
* the length of this collection <i>only</i> if the caller knows that this
|
||||
* collection does not contain any elements representing null.)
|
||||
*
|
||||
* <p>If the native array is smaller than the collection size,
|
||||
* the array will be filled with elements in Iterator order
|
||||
* until it is full and exclude the remainder.
|
||||
*
|
||||
* <p>If this collection makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the elements
|
||||
* in the same order.
|
||||
*
|
||||
* @param dest the array into which the elements of this collection are to be
|
||||
* stored.
|
||||
* @return an <tt>float[]</tt> containing all the elements in this collection
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
float[] toArray( float[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a value into the collection.
|
||||
*
|
||||
* @param entry a <code>float</code> value
|
||||
* @return true if the collection was modified by the add operation
|
||||
*/
|
||||
boolean add( float entry );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>entry</tt> from the collection.
|
||||
*
|
||||
* @param entry an <code>float</code> value
|
||||
* @return true if the collection was modified by the remove operation.
|
||||
*/
|
||||
boolean remove( float entry );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>collection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>TFloatCollection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>array</tt> are present.
|
||||
*
|
||||
* @param array as <code>array</code> of float primitives.
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in <tt>collection</tt> to the collection.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( Collection<? extends Float> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>TFloatCollection</tt> to the collection.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>array</tt> to the collection.
|
||||
*
|
||||
* @param array a <code>array</code> of float primitives.
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>collection</tt>.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>TFloatCollection</tt>.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>array</tt>.
|
||||
*
|
||||
* @param array an <code>array</code> of float primitives.
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>collection</tt> from the collection.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>TFloatCollection</tt> from the collection.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>array</tt> from the collection.
|
||||
*
|
||||
* @param array an <code>array</code> of float primitives.
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Empties the collection.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the collection.
|
||||
*
|
||||
* @param procedure a <code>TFloatProcedure</code> value
|
||||
* @return false if the loop over the collection terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
boolean forEach( TFloatProcedure procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this collection for equality. Returns
|
||||
* <tt>true</tt> if the specified object is also a collection, the two collection
|
||||
* have the same size, and every member of the specified collection is
|
||||
* contained in this collection (or equivalently, every member of this collection is
|
||||
* contained in the specified collection). This definition ensures that the
|
||||
* equals method works properly across different implementations of the
|
||||
* collection interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this collection
|
||||
* @return <tt>true</tt> if the specified object is equal to this collection
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this collection. The hash code of a collection is
|
||||
* defined to be the sum of the hash codes of the elements in the collection.
|
||||
* This ensures that <tt>s1.equals(s2)</tt> implies that
|
||||
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
|
||||
* and <tt>s2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this collection
|
||||
* @see Object#equals(Object)
|
||||
* @see Collection#equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
|
||||
} // TFloatCollection
|
|
@ -1,316 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
import gnu.trove.iterator.TIntIterator;
|
||||
import gnu.trove.procedure.TIntProcedure;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An interface that mimics the <tt>Collection</tt> interface.
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden
|
||||
* @author Jeff Randall
|
||||
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TIntCollection extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
int getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this collection (its cardinality). If this
|
||||
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of elements in this collection (its cardinality)
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this collection contains no elements.
|
||||
*
|
||||
* @return <tt>true</tt> if this collection contains no elements
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this collection contains the specified element.
|
||||
*
|
||||
* @param entry an <code>int</code> value
|
||||
* @return true if the collection contains the specified element.
|
||||
*/
|
||||
boolean contains( int entry );
|
||||
|
||||
|
||||
/**
|
||||
* Creates an iterator over the values of the collection. The iterator
|
||||
* supports element deletion.
|
||||
*
|
||||
* @return an <code>TIntIterator</code> value
|
||||
*/
|
||||
TIntIterator iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this collection.
|
||||
* If this collection makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the
|
||||
* elements in the same order.
|
||||
*
|
||||
* <p>The returned array will be "safe" in that no references to it
|
||||
* are maintained by this collection. (In other words, this method must
|
||||
* allocate a new array even if this collection is backed by an array).
|
||||
* The caller is thus free to modify the returned array.
|
||||
*
|
||||
* <p>This method acts as bridge between array-based and collection-based
|
||||
* APIs.
|
||||
*
|
||||
* @return an array containing all the elements in this collection
|
||||
*/
|
||||
int[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing elements in this collection.
|
||||
*
|
||||
* <p>If this collection fits in the specified array with room to spare
|
||||
* (i.e., the array has more elements than this collection), the element in
|
||||
* the array immediately following the end of the collection is collection to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
|
||||
* the length of this collection <i>only</i> if the caller knows that this
|
||||
* collection does not contain any elements representing null.)
|
||||
*
|
||||
* <p>If the native array is smaller than the collection size,
|
||||
* the array will be filled with elements in Iterator order
|
||||
* until it is full and exclude the remainder.
|
||||
*
|
||||
* <p>If this collection makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the elements
|
||||
* in the same order.
|
||||
*
|
||||
* @param dest the array into which the elements of this collection are to be
|
||||
* stored.
|
||||
* @return an <tt>int[]</tt> containing all the elements in this collection
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
int[] toArray( int[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a value into the collection.
|
||||
*
|
||||
* @param entry a <code>int</code> value
|
||||
* @return true if the collection was modified by the add operation
|
||||
*/
|
||||
boolean add( int entry );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>entry</tt> from the collection.
|
||||
*
|
||||
* @param entry an <code>int</code> value
|
||||
* @return true if the collection was modified by the remove operation.
|
||||
*/
|
||||
boolean remove( int entry );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>collection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>TIntCollection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>array</tt> are present.
|
||||
*
|
||||
* @param array as <code>array</code> of int primitives.
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in <tt>collection</tt> to the collection.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( Collection<? extends Integer> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>TIntCollection</tt> to the collection.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>array</tt> to the collection.
|
||||
*
|
||||
* @param array a <code>array</code> of int primitives.
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>collection</tt>.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>TIntCollection</tt>.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>array</tt>.
|
||||
*
|
||||
* @param array an <code>array</code> of int primitives.
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>collection</tt> from the collection.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>TIntCollection</tt> from the collection.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>array</tt> from the collection.
|
||||
*
|
||||
* @param array an <code>array</code> of int primitives.
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Empties the collection.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the collection.
|
||||
*
|
||||
* @param procedure a <code>TIntProcedure</code> value
|
||||
* @return false if the loop over the collection terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
boolean forEach( TIntProcedure procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this collection for equality. Returns
|
||||
* <tt>true</tt> if the specified object is also a collection, the two collection
|
||||
* have the same size, and every member of the specified collection is
|
||||
* contained in this collection (or equivalently, every member of this collection is
|
||||
* contained in the specified collection). This definition ensures that the
|
||||
* equals method works properly across different implementations of the
|
||||
* collection interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this collection
|
||||
* @return <tt>true</tt> if the specified object is equal to this collection
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this collection. The hash code of a collection is
|
||||
* defined to be the sum of the hash codes of the elements in the collection.
|
||||
* This ensures that <tt>s1.equals(s2)</tt> implies that
|
||||
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
|
||||
* and <tt>s2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this collection
|
||||
* @see Object#equals(Object)
|
||||
* @see Collection#equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
|
||||
} // TIntCollection
|
|
@ -1,316 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
import gnu.trove.iterator.TLongIterator;
|
||||
import gnu.trove.procedure.TLongProcedure;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An interface that mimics the <tt>Collection</tt> interface.
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden
|
||||
* @author Jeff Randall
|
||||
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TLongCollection extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
long getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this collection (its cardinality). If this
|
||||
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of elements in this collection (its cardinality)
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this collection contains no elements.
|
||||
*
|
||||
* @return <tt>true</tt> if this collection contains no elements
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this collection contains the specified element.
|
||||
*
|
||||
* @param entry an <code>long</code> value
|
||||
* @return true if the collection contains the specified element.
|
||||
*/
|
||||
boolean contains( long entry );
|
||||
|
||||
|
||||
/**
|
||||
* Creates an iterator over the values of the collection. The iterator
|
||||
* supports element deletion.
|
||||
*
|
||||
* @return an <code>TLongIterator</code> value
|
||||
*/
|
||||
TLongIterator iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this collection.
|
||||
* If this collection makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the
|
||||
* elements in the same order.
|
||||
*
|
||||
* <p>The returned array will be "safe" in that no references to it
|
||||
* are maintained by this collection. (In other words, this method must
|
||||
* allocate a new array even if this collection is backed by an array).
|
||||
* The caller is thus free to modify the returned array.
|
||||
*
|
||||
* <p>This method acts as bridge between array-based and collection-based
|
||||
* APIs.
|
||||
*
|
||||
* @return an array containing all the elements in this collection
|
||||
*/
|
||||
long[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing elements in this collection.
|
||||
*
|
||||
* <p>If this collection fits in the specified array with room to spare
|
||||
* (i.e., the array has more elements than this collection), the element in
|
||||
* the array immediately following the end of the collection is collection to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
|
||||
* the length of this collection <i>only</i> if the caller knows that this
|
||||
* collection does not contain any elements representing null.)
|
||||
*
|
||||
* <p>If the native array is smaller than the collection size,
|
||||
* the array will be filled with elements in Iterator order
|
||||
* until it is full and exclude the remainder.
|
||||
*
|
||||
* <p>If this collection makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the elements
|
||||
* in the same order.
|
||||
*
|
||||
* @param dest the array into which the elements of this collection are to be
|
||||
* stored.
|
||||
* @return an <tt>long[]</tt> containing all the elements in this collection
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
long[] toArray( long[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a value into the collection.
|
||||
*
|
||||
* @param entry a <code>long</code> value
|
||||
* @return true if the collection was modified by the add operation
|
||||
*/
|
||||
boolean add( long entry );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>entry</tt> from the collection.
|
||||
*
|
||||
* @param entry an <code>long</code> value
|
||||
* @return true if the collection was modified by the remove operation.
|
||||
*/
|
||||
boolean remove( long entry );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>collection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>TLongCollection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the collection to determine if all of the elements in
|
||||
* <tt>array</tt> are present.
|
||||
*
|
||||
* @param array as <code>array</code> of long primitives.
|
||||
* @return true if all elements were present in the collection.
|
||||
*/
|
||||
boolean containsAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in <tt>collection</tt> to the collection.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( Collection<? extends Long> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>TLongCollection</tt> to the collection.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>array</tt> to the collection.
|
||||
*
|
||||
* @param array a <code>array</code> of long primitives.
|
||||
* @return true if the collection was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>collection</tt>.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>TLongCollection</tt>.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the collection which are not contained in
|
||||
* <tt>array</tt>.
|
||||
*
|
||||
* @param array an <code>array</code> of long primitives.
|
||||
* @return true if the collection was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>collection</tt> from the collection.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>TLongCollection</tt> from the collection.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>array</tt> from the collection.
|
||||
*
|
||||
* @param array an <code>array</code> of long primitives.
|
||||
* @return true if the collection was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Empties the collection.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the collection.
|
||||
*
|
||||
* @param procedure a <code>TLongProcedure</code> value
|
||||
* @return false if the loop over the collection terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
boolean forEach( TLongProcedure procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this collection for equality. Returns
|
||||
* <tt>true</tt> if the specified object is also a collection, the two collection
|
||||
* have the same size, and every member of the specified collection is
|
||||
* contained in this collection (or equivalently, every member of this collection is
|
||||
* contained in the specified collection). This definition ensures that the
|
||||
* equals method works properly across different implementations of the
|
||||
* collection interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this collection
|
||||
* @return <tt>true</tt> if the specified object is equal to this collection
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this collection. The hash code of a collection is
|
||||
* defined to be the sum of the hash codes of the elements in the collection.
|
||||
* This ensures that <tt>s1.equals(s2)</tt> implies that
|
||||
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
|
||||
* and <tt>s2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this collection
|
||||
* @see Object#equals(Object)
|
||||
* @see Collection#equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
|
||||
} // TLongCollection
|
|
@ -1,37 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.function;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for functions that accept and return one float primitive.
|
||||
*/
|
||||
public interface TFloatFunction {
|
||||
/**
|
||||
* Execute this function with <tt>value</tt>
|
||||
*
|
||||
* @param value a <code>float</code> input
|
||||
* @return a <code>float</code> result
|
||||
*/
|
||||
public float execute( float value );
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.function;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for functions that accept and return one int primitive.
|
||||
*/
|
||||
public interface TIntFunction {
|
||||
/**
|
||||
* Execute this function with <tt>value</tt>
|
||||
*
|
||||
* @param value a <code>int</code> input
|
||||
* @return a <code>int</code> result
|
||||
*/
|
||||
public int execute( int value );
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.function;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for functions that accept and return one long primitive.
|
||||
*/
|
||||
public interface TLongFunction {
|
||||
/**
|
||||
* Execute this function with <tt>value</tt>
|
||||
*
|
||||
* @param value a <code>long</code> input
|
||||
* @return a <code>long</code> result
|
||||
*/
|
||||
public long execute( long value );
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.function;
|
||||
|
||||
/**
|
||||
* Interface for functions that accept and return one Object reference.
|
||||
* <p/>
|
||||
* Created: Mon Nov 5 22:19:36 2001
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @version $Id: TObjectFunction.java,v 1.1.2.1 2009/09/06 17:02:19 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TObjectFunction<T, R> {
|
||||
|
||||
/**
|
||||
* Execute this function with <tt>value</tt>
|
||||
*
|
||||
* @param value an <code>Object</code> input
|
||||
* @return an <code>Object</code> result
|
||||
*/
|
||||
public R execute( T value );
|
||||
}// TObjectFunction
|
|
@ -1,165 +0,0 @@
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
package gnu.trove.impl;
|
||||
|
||||
/**
|
||||
* Central location for constants needed by various implementations.
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
private static final boolean VERBOSE =
|
||||
System.getProperty( "gnu.trove.verbose", null ) != null;
|
||||
|
||||
/** the default capacity for new collections */
|
||||
public static final int DEFAULT_CAPACITY = 10;
|
||||
|
||||
/** the load above which rehashing occurs. */
|
||||
public static final float DEFAULT_LOAD_FACTOR = 0.5f;
|
||||
|
||||
|
||||
/** the default value that represents for <tt>byte</tt> types. */
|
||||
public static final byte DEFAULT_BYTE_NO_ENTRY_VALUE;
|
||||
static {
|
||||
byte value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.byte", "0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Byte.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Byte.MIN_VALUE;
|
||||
else value = Byte.valueOf( property );
|
||||
|
||||
if ( value > Byte.MAX_VALUE ) value = Byte.MAX_VALUE;
|
||||
else if ( value < Byte.MIN_VALUE ) value = Byte.MIN_VALUE;
|
||||
DEFAULT_BYTE_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_BYTE_NO_ENTRY_VALUE: " +
|
||||
DEFAULT_BYTE_NO_ENTRY_VALUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** the default value that represents for <tt>short</tt> types. */
|
||||
public static final short DEFAULT_SHORT_NO_ENTRY_VALUE;
|
||||
static {
|
||||
short value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.short", "0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Short.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Short.MIN_VALUE;
|
||||
else value = Short.valueOf( property );
|
||||
|
||||
if ( value > Short.MAX_VALUE ) value = Short.MAX_VALUE;
|
||||
else if ( value < Short.MIN_VALUE ) value = Short.MIN_VALUE;
|
||||
DEFAULT_SHORT_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_SHORT_NO_ENTRY_VALUE: " +
|
||||
DEFAULT_SHORT_NO_ENTRY_VALUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** the default value that represents for <tt>char</tt> types. */
|
||||
public static final char DEFAULT_CHAR_NO_ENTRY_VALUE;
|
||||
static {
|
||||
char value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.char", "\0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Character.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Character.MIN_VALUE;
|
||||
else value = property.toCharArray()[0];
|
||||
|
||||
if ( value > Character.MAX_VALUE ) value = Character.MAX_VALUE;
|
||||
else if ( value < Character.MIN_VALUE ) value = Character.MIN_VALUE;
|
||||
DEFAULT_CHAR_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_CHAR_NO_ENTRY_VALUE: " +
|
||||
Integer.valueOf( value ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** the default value that represents for <tt>int</tt> types. */
|
||||
public static final int DEFAULT_INT_NO_ENTRY_VALUE;
|
||||
static {
|
||||
int value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.int", "0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Integer.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Integer.MIN_VALUE;
|
||||
else value = Integer.valueOf( property );
|
||||
DEFAULT_INT_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_INT_NO_ENTRY_VALUE: " +
|
||||
DEFAULT_INT_NO_ENTRY_VALUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** the default value that represents for <tt>long</tt> types. */
|
||||
public static final long DEFAULT_LONG_NO_ENTRY_VALUE;
|
||||
static {
|
||||
long value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.long", "0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Long.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Long.MIN_VALUE;
|
||||
else value = Long.valueOf( property );
|
||||
DEFAULT_LONG_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_LONG_NO_ENTRY_VALUE: " +
|
||||
DEFAULT_LONG_NO_ENTRY_VALUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** the default value that represents for <tt>float</tt> types. */
|
||||
public static final float DEFAULT_FLOAT_NO_ENTRY_VALUE;
|
||||
static {
|
||||
float value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.float", "0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Float.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Float.MIN_VALUE;
|
||||
// Value from Float.MIN_NORMAL (introduced in 1.6)
|
||||
else if ( "MIN_NORMAL".equalsIgnoreCase( property ) ) value = 0x1.0p-126f;
|
||||
else if ( "NEGATIVE_INFINITY".equalsIgnoreCase( property ) ) value = Float.NEGATIVE_INFINITY;
|
||||
else if ( "POSITIVE_INFINITY".equalsIgnoreCase( property ) ) value = Float.POSITIVE_INFINITY;
|
||||
// else if ( "NaN".equalsIgnoreCase( property ) ) value = Float.NaN;
|
||||
else value = Float.valueOf( property );
|
||||
DEFAULT_FLOAT_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_FLOAT_NO_ENTRY_VALUE: " +
|
||||
DEFAULT_FLOAT_NO_ENTRY_VALUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** the default value that represents for <tt>double</tt> types. */
|
||||
public static final double DEFAULT_DOUBLE_NO_ENTRY_VALUE;
|
||||
static {
|
||||
double value;
|
||||
String property = System.getProperty( "gnu.trove.no_entry.double", "0" );
|
||||
if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Double.MAX_VALUE;
|
||||
else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Double.MIN_VALUE;
|
||||
// Value from Double.MIN_NORMAL (introduced in 1.6)
|
||||
else if ( "MIN_NORMAL".equalsIgnoreCase( property ) ) value = 0x1.0p-1022;
|
||||
else if ( "NEGATIVE_INFINITY".equalsIgnoreCase( property ) ) value = Double.NEGATIVE_INFINITY;
|
||||
else if ( "POSITIVE_INFINITY".equalsIgnoreCase( property ) ) value = Double.POSITIVE_INFINITY;
|
||||
// else if ( "NaN".equalsIgnoreCase( property ) ) value = Double.NaN;
|
||||
else value = Double.valueOf( property );
|
||||
DEFAULT_DOUBLE_NO_ENTRY_VALUE = value;
|
||||
if ( VERBOSE ) {
|
||||
System.out.println( "DEFAULT_DOUBLE_NO_ENTRY_VALUE: " +
|
||||
DEFAULT_DOUBLE_NO_ENTRY_VALUE );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package gnu.trove.impl;
|
||||
|
||||
/*
|
||||
* @author Vladimir Yaroslavskiy
|
||||
* @version 2009.09.10 m765
|
||||
*/
|
||||
public class DualPivotQuicksort {
|
||||
|
||||
public static void sort(int[] a) {
|
||||
sort(a, 0, a.length);
|
||||
}
|
||||
|
||||
public static void sort(int[] a, int fromIndex, int toIndex) {
|
||||
rangeCheck(a.length, fromIndex, toIndex);
|
||||
dualPivotQuicksort(a, fromIndex, toIndex - 1, 3);
|
||||
}
|
||||
|
||||
private static void rangeCheck(int length, int fromIndex, int toIndex) {
|
||||
if (fromIndex > toIndex) {
|
||||
throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
|
||||
}
|
||||
if (fromIndex < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(fromIndex);
|
||||
}
|
||||
if (toIndex > length) {
|
||||
throw new ArrayIndexOutOfBoundsException(toIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void swap(int[] a, int i, int j) {
|
||||
int temp = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = temp;
|
||||
}
|
||||
|
||||
private static void dualPivotQuicksort(int[] a, int left, int right, int div) {
|
||||
int len = right - left;
|
||||
|
||||
if (len < 27) { // insertion sort for tiny array
|
||||
for (int i = left + 1; i <= right; i++) {
|
||||
for (int j = i; j > left && a[j] < a[j - 1]; j--) {
|
||||
swap(a, j, j - 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
int third = len / div;
|
||||
|
||||
// "medians"
|
||||
int m1 = left + third;
|
||||
int m2 = right - third;
|
||||
|
||||
if (m1 <= left) {
|
||||
m1 = left + 1;
|
||||
}
|
||||
if (m2 >= right) {
|
||||
m2 = right - 1;
|
||||
}
|
||||
if (a[m1] < a[m2]) {
|
||||
swap(a, m1, left);
|
||||
swap(a, m2, right);
|
||||
}
|
||||
else {
|
||||
swap(a, m1, right);
|
||||
swap(a, m2, left);
|
||||
}
|
||||
// pivots
|
||||
int pivot1 = a[left];
|
||||
int pivot2 = a[right];
|
||||
|
||||
// pointers
|
||||
int less = left + 1;
|
||||
int great = right - 1;
|
||||
|
||||
// sorting
|
||||
for (int k = less; k <= great; k++) {
|
||||
if (a[k] < pivot1) {
|
||||
swap(a, k, less++);
|
||||
}
|
||||
else if (a[k] > pivot2) {
|
||||
while (k < great && a[great] > pivot2) {
|
||||
great--;
|
||||
}
|
||||
swap(a, k, great--);
|
||||
|
||||
if (a[k] < pivot1) {
|
||||
swap(a, k, less++);
|
||||
}
|
||||
}
|
||||
}
|
||||
// swaps
|
||||
int dist = great - less;
|
||||
|
||||
if (dist < 13) {
|
||||
div++;
|
||||
}
|
||||
swap(a, less - 1, left);
|
||||
swap(a, great + 1, right);
|
||||
|
||||
// subarrays
|
||||
dualPivotQuicksort(a, left, less - 2, div);
|
||||
dualPivotQuicksort(a, great + 2, right, div);
|
||||
|
||||
// equal elements
|
||||
if (dist > len - 13 && pivot1 != pivot2) {
|
||||
for (int k = less; k <= great; k++) {
|
||||
if (a[k] == pivot1) {
|
||||
swap(a, k, less++);
|
||||
}
|
||||
else if (a[k] == pivot2) {
|
||||
swap(a, k, great--);
|
||||
|
||||
if (a[k] == pivot1) {
|
||||
swap(a, k, less++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// subarray
|
||||
if (pivot1 < pivot2) {
|
||||
dualPivotQuicksort(a, less, great, div);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) 1999 CERN - European Organization for Nuclear Research.
|
||||
|
||||
// Permission to use, copy, modify, distribute and sell this software and
|
||||
// its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and that
|
||||
// both that copyright notice and this permission notice appear in
|
||||
// supporting documentation. CERN makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without expressed or implied warranty.
|
||||
|
||||
package gnu.trove.impl;
|
||||
|
||||
/**
|
||||
* Provides various hash functions.
|
||||
*
|
||||
* @author wolfgang.hoschek@cern.ch
|
||||
* @version 1.0, 09/24/99
|
||||
*/
|
||||
public final class HashFunctions {
|
||||
/**
|
||||
* Returns a hashcode for the specified value.
|
||||
*
|
||||
* @return a hash code value for the specified value.
|
||||
*/
|
||||
public static int hash(double value) {
|
||||
assert !Double.isNaN(value) : "Values of NaN are not supported.";
|
||||
|
||||
long bits = Double.doubleToLongBits(value);
|
||||
return (int)(bits ^ (bits >>> 32));
|
||||
//return (int) Double.doubleToLongBits(value*663608941.737);
|
||||
//this avoids excessive hashCollisions in the case values are
|
||||
//of the form (1.0, 2.0, 3.0, ...)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for the specified value.
|
||||
*
|
||||
* @return a hash code value for the specified value.
|
||||
*/
|
||||
public static int hash(float value) {
|
||||
assert !Float.isNaN(value) : "Values of NaN are not supported.";
|
||||
|
||||
return Float.floatToIntBits(value*663608941.737f);
|
||||
// this avoids excessive hashCollisions in the case values are
|
||||
// of the form (1.0, 2.0, 3.0, ...)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for the specified value.
|
||||
*
|
||||
* @return a hash code value for the specified value.
|
||||
*/
|
||||
public static int hash(int value) {
|
||||
// Multiply by prime to make sure hash can't be negative (see Knuth v3, p. 515-516)
|
||||
return value * 31;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for the specified value.
|
||||
*
|
||||
* @return a hash code value for the specified value.
|
||||
*/
|
||||
public static int hash(long value) {
|
||||
// Multiply by prime to make sure hash can't be negative (see Knuth v3, p. 515-516)
|
||||
return ((int)(value ^ (value >>> 32))) * 31;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for the specified object.
|
||||
*
|
||||
* @return a hash code value for the specified object.
|
||||
*/
|
||||
public static int hash(Object object) {
|
||||
return object==null ? 0 : object.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* In profiling, it has been found to be faster to have our own local implementation
|
||||
* of "ceil" rather than to call to {@link Math#ceil(double)}.
|
||||
*/
|
||||
public static int fastCeil( float v ) {
|
||||
int possible_result = ( int ) v;
|
||||
if ( v - possible_result > 0 ) possible_result++;
|
||||
return possible_result;
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
// Copyright (c) 1999 CERN - European Organization for Nuclear Research.
|
||||
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear in
|
||||
// supporting documentation. CERN makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without expressed or implied warranty.
|
||||
package gnu.trove.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* Modified for Trove to use the java.util.Arrays sort/search
|
||||
* algorithms instead of those provided with colt.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used to keep hash table capacities prime numbers.
|
||||
* Not of interest for users; only for implementors of hashtables.
|
||||
*
|
||||
* <p>Choosing prime numbers as hash table capacities is a good idea
|
||||
* to keep them working fast, particularly under hash table
|
||||
* expansions.
|
||||
*
|
||||
* <p>However, JDK 1.2, JGL 3.1 and many other toolkits do nothing to
|
||||
* keep capacities prime. This class provides efficient means to
|
||||
* choose prime capacities.
|
||||
*
|
||||
* <p>Choosing a prime is <tt>O(log 300)</tt> (binary search in a list
|
||||
* of 300 ints). Memory requirements: 1 KB static memory.
|
||||
*
|
||||
* @author wolfgang.hoschek@cern.ch
|
||||
* @version 1.0, 09/24/99
|
||||
*/
|
||||
public final class PrimeFinder {
|
||||
/**
|
||||
* The largest prime this class can generate; currently equal to
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*/
|
||||
public static final int largestPrime = Integer.MAX_VALUE; //yes, it is prime.
|
||||
|
||||
/**
|
||||
* The prime number list consists of 11 chunks.
|
||||
*
|
||||
* Each chunk contains prime numbers.
|
||||
*
|
||||
* A chunk starts with a prime P1. The next element is a prime
|
||||
* P2. P2 is the smallest prime for which holds: P2 >= 2*P1.
|
||||
*
|
||||
* The next element is P3, for which the same holds with respect
|
||||
* to P2, and so on.
|
||||
*
|
||||
* Chunks are chosen such that for any desired capacity >= 1000
|
||||
* the list includes a prime number <= desired capacity * 1.11.
|
||||
*
|
||||
* Therefore, primes can be retrieved which are quite close to any
|
||||
* desired capacity, which in turn avoids wasting memory.
|
||||
*
|
||||
* For example, the list includes
|
||||
* 1039,1117,1201,1277,1361,1439,1523,1597,1759,1907,2081.
|
||||
*
|
||||
* So if you need a prime >= 1040, you will find a prime <=
|
||||
* 1040*1.11=1154.
|
||||
*
|
||||
* Chunks are chosen such that they are optimized for a hashtable
|
||||
* growthfactor of 2.0;
|
||||
*
|
||||
* If your hashtable has such a growthfactor then, after initially
|
||||
* "rounding to a prime" upon hashtable construction, it will
|
||||
* later expand to prime capacities such that there exist no
|
||||
* better primes.
|
||||
*
|
||||
* In total these are about 32*10=320 numbers -> 1 KB of static
|
||||
* memory needed.
|
||||
*
|
||||
* If you are stingy, then delete every second or fourth chunk.
|
||||
*/
|
||||
|
||||
private static final int[] primeCapacities = {
|
||||
//chunk #0
|
||||
largestPrime,
|
||||
|
||||
//chunk #1
|
||||
5,11,23,47,97,197,397,797,1597,3203,6421,12853,25717,51437,102877,205759,
|
||||
411527,823117,1646237,3292489,6584983,13169977,26339969,52679969,105359939,
|
||||
210719881,421439783,842879579,1685759167,
|
||||
|
||||
//chunk #2
|
||||
433,877,1759,3527,7057,14143,28289,56591,113189,226379,452759,905551,1811107,
|
||||
3622219,7244441,14488931,28977863,57955739,115911563,231823147,463646329,927292699,
|
||||
1854585413,
|
||||
|
||||
//chunk #3
|
||||
953,1907,3821,7643,15287,30577,61169,122347,244703,489407,978821,1957651,3915341,
|
||||
7830701,15661423,31322867,62645741,125291483,250582987,501165979,1002331963,
|
||||
2004663929,
|
||||
|
||||
//chunk #4
|
||||
1039,2081,4177,8363,16729,33461,66923,133853,267713,535481,1070981,2141977,4283963,
|
||||
8567929,17135863,34271747,68543509,137087021,274174111,548348231,1096696463,
|
||||
|
||||
//chunk #5
|
||||
31,67,137,277,557,1117,2237,4481,8963,17929,35863,71741,143483,286973,573953,
|
||||
1147921,2295859,4591721,9183457,18366923,36733847,73467739,146935499,293871013,
|
||||
587742049,1175484103,
|
||||
|
||||
//chunk #6
|
||||
599,1201,2411,4831,9677,19373,38747,77509,155027,310081,620171,1240361,2480729,
|
||||
4961459,9922933,19845871,39691759,79383533,158767069,317534141,635068283,1270136683,
|
||||
|
||||
//chunk #7
|
||||
311,631,1277,2557,5119,10243,20507,41017,82037,164089,328213,656429,1312867,
|
||||
2625761,5251529,10503061,21006137,42012281,84024581,168049163,336098327,672196673,
|
||||
1344393353,
|
||||
|
||||
//chunk #8
|
||||
3,7,17,37,79,163,331,673,1361,2729,5471,10949,21911,43853,87719,175447,350899,
|
||||
701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,
|
||||
359339171,718678369,1437356741,
|
||||
|
||||
//chunk #9
|
||||
43,89,179,359,719,1439,2879,5779,11579,23159,46327,92657,185323,370661,741337,
|
||||
1482707,2965421,5930887,11861791,23723597,47447201,94894427,189788857,379577741,
|
||||
759155483,1518310967,
|
||||
|
||||
//chunk #10
|
||||
379,761,1523,3049,6101,12203,24407,48817,97649,195311,390647,781301,1562611,
|
||||
3125257,6250537,12501169,25002389,50004791,100009607,200019221,400038451,800076929,
|
||||
1600153859
|
||||
};
|
||||
|
||||
static { //initializer
|
||||
// The above prime numbers are formatted for human readability.
|
||||
// To find numbers fast, we sort them once and for all.
|
||||
|
||||
Arrays.sort(primeCapacities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a prime number which is <code>>= desiredCapacity</code>
|
||||
* and very close to <code>desiredCapacity</code> (within 11% if
|
||||
* <code>desiredCapacity >= 1000</code>).
|
||||
*
|
||||
* @param desiredCapacity the capacity desired by the user.
|
||||
* @return the capacity which should be used for a hashtable.
|
||||
*/
|
||||
public static final int nextPrime(int desiredCapacity) {
|
||||
int i = Arrays.binarySearch(primeCapacities, desiredCapacity);
|
||||
if (i<0) {
|
||||
// desired capacity not found, choose next prime greater
|
||||
// than desired capacity
|
||||
i = -i -1; // remember the semantics of binarySearch...
|
||||
}
|
||||
return primeCapacities[i];
|
||||
}
|
||||
}
|
|
@ -1,293 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.impl.hash;
|
||||
|
||||
import gnu.trove.procedure.TFloatProcedure;
|
||||
import gnu.trove.impl.HashFunctions;
|
||||
import gnu.trove.impl.Constants;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* An open addressed hashing implementation for float primitives.
|
||||
*
|
||||
* Created: Sun Nov 4 08:56:06 2001
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: _E_Hash.template,v 1.1.2.6 2009/11/07 03:36:44 robeden Exp $
|
||||
*/
|
||||
abstract public class TFloatHash extends TPrimitiveHash {
|
||||
|
||||
/** the set of floats */
|
||||
public transient float[] _set;
|
||||
|
||||
/**
|
||||
* value that represents null
|
||||
*
|
||||
* NOTE: should not be modified after the Hash is created, but is
|
||||
* not final because of Externalization
|
||||
*
|
||||
*/
|
||||
protected float no_entry_value;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TFloatHash</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public TFloatHash() {
|
||||
super();
|
||||
no_entry_value = Constants.DEFAULT_FLOAT_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( float ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TFloatHash</code> instance whose capacity
|
||||
* is the next highest prime above <tt>initialCapacity + 1</tt>
|
||||
* unless that value is already prime.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public TFloatHash( int initialCapacity ) {
|
||||
super( initialCapacity );
|
||||
no_entry_value = Constants.DEFAULT_FLOAT_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( float ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TFloatHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param loadFactor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
*/
|
||||
public TFloatHash( int initialCapacity, float loadFactor ) {
|
||||
super(initialCapacity, loadFactor);
|
||||
no_entry_value = Constants.DEFAULT_FLOAT_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( float ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TFloatHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param loadFactor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
* @param no_entry_value value that represents null
|
||||
*/
|
||||
public TFloatHash( int initialCapacity, float loadFactor, float no_entry_value ) {
|
||||
super(initialCapacity, loadFactor);
|
||||
this.no_entry_value = no_entry_value;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( float ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
public float getNoEntryValue() {
|
||||
return no_entry_value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initializes the hashtable to a prime capacity which is at least
|
||||
* <tt>initialCapacity + 1</tt>.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @return the actual capacity chosen
|
||||
*/
|
||||
protected int setUp( int initialCapacity ) {
|
||||
int capacity;
|
||||
|
||||
capacity = super.setUp( initialCapacity );
|
||||
_set = new float[capacity];
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Searches the set for <tt>val</tt>
|
||||
*
|
||||
* @param val an <code>float</code> value
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean contains( float val ) {
|
||||
return index(val) >= 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the set.
|
||||
*
|
||||
* @param procedure a <code>TObjectProcedure</code> value
|
||||
* @return false if the loop over the set terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
public boolean forEach( TFloatProcedure procedure ) {
|
||||
byte[] states = _states;
|
||||
float[] set = _set;
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
if ( states[i] == FULL && ! procedure.execute( set[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases the element currently stored at <tt>index</tt>.
|
||||
*
|
||||
* @param index an <code>int</code> value
|
||||
*/
|
||||
protected void removeAt( int index ) {
|
||||
_set[index] = no_entry_value;
|
||||
super.removeAt( index );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the index of <tt>val</tt>.
|
||||
*
|
||||
* @param val an <code>float</code> value
|
||||
* @return the index of <tt>val</tt> or -1 if it isn't in the set.
|
||||
*/
|
||||
protected int index( float val ) {
|
||||
int hash, probe, index, length;
|
||||
|
||||
final byte[] states = _states;
|
||||
final float[] set = _set;
|
||||
length = states.length;
|
||||
hash = HashFunctions.hash( val ) & 0x7fffffff;
|
||||
index = hash % length;
|
||||
|
||||
if ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) ) {
|
||||
// see Knuth, p. 529
|
||||
probe = 1 + ( hash % ( length - 2 ) );
|
||||
|
||||
do {
|
||||
index -= probe;
|
||||
if ( index < 0 ) {
|
||||
index += length;
|
||||
}
|
||||
} while ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) );
|
||||
}
|
||||
|
||||
return states[index] == FREE ? -1 : index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the index at which <tt>val</tt> can be inserted. if
|
||||
* there is already a value equal()ing <tt>val</tt> in the set,
|
||||
* returns that value as a negative integer.
|
||||
*
|
||||
* @param val an <code>float</code> value
|
||||
* @return an <code>int</code> value
|
||||
*/
|
||||
protected int insertionIndex( float val ) {
|
||||
int hash, probe, index, length;
|
||||
|
||||
final byte[] states = _states;
|
||||
final float[] set = _set;
|
||||
length = states.length;
|
||||
hash = HashFunctions.hash( val ) & 0x7fffffff;
|
||||
index = hash % length;
|
||||
|
||||
if ( states[index] == FREE ) {
|
||||
return index; // empty, all done
|
||||
} else if ( states[index] == FULL && set[index] == val ) {
|
||||
return -index -1; // already stored
|
||||
} else { // already FULL or REMOVED, must probe
|
||||
// compute the double hash
|
||||
probe = 1 + ( hash % ( length - 2 ) );
|
||||
|
||||
// if the slot we landed on is FULL (but not removed), probe
|
||||
// until we find an empty slot, a REMOVED slot, or an element
|
||||
// equal to the one we are trying to insert.
|
||||
// finding an empty slot means that the value is not present
|
||||
// and that we should use that slot as the insertion point;
|
||||
// finding a REMOVED slot means that we need to keep searching,
|
||||
// however we want to remember the offset of that REMOVED slot
|
||||
// so we can reuse it in case a "new" insertion (i.e. not an update)
|
||||
// is possible.
|
||||
// finding a matching value means that we've found that our desired
|
||||
// key is already in the table
|
||||
|
||||
if ( states[index] != REMOVED ) {
|
||||
// starting at the natural offset, probe until we find an
|
||||
// offset that isn't full.
|
||||
do {
|
||||
index -= probe;
|
||||
if (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
} while ( states[index] == FULL && set[index] != val );
|
||||
}
|
||||
|
||||
// if the index we found was removed: continue probing until we
|
||||
// locate a free location or an element which equal()s the
|
||||
// one we have.
|
||||
if ( states[index] == REMOVED) {
|
||||
int firstRemoved = index;
|
||||
while ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) ) {
|
||||
index -= probe;
|
||||
if (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
}
|
||||
return states[index] == FULL ? -index -1 : firstRemoved;
|
||||
}
|
||||
// if it's full, the key is already stored
|
||||
return states[index] == FULL ? -index -1 : index;
|
||||
}
|
||||
}
|
||||
} // TFloatHash
|
|
@ -1,428 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.impl.hash;
|
||||
|
||||
import gnu.trove.impl.Constants;
|
||||
import gnu.trove.impl.HashFunctions;
|
||||
import gnu.trove.impl.PrimeFinder;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Base class for hashtables that use open addressing to resolve
|
||||
* collisions.
|
||||
*
|
||||
* Created: Wed Nov 28 21:11:16 2001
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden (auto-compaction)
|
||||
* @author Jeff Randall
|
||||
*
|
||||
* @version $Id: THash.java,v 1.1.2.4 2010/03/02 00:55:34 robeden Exp $
|
||||
*/
|
||||
abstract public class THash implements Externalizable {
|
||||
|
||||
static final long serialVersionUID = -1792948471915530295L;
|
||||
|
||||
/** the load above which rehashing occurs. */
|
||||
protected static final float DEFAULT_LOAD_FACTOR = Constants.DEFAULT_LOAD_FACTOR;
|
||||
|
||||
/**
|
||||
* the default initial capacity for the hash table. This is one
|
||||
* less than a prime value because one is added to it when
|
||||
* searching for a prime capacity to account for the free slot
|
||||
* required by open addressing. Thus, the real default capacity is
|
||||
* 11.
|
||||
*/
|
||||
protected static final int DEFAULT_CAPACITY = Constants.DEFAULT_CAPACITY;
|
||||
|
||||
|
||||
/** the current number of occupied slots in the hash. */
|
||||
protected transient int _size;
|
||||
|
||||
/** the current number of free slots in the hash. */
|
||||
protected transient int _free;
|
||||
|
||||
/**
|
||||
* Determines how full the internal table can become before
|
||||
* rehashing is required. This must be a value in the range: 0.0 <
|
||||
* loadFactor < 1.0. The default value is 0.5, which is about as
|
||||
* large as you can get in open addressing without hurting
|
||||
* performance. Cf. Knuth, Volume 3., Chapter 6.
|
||||
*/
|
||||
protected float _loadFactor;
|
||||
|
||||
/**
|
||||
* The maximum number of elements allowed without allocating more
|
||||
* space.
|
||||
*/
|
||||
protected int _maxSize;
|
||||
|
||||
|
||||
/** The number of removes that should be performed before an auto-compaction occurs. */
|
||||
protected int _autoCompactRemovesRemaining;
|
||||
|
||||
/**
|
||||
* The auto-compaction factor for the table.
|
||||
*
|
||||
* @see #setAutoCompactionFactor
|
||||
*/
|
||||
protected float _autoCompactionFactor;
|
||||
|
||||
/** @see #tempDisableAutoCompaction */
|
||||
protected transient boolean _autoCompactTemporaryDisable = false;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>THash</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public THash() {
|
||||
this( DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>THash</code> instance with a prime capacity
|
||||
* at or near the specified capacity and with the default load
|
||||
* factor.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public THash( int initialCapacity ) {
|
||||
this( initialCapacity, DEFAULT_LOAD_FACTOR );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>THash</code> instance with a prime capacity
|
||||
* at or near the minimum needed to hold <tt>initialCapacity</tt>
|
||||
* elements with load factor <tt>loadFactor</tt> without triggering
|
||||
* a rehash.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @param loadFactor a <code>float</code> value
|
||||
*/
|
||||
public THash( int initialCapacity, float loadFactor ) {
|
||||
super();
|
||||
_loadFactor = loadFactor;
|
||||
|
||||
// Through testing, the load factor (especially the default load factor) has been
|
||||
// found to be a pretty good starting auto-compaction factor.
|
||||
_autoCompactionFactor = loadFactor;
|
||||
|
||||
setUp( HashFunctions.fastCeil( initialCapacity / loadFactor ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tells whether this set is currently holding any elements.
|
||||
*
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return 0 == _size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of distinct elements in this collection.
|
||||
*
|
||||
* @return an <code>int</code> value
|
||||
*/
|
||||
public int size() {
|
||||
return _size;
|
||||
}
|
||||
|
||||
|
||||
/** @return the current physical capacity of the hash table. */
|
||||
abstract public int capacity();
|
||||
|
||||
|
||||
/**
|
||||
* Ensure that this hashtable has sufficient capacity to hold
|
||||
* <tt>desiredCapacity<tt> <b>additional</b> elements without
|
||||
* requiring a rehash. This is a tuning method you can call
|
||||
* before doing a large insert.
|
||||
*
|
||||
* @param desiredCapacity an <code>int</code> value
|
||||
*/
|
||||
public void ensureCapacity( int desiredCapacity ) {
|
||||
if ( desiredCapacity > ( _maxSize - size() ) ) {
|
||||
rehash( PrimeFinder.nextPrime( HashFunctions.fastCeil(
|
||||
( desiredCapacity + size() ) / _loadFactor ) + 1 ) );
|
||||
computeMaxSize( capacity() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compresses the hashtable to the minimum prime size (as defined
|
||||
* by PrimeFinder) that will hold all of the elements currently in
|
||||
* the table. If you have done a lot of <tt>remove</tt>
|
||||
* operations and plan to do a lot of queries or insertions or
|
||||
* iteration, it is a good idea to invoke this method. Doing so
|
||||
* will accomplish two things:
|
||||
* <p/>
|
||||
* <ol>
|
||||
* <li> You'll free memory allocated to the table but no
|
||||
* longer needed because of the remove()s.</li>
|
||||
* <p/>
|
||||
* <li> You'll get better query/insert/iterator performance
|
||||
* because there won't be any <tt>REMOVED</tt> slots to skip
|
||||
* over when probing for indices in the table.</li>
|
||||
* </ol>
|
||||
*/
|
||||
public void compact() {
|
||||
// need at least one free spot for open addressing
|
||||
rehash( PrimeFinder.nextPrime( HashFunctions.fastCeil( size() / _loadFactor ) + 1 ) );
|
||||
computeMaxSize( capacity() );
|
||||
|
||||
// If auto-compaction is enabled, re-determine the compaction interval
|
||||
if ( _autoCompactionFactor != 0 ) {
|
||||
computeNextAutoCompactionAmount( size() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The auto-compaction factor controls whether and when a table performs a
|
||||
* {@link #compact} automatically after a certain number of remove operations.
|
||||
* If the value is non-zero, the number of removes that need to occur for
|
||||
* auto-compaction is the size of table at the time of the previous compaction
|
||||
* (or the initial capacity) multiplied by this factor.
|
||||
* <p/>
|
||||
* Setting this value to zero will disable auto-compaction.
|
||||
*
|
||||
* @param factor a <tt>float</tt> that indicates the auto-compaction factor
|
||||
*/
|
||||
public void setAutoCompactionFactor( float factor ) {
|
||||
if ( factor < 0 ) {
|
||||
throw new IllegalArgumentException( "Factor must be >= 0: " + factor );
|
||||
}
|
||||
|
||||
_autoCompactionFactor = factor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see #setAutoCompactionFactor
|
||||
*
|
||||
* @return a <<tt>float</tt> that represents the auto-compaction factor.
|
||||
*/
|
||||
public float getAutoCompactionFactor() {
|
||||
return _autoCompactionFactor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This simply calls {@link #compact compact}. It is included for
|
||||
* symmetry with other collection classes. Note that the name of this
|
||||
* method is somewhat misleading (which is why we prefer
|
||||
* <tt>compact</tt>) as the load factor may require capacity above
|
||||
* and beyond the size of this collection.
|
||||
*
|
||||
* @see #compact
|
||||
*/
|
||||
public final void trimToSize() {
|
||||
compact();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete the record at <tt>index</tt>. Reduces the size of the
|
||||
* collection by one.
|
||||
*
|
||||
* @param index an <code>int</code> value
|
||||
*/
|
||||
protected void removeAt( int index ) {
|
||||
_size--;
|
||||
|
||||
// If auto-compaction is enabled, see if we need to compact
|
||||
if ( _autoCompactionFactor != 0 ) {
|
||||
_autoCompactRemovesRemaining--;
|
||||
|
||||
if ( !_autoCompactTemporaryDisable && _autoCompactRemovesRemaining <= 0 ) {
|
||||
// Do the compact
|
||||
// NOTE: this will cause the next compaction interval to be calculated
|
||||
compact();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Empties the collection. */
|
||||
public void clear() {
|
||||
_size = 0;
|
||||
_free = capacity();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initializes the hashtable to a prime capacity which is at least
|
||||
* <tt>initialCapacity + 1</tt>.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @return the actual capacity chosen
|
||||
*/
|
||||
protected int setUp( int initialCapacity ) {
|
||||
int capacity;
|
||||
|
||||
capacity = PrimeFinder.nextPrime( initialCapacity );
|
||||
computeMaxSize( capacity );
|
||||
computeNextAutoCompactionAmount( initialCapacity );
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rehashes the set.
|
||||
*
|
||||
* @param newCapacity an <code>int</code> value
|
||||
*/
|
||||
protected abstract void rehash( int newCapacity );
|
||||
|
||||
|
||||
/**
|
||||
* Temporarily disables auto-compaction. MUST be followed by calling
|
||||
* {@link #reenableAutoCompaction}.
|
||||
*/
|
||||
public void tempDisableAutoCompaction() {
|
||||
_autoCompactTemporaryDisable = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Re-enable auto-compaction after it was disabled via
|
||||
* {@link #tempDisableAutoCompaction()}.
|
||||
*
|
||||
* @param check_for_compaction True if compaction should be performed if needed
|
||||
* before returning. If false, no compaction will be
|
||||
* performed.
|
||||
*/
|
||||
public void reenableAutoCompaction( boolean check_for_compaction ) {
|
||||
_autoCompactTemporaryDisable = false;
|
||||
|
||||
if ( check_for_compaction && _autoCompactRemovesRemaining <= 0 &&
|
||||
_autoCompactionFactor != 0 ) {
|
||||
|
||||
// Do the compact
|
||||
// NOTE: this will cause the next compaction interval to be calculated
|
||||
compact();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computes the values of maxSize. There will always be at least
|
||||
* one free slot required.
|
||||
*
|
||||
* @param capacity an <code>int</code> value
|
||||
*/
|
||||
protected void computeMaxSize( int capacity ) {
|
||||
// need at least one free slot for open addressing
|
||||
_maxSize = Math.min( capacity - 1, (int) ( capacity * _loadFactor ) );
|
||||
_free = capacity - _size; // reset the free element count
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computes the number of removes that need to happen before the next auto-compaction
|
||||
* will occur.
|
||||
*
|
||||
* @param size an <tt>int</tt> that sets the auto-compaction limit.
|
||||
*/
|
||||
protected void computeNextAutoCompactionAmount( int size ) {
|
||||
if ( _autoCompactionFactor != 0 ) {
|
||||
// NOTE: doing the round ourselves has been found to be faster than using
|
||||
// Math.round.
|
||||
_autoCompactRemovesRemaining =
|
||||
(int) ( ( size * _autoCompactionFactor ) + 0.5f );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* After an insert, this hook is called to adjust the size/free
|
||||
* values of the set and to perform rehashing if necessary.
|
||||
*
|
||||
* @param usedFreeSlot the slot
|
||||
*/
|
||||
protected final void postInsertHook( boolean usedFreeSlot ) {
|
||||
if ( usedFreeSlot ) {
|
||||
_free--;
|
||||
}
|
||||
|
||||
// rehash whenever we exhaust the available space in the table
|
||||
if ( ++_size > _maxSize || _free == 0 ) {
|
||||
// choose a new capacity suited to the new state of the table
|
||||
// if we've grown beyond our maximum size, double capacity;
|
||||
// if we've exhausted the free spots, rehash to the same capacity,
|
||||
// which will free up any stale removed slots for reuse.
|
||||
int newCapacity = _size > _maxSize ? PrimeFinder.nextPrime( capacity() << 1 ) : capacity();
|
||||
rehash( newCapacity );
|
||||
computeMaxSize( capacity() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int calculateGrownCapacity() {
|
||||
return capacity() << 1;
|
||||
}
|
||||
|
||||
|
||||
public void writeExternal( ObjectOutput out ) throws IOException {
|
||||
// VERSION
|
||||
out.writeByte( 0 );
|
||||
|
||||
// LOAD FACTOR
|
||||
out.writeFloat( _loadFactor );
|
||||
|
||||
// AUTO COMPACTION LOAD FACTOR
|
||||
out.writeFloat( _autoCompactionFactor );
|
||||
}
|
||||
|
||||
|
||||
public void readExternal( ObjectInput in )
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
// VERSION
|
||||
in.readByte();
|
||||
|
||||
// LOAD FACTOR
|
||||
float old_factor = _loadFactor;
|
||||
_loadFactor = in.readFloat();
|
||||
|
||||
// AUTO COMPACTION LOAD FACTOR
|
||||
_autoCompactionFactor = in.readFloat();
|
||||
|
||||
// If we change the laod factor from the default, re-setup
|
||||
if ( old_factor != _loadFactor ) {
|
||||
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
|
||||
}
|
||||
}
|
||||
}// THash
|
|
@ -1,143 +0,0 @@
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.impl.hash;
|
||||
|
||||
import gnu.trove.iterator.TPrimitiveIterator;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
/**
|
||||
* Implements all iterator functions for the hashed object set.
|
||||
* Subclasses may override objectAtIndex to vary the object
|
||||
* returned by calls to next() (e.g. for values, and Map.Entry
|
||||
* objects).
|
||||
* <p/>
|
||||
* <p> Note that iteration is fastest if you forego the calls to
|
||||
* <tt>hasNext</tt> in favor of checking the size of the structure
|
||||
* yourself and then call next() that many times:
|
||||
* <p/>
|
||||
* <pre>
|
||||
* Iterator i = collection.iterator();
|
||||
* for (int size = collection.size(); size-- > 0;) {
|
||||
* Object o = i.next();
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* <p>You may, of course, use the hasNext(), next() idiom too if
|
||||
* you aren't in a performance critical spot.</p>
|
||||
*/
|
||||
public abstract class THashPrimitiveIterator implements TPrimitiveIterator {
|
||||
|
||||
/** the data structure this iterator traverses */
|
||||
protected final TPrimitiveHash _hash;
|
||||
/**
|
||||
* the number of elements this iterator believes are in the
|
||||
* data structure it accesses.
|
||||
*/
|
||||
protected int _expectedSize;
|
||||
/** the index used for iteration. */
|
||||
protected int _index;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a <tt>TPrimitiveIterator</tt> for the specified collection.
|
||||
*
|
||||
* @param hash the <tt>TPrimitiveHash</tt> we want to iterate over.
|
||||
*/
|
||||
public THashPrimitiveIterator( TPrimitiveHash hash ) {
|
||||
_hash = hash;
|
||||
_expectedSize = _hash.size();
|
||||
_index = _hash.capacity();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index of the next value in the data structure
|
||||
* or a negative value if the iterator is exhausted.
|
||||
*
|
||||
* @return an <code>int</code> value
|
||||
* @throws java.util.ConcurrentModificationException
|
||||
* if the underlying collection's
|
||||
* size has been modified since the iterator was created.
|
||||
*/
|
||||
protected final int nextIndex() {
|
||||
if ( _expectedSize != _hash.size() ) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
byte[] states = _hash._states;
|
||||
int i = _index;
|
||||
while ( i-- > 0 && ( states[i] != TPrimitiveHash.FULL ) ) {
|
||||
;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the iterator can be advanced past its current
|
||||
* location.
|
||||
*
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return nextIndex() >= 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the last entry returned by the iterator.
|
||||
* Invoking this method more than once for a single entry
|
||||
* will leave the underlying data structure in a confused
|
||||
* state.
|
||||
*/
|
||||
public void remove() {
|
||||
if (_expectedSize != _hash.size()) {
|
||||
throw new ConcurrentModificationException();
|
||||
}
|
||||
|
||||
// Disable auto compaction during the remove. This is a workaround for bug 1642768.
|
||||
try {
|
||||
_hash.tempDisableAutoCompaction();
|
||||
_hash.removeAt(_index);
|
||||
}
|
||||
finally {
|
||||
_hash.reenableAutoCompaction( false );
|
||||
}
|
||||
|
||||
_expectedSize--;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the internal <tt>index</tt> so that the `next' object
|
||||
* can be returned.
|
||||
*/
|
||||
protected final void moveToNextIndex() {
|
||||
// doing the assignment && < 0 in one line shaves
|
||||
// 3 opcodes...
|
||||
if ( ( _index = nextIndex() ) < 0 ) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // TPrimitiveIterator
|
|
@ -1,293 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.impl.hash;
|
||||
|
||||
import gnu.trove.procedure.TIntProcedure;
|
||||
import gnu.trove.impl.HashFunctions;
|
||||
import gnu.trove.impl.Constants;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* An open addressed hashing implementation for int primitives.
|
||||
*
|
||||
* Created: Sun Nov 4 08:56:06 2001
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: _E_Hash.template,v 1.1.2.6 2009/11/07 03:36:44 robeden Exp $
|
||||
*/
|
||||
abstract public class TIntHash extends TPrimitiveHash {
|
||||
|
||||
/** the set of ints */
|
||||
public transient int[] _set;
|
||||
|
||||
/**
|
||||
* value that represents null
|
||||
*
|
||||
* NOTE: should not be modified after the Hash is created, but is
|
||||
* not final because of Externalization
|
||||
*
|
||||
*/
|
||||
protected int no_entry_value;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHash</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public TIntHash() {
|
||||
super();
|
||||
no_entry_value = Constants.DEFAULT_INT_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHash</code> instance whose capacity
|
||||
* is the next highest prime above <tt>initialCapacity + 1</tt>
|
||||
* unless that value is already prime.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public TIntHash( int initialCapacity ) {
|
||||
super( initialCapacity );
|
||||
no_entry_value = Constants.DEFAULT_INT_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param loadFactor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
*/
|
||||
public TIntHash( int initialCapacity, float loadFactor ) {
|
||||
super(initialCapacity, loadFactor);
|
||||
no_entry_value = Constants.DEFAULT_INT_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param loadFactor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
* @param no_entry_value value that represents null
|
||||
*/
|
||||
public TIntHash( int initialCapacity, float loadFactor, int no_entry_value ) {
|
||||
super(initialCapacity, loadFactor);
|
||||
this.no_entry_value = no_entry_value;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
public int getNoEntryValue() {
|
||||
return no_entry_value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initializes the hashtable to a prime capacity which is at least
|
||||
* <tt>initialCapacity + 1</tt>.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @return the actual capacity chosen
|
||||
*/
|
||||
protected int setUp( int initialCapacity ) {
|
||||
int capacity;
|
||||
|
||||
capacity = super.setUp( initialCapacity );
|
||||
_set = new int[capacity];
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Searches the set for <tt>val</tt>
|
||||
*
|
||||
* @param val an <code>int</code> value
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean contains( int val ) {
|
||||
return index(val) >= 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the set.
|
||||
*
|
||||
* @param procedure a <code>TObjectProcedure</code> value
|
||||
* @return false if the loop over the set terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
public boolean forEach( TIntProcedure procedure ) {
|
||||
byte[] states = _states;
|
||||
int[] set = _set;
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
if ( states[i] == FULL && ! procedure.execute( set[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases the element currently stored at <tt>index</tt>.
|
||||
*
|
||||
* @param index an <code>int</code> value
|
||||
*/
|
||||
protected void removeAt( int index ) {
|
||||
_set[index] = no_entry_value;
|
||||
super.removeAt( index );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the index of <tt>val</tt>.
|
||||
*
|
||||
* @param val an <code>int</code> value
|
||||
* @return the index of <tt>val</tt> or -1 if it isn't in the set.
|
||||
*/
|
||||
protected int index( int val ) {
|
||||
int hash, probe, index, length;
|
||||
|
||||
final byte[] states = _states;
|
||||
final int[] set = _set;
|
||||
length = states.length;
|
||||
hash = HashFunctions.hash( val ) & 0x7fffffff;
|
||||
index = hash % length;
|
||||
|
||||
if ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) ) {
|
||||
// see Knuth, p. 529
|
||||
probe = 1 + ( hash % ( length - 2 ) );
|
||||
|
||||
do {
|
||||
index -= probe;
|
||||
if ( index < 0 ) {
|
||||
index += length;
|
||||
}
|
||||
} while ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) );
|
||||
}
|
||||
|
||||
return states[index] == FREE ? -1 : index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the index at which <tt>val</tt> can be inserted. if
|
||||
* there is already a value equal()ing <tt>val</tt> in the set,
|
||||
* returns that value as a negative integer.
|
||||
*
|
||||
* @param val an <code>int</code> value
|
||||
* @return an <code>int</code> value
|
||||
*/
|
||||
protected int insertionIndex( int val ) {
|
||||
int hash, probe, index, length;
|
||||
|
||||
final byte[] states = _states;
|
||||
final int[] set = _set;
|
||||
length = states.length;
|
||||
hash = HashFunctions.hash( val ) & 0x7fffffff;
|
||||
index = hash % length;
|
||||
|
||||
if ( states[index] == FREE ) {
|
||||
return index; // empty, all done
|
||||
} else if ( states[index] == FULL && set[index] == val ) {
|
||||
return -index -1; // already stored
|
||||
} else { // already FULL or REMOVED, must probe
|
||||
// compute the double hash
|
||||
probe = 1 + ( hash % ( length - 2 ) );
|
||||
|
||||
// if the slot we landed on is FULL (but not removed), probe
|
||||
// until we find an empty slot, a REMOVED slot, or an element
|
||||
// equal to the one we are trying to insert.
|
||||
// finding an empty slot means that the value is not present
|
||||
// and that we should use that slot as the insertion point;
|
||||
// finding a REMOVED slot means that we need to keep searching,
|
||||
// however we want to remember the offset of that REMOVED slot
|
||||
// so we can reuse it in case a "new" insertion (i.e. not an update)
|
||||
// is possible.
|
||||
// finding a matching value means that we've found that our desired
|
||||
// key is already in the table
|
||||
|
||||
if ( states[index] != REMOVED ) {
|
||||
// starting at the natural offset, probe until we find an
|
||||
// offset that isn't full.
|
||||
do {
|
||||
index -= probe;
|
||||
if (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
} while ( states[index] == FULL && set[index] != val );
|
||||
}
|
||||
|
||||
// if the index we found was removed: continue probing until we
|
||||
// locate a free location or an element which equal()s the
|
||||
// one we have.
|
||||
if ( states[index] == REMOVED) {
|
||||
int firstRemoved = index;
|
||||
while ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) ) {
|
||||
index -= probe;
|
||||
if (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
}
|
||||
return states[index] == FULL ? -index -1 : firstRemoved;
|
||||
}
|
||||
// if it's full, the key is already stored
|
||||
return states[index] == FULL ? -index -1 : index;
|
||||
}
|
||||
}
|
||||
} // TIntHash
|
|
@ -1,293 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.impl.hash;
|
||||
|
||||
import gnu.trove.procedure.TLongProcedure;
|
||||
import gnu.trove.impl.HashFunctions;
|
||||
import gnu.trove.impl.Constants;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* An open addressed hashing implementation for long primitives.
|
||||
*
|
||||
* Created: Sun Nov 4 08:56:06 2001
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: _E_Hash.template,v 1.1.2.6 2009/11/07 03:36:44 robeden Exp $
|
||||
*/
|
||||
abstract public class TLongHash extends TPrimitiveHash {
|
||||
|
||||
/** the set of longs */
|
||||
public transient long[] _set;
|
||||
|
||||
/**
|
||||
* value that represents null
|
||||
*
|
||||
* NOTE: should not be modified after the Hash is created, but is
|
||||
* not final because of Externalization
|
||||
*
|
||||
*/
|
||||
protected long no_entry_value;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHash</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public TLongHash() {
|
||||
super();
|
||||
no_entry_value = Constants.DEFAULT_LONG_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHash</code> instance whose capacity
|
||||
* is the next highest prime above <tt>initialCapacity + 1</tt>
|
||||
* unless that value is already prime.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public TLongHash( int initialCapacity ) {
|
||||
super( initialCapacity );
|
||||
no_entry_value = Constants.DEFAULT_LONG_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param loadFactor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
*/
|
||||
public TLongHash( int initialCapacity, float loadFactor ) {
|
||||
super(initialCapacity, loadFactor);
|
||||
no_entry_value = Constants.DEFAULT_LONG_NO_ENTRY_VALUE;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param loadFactor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
* @param no_entry_value value that represents null
|
||||
*/
|
||||
public TLongHash( int initialCapacity, float loadFactor, long no_entry_value ) {
|
||||
super(initialCapacity, loadFactor);
|
||||
this.no_entry_value = no_entry_value;
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
public long getNoEntryValue() {
|
||||
return no_entry_value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initializes the hashtable to a prime capacity which is at least
|
||||
* <tt>initialCapacity + 1</tt>.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @return the actual capacity chosen
|
||||
*/
|
||||
protected int setUp( int initialCapacity ) {
|
||||
int capacity;
|
||||
|
||||
capacity = super.setUp( initialCapacity );
|
||||
_set = new long[capacity];
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Searches the set for <tt>val</tt>
|
||||
*
|
||||
* @param val an <code>long</code> value
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean contains( long val ) {
|
||||
return index(val) >= 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the set.
|
||||
*
|
||||
* @param procedure a <code>TObjectProcedure</code> value
|
||||
* @return false if the loop over the set terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
public boolean forEach( TLongProcedure procedure ) {
|
||||
byte[] states = _states;
|
||||
long[] set = _set;
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
if ( states[i] == FULL && ! procedure.execute( set[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Releases the element currently stored at <tt>index</tt>.
|
||||
*
|
||||
* @param index an <code>int</code> value
|
||||
*/
|
||||
protected void removeAt( int index ) {
|
||||
_set[index] = no_entry_value;
|
||||
super.removeAt( index );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the index of <tt>val</tt>.
|
||||
*
|
||||
* @param val an <code>long</code> value
|
||||
* @return the index of <tt>val</tt> or -1 if it isn't in the set.
|
||||
*/
|
||||
protected int index( long val ) {
|
||||
int hash, probe, index, length;
|
||||
|
||||
final byte[] states = _states;
|
||||
final long[] set = _set;
|
||||
length = states.length;
|
||||
hash = HashFunctions.hash( val ) & 0x7fffffff;
|
||||
index = hash % length;
|
||||
|
||||
if ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) ) {
|
||||
// see Knuth, p. 529
|
||||
probe = 1 + ( hash % ( length - 2 ) );
|
||||
|
||||
do {
|
||||
index -= probe;
|
||||
if ( index < 0 ) {
|
||||
index += length;
|
||||
}
|
||||
} while ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) );
|
||||
}
|
||||
|
||||
return states[index] == FREE ? -1 : index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the index at which <tt>val</tt> can be inserted. if
|
||||
* there is already a value equal()ing <tt>val</tt> in the set,
|
||||
* returns that value as a negative integer.
|
||||
*
|
||||
* @param val an <code>long</code> value
|
||||
* @return an <code>int</code> value
|
||||
*/
|
||||
protected int insertionIndex( long val ) {
|
||||
int hash, probe, index, length;
|
||||
|
||||
final byte[] states = _states;
|
||||
final long[] set = _set;
|
||||
length = states.length;
|
||||
hash = HashFunctions.hash( val ) & 0x7fffffff;
|
||||
index = hash % length;
|
||||
|
||||
if ( states[index] == FREE ) {
|
||||
return index; // empty, all done
|
||||
} else if ( states[index] == FULL && set[index] == val ) {
|
||||
return -index -1; // already stored
|
||||
} else { // already FULL or REMOVED, must probe
|
||||
// compute the double hash
|
||||
probe = 1 + ( hash % ( length - 2 ) );
|
||||
|
||||
// if the slot we landed on is FULL (but not removed), probe
|
||||
// until we find an empty slot, a REMOVED slot, or an element
|
||||
// equal to the one we are trying to insert.
|
||||
// finding an empty slot means that the value is not present
|
||||
// and that we should use that slot as the insertion point;
|
||||
// finding a REMOVED slot means that we need to keep searching,
|
||||
// however we want to remember the offset of that REMOVED slot
|
||||
// so we can reuse it in case a "new" insertion (i.e. not an update)
|
||||
// is possible.
|
||||
// finding a matching value means that we've found that our desired
|
||||
// key is already in the table
|
||||
|
||||
if ( states[index] != REMOVED ) {
|
||||
// starting at the natural offset, probe until we find an
|
||||
// offset that isn't full.
|
||||
do {
|
||||
index -= probe;
|
||||
if (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
} while ( states[index] == FULL && set[index] != val );
|
||||
}
|
||||
|
||||
// if the index we found was removed: continue probing until we
|
||||
// locate a free location or an element which equal()s the
|
||||
// one we have.
|
||||
if ( states[index] == REMOVED) {
|
||||
int firstRemoved = index;
|
||||
while ( states[index] != FREE &&
|
||||
( states[index] == REMOVED || set[index] != val ) ) {
|
||||
index -= probe;
|
||||
if (index < 0) {
|
||||
index += length;
|
||||
}
|
||||
}
|
||||
return states[index] == FULL ? -index -1 : firstRemoved;
|
||||
}
|
||||
// if it's full, the key is already stored
|
||||
return states[index] == FULL ? -index -1 : index;
|
||||
}
|
||||
}
|
||||
} // TLongHash
|
|
@ -1,135 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.impl.hash;
|
||||
|
||||
import gnu.trove.impl.HashFunctions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The base class for hashtables of primitive values. Since there is
|
||||
* no notion of object equality for primitives, it isn't possible to
|
||||
* use a `REMOVED' object to track deletions in an open-addressed table.
|
||||
* So, we have to resort to using a parallel `bookkeeping' array of bytes,
|
||||
* in which flags can be set to indicate that a particular slot in the
|
||||
* hash table is FREE, FULL, or REMOVED.
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: TPrimitiveHash.java,v 1.1.2.6 2010/03/01 23:39:07 robeden Exp $
|
||||
*/
|
||||
abstract public class TPrimitiveHash extends THash {
|
||||
|
||||
/**
|
||||
* flags indicating whether each position in the hash is
|
||||
* FREE, FULL, or REMOVED
|
||||
*/
|
||||
public transient byte[] _states;
|
||||
|
||||
/* constants used for state flags */
|
||||
|
||||
/** flag indicating that a slot in the hashtable is available */
|
||||
public static final byte FREE = 0;
|
||||
|
||||
/** flag indicating that a slot in the hashtable is occupied */
|
||||
public static final byte FULL = 1;
|
||||
|
||||
/**
|
||||
* flag indicating that the value of a slot in the hashtable
|
||||
* was deleted
|
||||
*/
|
||||
public static final byte REMOVED = 2;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>THash</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public TPrimitiveHash() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TPrimitiveHash</code> instance with a prime
|
||||
* capacity at or near the specified capacity and with the default
|
||||
* load factor.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public TPrimitiveHash( int initialCapacity ) {
|
||||
this( initialCapacity, DEFAULT_LOAD_FACTOR );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TPrimitiveHash</code> instance with a prime
|
||||
* capacity at or near the minimum needed to hold
|
||||
* <tt>initialCapacity<tt> elements with load factor
|
||||
* <tt>loadFactor</tt> without triggering a rehash.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @param loadFactor a <code>float</code> value
|
||||
*/
|
||||
public TPrimitiveHash( int initialCapacity, float loadFactor ) {
|
||||
super();
|
||||
initialCapacity = Math.max( 1, initialCapacity );
|
||||
_loadFactor = loadFactor;
|
||||
setUp( HashFunctions.fastCeil( initialCapacity / loadFactor ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the capacity of the hash table. This is the true
|
||||
* physical capacity, without adjusting for the load factor.
|
||||
*
|
||||
* @return the physical capacity of the hash table.
|
||||
*/
|
||||
public int capacity() {
|
||||
return _states.length;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete the record at <tt>index</tt>.
|
||||
*
|
||||
* @param index an <code>int</code> value
|
||||
*/
|
||||
protected void removeAt( int index ) {
|
||||
_states[index] = REMOVED;
|
||||
super.removeAt( index );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initializes the hashtable to a prime capacity which is at least
|
||||
* <tt>initialCapacity + 1</tt>.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
* @return the actual capacity chosen
|
||||
*/
|
||||
protected int setUp( int initialCapacity ) {
|
||||
int capacity;
|
||||
|
||||
capacity = super.setUp( initialCapacity );
|
||||
_states = new byte[capacity];
|
||||
return capacity;
|
||||
}
|
||||
} // TPrimitiveHash
|
|
@ -1,31 +0,0 @@
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
package gnu.trove.iterator;
|
||||
|
||||
/**
|
||||
* Common interface for iterators that operate via the "advance" method for moving the
|
||||
* cursor to the next element.
|
||||
*/
|
||||
public interface TAdvancingIterator extends TIterator {
|
||||
/**
|
||||
* Moves the iterator forward to the next entry.
|
||||
*
|
||||
* @throws java.util.NoSuchElementException if the iterator is already exhausted
|
||||
*/
|
||||
public void advance();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.iterator;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Iterator for float collections.
|
||||
*/
|
||||
public interface TFloatIterator extends TIterator {
|
||||
/**
|
||||
* Advances the iterator to the next element in the underlying collection
|
||||
* and returns it.
|
||||
*
|
||||
* @return the next float in the collection
|
||||
* @exception NoSuchElementException if the iterator is already exhausted
|
||||
*/
|
||||
public float next();
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.iterator;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Iterator for maps of type float and Object.
|
||||
* <p/>
|
||||
* The iterator semantics for Trove's primitive maps is slightly different
|
||||
* from those defined in <tt>java.util.Iterator</tt>, but still well within
|
||||
* the scope of the pattern, as defined by Gamma, et al.
|
||||
* <p/>
|
||||
* This iterator does <b>not</b> implicitly advance to the next entry when
|
||||
* the value at the current position is retrieved. Rather, you must explicitly
|
||||
* ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
|
||||
* the <tt>value()</tt> or both. This is done so that you have the option, but not
|
||||
* the obligation, to retrieve keys and/or values as your application requires, and
|
||||
* without introducing wrapper objects that would carry both. As the iteration is
|
||||
* stateful, access to the key/value parts of the current map entry happens in
|
||||
* constant time.
|
||||
* <p/>
|
||||
* In practice, the iterator is akin to a "search finger" that you move from
|
||||
* position to position. Read or write operations affect the current entry only and
|
||||
* do not assume responsibility for moving the finger.
|
||||
* <p/>
|
||||
* Here are some sample scenarios for this class of iterator:
|
||||
* <p/>
|
||||
* <pre>
|
||||
* // accessing keys/values through an iterator:
|
||||
* for ( TFloatObjectIterator it = map.iterator(); it.hasNext(); ) {
|
||||
* it.advance();
|
||||
* if ( satisfiesCondition( it.key() ) ) {
|
||||
* doSomethingWithValue( it.value() );
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* // modifying values in-place through iteration:
|
||||
* for ( TFloatObjectIterator it = map.iterator(); it.hasNext(); ) {
|
||||
* it.advance();
|
||||
* if ( satisfiesCondition( it.key() ) ) {
|
||||
* it.setValue( newValueForKey( it.key() ) );
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* // deleting entries during iteration:
|
||||
* for ( TFloatObjectIterator it = map.iterator(); it.hasNext(); ) {
|
||||
* it.advance();
|
||||
* if ( satisfiesCondition( it.key() ) ) {
|
||||
* it.remove();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* // faster iteration by avoiding hasNext():
|
||||
* TFloatObjectIterator iterator = map.iterator();
|
||||
* for ( int i = map.size(); i-- > 0; ) {
|
||||
* iterator.advance();
|
||||
* doSomethingWithKeyAndValue( iterator.key(), iterator.value() );
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden
|
||||
* @author Jeff Randall
|
||||
* @version $Id: _E_ObjectIterator.template,v 1.1.2.1 2009/09/15 02:38:31 upholderoftruth Exp $
|
||||
*/
|
||||
public interface TFloatObjectIterator<V> extends TAdvancingIterator {
|
||||
|
||||
/**
|
||||
* Provides access to the key of the mapping at the iterator's position.
|
||||
* Note that you must <tt>advance()</tt> the iterator at least once
|
||||
* before invoking this method.
|
||||
*
|
||||
* @return the key of the entry at the iterator's current position.
|
||||
*/
|
||||
public float key();
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to the value of the mapping at the iterator's position.
|
||||
* Note that you must <tt>advance()</tt> the iterator at least once
|
||||
* before invoking this method.
|
||||
*
|
||||
* @return the value of the entry at the iterator's current position.
|
||||
*/
|
||||
public V value();
|
||||
|
||||
|
||||
/**
|
||||
* Replace the value of the mapping at the iterator's position with the
|
||||
* specified value. Note that you must <tt>advance()</tt> the iterator at
|
||||
* least once before invoking this method.
|
||||
*
|
||||
* @param val the value to set in the current entry
|
||||
* @return the old value of the entry.
|
||||
*/
|
||||
public V setValue( V val );
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.iterator;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Iterator for int collections.
|
||||
*/
|
||||
public interface TIntIterator extends TIterator {
|
||||
/**
|
||||
* Advances the iterator to the next element in the underlying collection
|
||||
* and returns it.
|
||||
*
|
||||
* @return the next int in the collection
|
||||
* @exception NoSuchElementException if the iterator is already exhausted
|
||||
*/
|
||||
public int next();
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
package gnu.trove.iterator;
|
||||
|
||||
/**
|
||||
* Common interface for all iterators used in Trove.
|
||||
*/
|
||||
public interface TIterator {
|
||||
/**
|
||||
* Returns true if the iterator can be advanced past its current location.
|
||||
*
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean hasNext();
|
||||
|
||||
/**
|
||||
* Removes the last entry returned by the iterator. The result of invoking this method
|
||||
* more than once for a single entry is undefined and can leave the underlying data
|
||||
* structure in a confused state.
|
||||
*/
|
||||
public void remove();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.iterator;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Iterator for long collections.
|
||||
*/
|
||||
public interface TLongIterator extends TIterator {
|
||||
/**
|
||||
* Advances the iterator to the next element in the underlying collection
|
||||
* and returns it.
|
||||
*
|
||||
* @return the next long in the collection
|
||||
* @exception NoSuchElementException if the iterator is already exhausted
|
||||
*/
|
||||
public long next();
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.iterator;
|
||||
|
||||
/**
|
||||
* Implements all iterator functions for the hashed object set.
|
||||
* Subclasses may override objectAtIndex to vary the object
|
||||
* returned by calls to next() (e.g. for values, and Map.Entry
|
||||
* objects).
|
||||
* <p/>
|
||||
* <p> Note that iteration is fastest if you forego the calls to
|
||||
* <tt>hasNext</tt> in favor of checking the size of the structure
|
||||
* yourself and then call next() that many times:
|
||||
* <p/>
|
||||
* <pre>
|
||||
* Iterator i = collection.iterator();
|
||||
* for (int size = collection.size(); size-- > 0;) {
|
||||
* Object o = i.next();
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* <p>You may, of course, use the hasNext(), next() idiom too if
|
||||
* you aren't in a performance critical spot.</p>
|
||||
*/
|
||||
public interface TPrimitiveIterator extends TIterator {
|
||||
/**
|
||||
* Returns true if the iterator can be advanced past its current
|
||||
* location.
|
||||
*
|
||||
* @return a <code>boolean</code> value
|
||||
*/
|
||||
public boolean hasNext();
|
||||
|
||||
|
||||
/**
|
||||
* Removes the last entry returned by the iterator.
|
||||
* Invoking this method more than once for a single entry
|
||||
* will leave the underlying data structure in a confused
|
||||
* state.
|
||||
*/
|
||||
public void remove();
|
||||
|
||||
} // TPrimitiveIterator
|
|
@ -1,508 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.list;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
import gnu.trove.function.*;
|
||||
import gnu.trove.procedure.*;
|
||||
import gnu.trove.TIntCollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface for Trove list implementations.
|
||||
*/
|
||||
public interface TIntList extends TIntCollection, Serializable {
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
public int getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of values in the list.
|
||||
*
|
||||
* @return the number of values in the list.
|
||||
*/
|
||||
public int size();
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether this list contains any values.
|
||||
*
|
||||
* @return true if the list is empty.
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Adds <tt>val</tt> to the end of the list, growing as needed.
|
||||
*
|
||||
* @param val an <code>int</code> value
|
||||
* @return true if the list was modified by the add operation
|
||||
*/
|
||||
public boolean add(int val);
|
||||
|
||||
|
||||
/**
|
||||
* Adds the values in the array <tt>vals</tt> to the end of the
|
||||
* list, in order.
|
||||
*
|
||||
* @param vals an <code>int[]</code> value
|
||||
*/
|
||||
public void add( int[] vals );
|
||||
|
||||
|
||||
/**
|
||||
* Adds a subset of the values in the array <tt>vals</tt> to the
|
||||
* end of the list, in order.
|
||||
*
|
||||
* @param vals an <code>int[]</code> value
|
||||
* @param offset the offset at which to start copying
|
||||
* @param length the number of values to copy.
|
||||
*/
|
||||
public void add( int[] vals, int offset, int length );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts <tt>value</tt> into the list at <tt>offset</tt>. All
|
||||
* values including and to the right of <tt>offset</tt> are shifted
|
||||
* to the right.
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @param value an <code>int</code> value
|
||||
*/
|
||||
public void insert( int offset, int value );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts the array of <tt>values</tt> into the list at
|
||||
* <tt>offset</tt>. All values including and to the right of
|
||||
* <tt>offset</tt> are shifted to the right.
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @param values an <code>int[]</code> value
|
||||
*/
|
||||
public void insert( int offset, int[] values );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a slice of the array of <tt>values</tt> into the list
|
||||
* at <tt>offset</tt>. All values including and to the right of
|
||||
* <tt>offset</tt> are shifted to the right.
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @param values an <code>int[]</code> value
|
||||
* @param valOffset the offset in the values array at which to
|
||||
* start copying.
|
||||
* @param len the number of values to copy from the values array
|
||||
*/
|
||||
public void insert( int offset, int[] values, int valOffset, int len );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value at the specified offset.
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @return an <code>int</code> value
|
||||
*/
|
||||
public int get( int offset );
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value at the specified offset.
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @param val an <code>int</code> value
|
||||
*
|
||||
* @return The value previously at the given index.
|
||||
*/
|
||||
public int set( int offset, int val );
|
||||
|
||||
|
||||
/**
|
||||
* Replace the values in the list starting at <tt>offset</tt> with
|
||||
* the contents of the <tt>values</tt> array.
|
||||
*
|
||||
* @param offset the first offset to replace
|
||||
* @param values the source of the new values
|
||||
*/
|
||||
public void set( int offset, int[] values );
|
||||
|
||||
|
||||
/**
|
||||
* Replace the values in the list starting at <tt>offset</tt> with
|
||||
* <tt>length</tt> values from the <tt>values</tt> array, starting
|
||||
* at valOffset.
|
||||
*
|
||||
* @param offset the first offset to replace
|
||||
* @param values the source of the new values
|
||||
* @param valOffset the first value to copy from the values array
|
||||
* @param length the number of values to copy
|
||||
*/
|
||||
public void set( int offset, int[] values, int valOffset, int length );
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value at the specified offset and returns the
|
||||
* previously stored value.
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @param val an <code>int</code> value
|
||||
* @return the value previously stored at offset.
|
||||
*/
|
||||
public int replace( int offset, int val );
|
||||
|
||||
|
||||
/**
|
||||
* Flushes the internal state of the list, resetting the capacity
|
||||
* to the default.
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>value</tt> from the list.
|
||||
*
|
||||
* @param value an <code>int</code> value
|
||||
* @return true if the list was modified by the remove operation.
|
||||
*/
|
||||
public boolean remove( int value );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>value</tt> at a given offset from the list.
|
||||
*
|
||||
* @param offset an <code>int</code> value that represents
|
||||
* the offset to the element to be removed
|
||||
* @return an <tt>int</tt> that is the value removed.
|
||||
*/
|
||||
public int removeAt( int offset );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>length</tt> values from the list, starting at
|
||||
* <tt>offset</tt>
|
||||
*
|
||||
* @param offset an <code>int</code> value
|
||||
* @param length an <code>int</code> value
|
||||
*/
|
||||
public void remove( int offset, int length );
|
||||
|
||||
|
||||
/**
|
||||
* Transform each value in the list using the specified function.
|
||||
*
|
||||
* @param function a <code>TIntFunction</code> value
|
||||
*/
|
||||
public void transformValues( TIntFunction function );
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the order of the elements in the list.
|
||||
*/
|
||||
public void reverse();
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the order of the elements in the range of the list.
|
||||
*
|
||||
* @param from the inclusive index at which to start reversing
|
||||
* @param to the exclusive index at which to stop reversing
|
||||
*/
|
||||
public void reverse( int from, int to );
|
||||
|
||||
|
||||
/**
|
||||
* Shuffle the elements of the list using the specified random
|
||||
* number generator.
|
||||
*
|
||||
* @param rand a <code>Random</code> value
|
||||
*/
|
||||
public void shuffle( Random rand );
|
||||
|
||||
|
||||
/**
|
||||
* Returns a sublist of this list.
|
||||
*
|
||||
* @param begin low endpoint (inclusive) of the subList.
|
||||
* @param end high endpoint (exclusive) of the subList.
|
||||
* @return sublist of this list from begin, inclusive to end, exclusive.
|
||||
* @throws IndexOutOfBoundsException - endpoint out of range
|
||||
* @throws IllegalArgumentException - endpoints out of order (end > begin)
|
||||
*/
|
||||
public TIntList subList( int begin, int end );
|
||||
|
||||
|
||||
/**
|
||||
* Copies the contents of the list into a native array.
|
||||
*
|
||||
* @return an <code>int[]</code> value
|
||||
*/
|
||||
public int[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Copies a slice of the list into a native array.
|
||||
*
|
||||
* @param offset the offset at which to start copying
|
||||
* @param len the number of values to copy.
|
||||
* @return an <code>int[]</code> value
|
||||
*/
|
||||
public int[] toArray( int offset, int len );
|
||||
|
||||
|
||||
/**
|
||||
* Copies a slice of the list into a native array.
|
||||
*
|
||||
* <p>If the list fits in the specified array with room to spare (i.e.,
|
||||
* the array has more elements than the list), the element in the array
|
||||
* immediately following the end of the list is set to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>.
|
||||
* (This is useful in determining the length of the list <i>only</i> if
|
||||
* the caller knows that the list does not contain any "null" elements.)
|
||||
*
|
||||
* <p>NOTE: Trove does not allocate a new array if the array passed in is
|
||||
* not large enough to hold all of the data elements. It will instead fill
|
||||
* the array passed in.
|
||||
*
|
||||
* @param dest the array to copy into.
|
||||
* @return the array passed in.
|
||||
*/
|
||||
public int[] toArray( int[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Copies a slice of the list into a native array.
|
||||
*
|
||||
* @param dest the array to copy into.
|
||||
* @param offset the offset where the first value should be copied
|
||||
* @param len the number of values to copy.
|
||||
* @return the array passed in.
|
||||
*/
|
||||
public int[] toArray( int[] dest, int offset, int len );
|
||||
|
||||
|
||||
/**
|
||||
* Copies a slice of the list into a native array.
|
||||
*
|
||||
* @param dest the array to copy into.
|
||||
* @param source_pos the offset of the first value to copy
|
||||
* @param dest_pos the offset where the first value should be copied
|
||||
* @param len the number of values to copy.
|
||||
* @return the array passed in.
|
||||
*/
|
||||
public int[] toArray( int[] dest, int source_pos, int dest_pos, int len );
|
||||
|
||||
|
||||
/**
|
||||
* Applies the procedure to each value in the list in ascending
|
||||
* (front to back) order.
|
||||
*
|
||||
* @param procedure a <code>TIntProcedure</code> value
|
||||
* @return true if the procedure did not terminate prematurely.
|
||||
*/
|
||||
public boolean forEach( TIntProcedure procedure );
|
||||
|
||||
|
||||
/**
|
||||
* Applies the procedure to each value in the list in descending
|
||||
* (back to front) order.
|
||||
*
|
||||
* @param procedure a <code>TIntProcedure</code> value
|
||||
* @return true if the procedure did not terminate prematurely.
|
||||
*/
|
||||
public boolean forEachDescending( TIntProcedure procedure );
|
||||
|
||||
|
||||
/**
|
||||
* Sort the values in the list (ascending) using the Sun quicksort
|
||||
* implementation.
|
||||
*
|
||||
* @see java.util.Arrays#sort
|
||||
*/
|
||||
public void sort();
|
||||
|
||||
|
||||
/**
|
||||
* Sort a slice of the list (ascending) using the Sun quicksort
|
||||
* implementation.
|
||||
*
|
||||
* @param fromIndex the index at which to start sorting (inclusive)
|
||||
* @param toIndex the index at which to stop sorting (exclusive)
|
||||
* @see java.util.Arrays#sort
|
||||
*/
|
||||
public void sort( int fromIndex, int toIndex );
|
||||
|
||||
|
||||
/**
|
||||
* Fills every slot in the list with the specified value.
|
||||
*
|
||||
* @param val the value to use when filling
|
||||
*/
|
||||
public void fill( int val );
|
||||
|
||||
|
||||
/**
|
||||
* Fills a range in the list with the specified value.
|
||||
*
|
||||
* @param fromIndex the offset at which to start filling (inclusive)
|
||||
* @param toIndex the offset at which to stop filling (exclusive)
|
||||
* @param val the value to use when filling
|
||||
*/
|
||||
public void fill( int fromIndex, int toIndex, int val );
|
||||
|
||||
|
||||
/**
|
||||
* Performs a binary search for <tt>value</tt> in the entire list.
|
||||
* Note that you <b>must</b> @{link #sort sort} the list before
|
||||
* doing a search.
|
||||
*
|
||||
* @param value the value to search for
|
||||
* @return the absolute offset in the list of the value, or its
|
||||
* negative insertion point into the sorted list.
|
||||
*/
|
||||
public int binarySearch( int value );
|
||||
|
||||
|
||||
/**
|
||||
* Performs a binary search for <tt>value</tt> in the specified
|
||||
* range. Note that you <b>must</b> @{link #sort sort} the list
|
||||
* or the range before doing a search.
|
||||
*
|
||||
* @param value the value to search for
|
||||
* @param fromIndex the lower boundary of the range (inclusive)
|
||||
* @param toIndex the upper boundary of the range (exclusive)
|
||||
* @return the absolute offset in the list of the value, or its
|
||||
* negative insertion point into the sorted list.
|
||||
*/
|
||||
public int binarySearch( int value, int fromIndex, int toIndex );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list front to back for the index of
|
||||
* <tt>value</tt>.
|
||||
*
|
||||
* @param value an <code>int</code> value
|
||||
* @return the first offset of the value, or -1 if it is not in
|
||||
* the list.
|
||||
* @see #binarySearch for faster searches on sorted lists
|
||||
*/
|
||||
public int indexOf( int value );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list front to back for the index of
|
||||
* <tt>value</tt>, starting at <tt>offset</tt>.
|
||||
*
|
||||
* @param offset the offset at which to start the linear search
|
||||
* (inclusive)
|
||||
* @param value an <code>int</code> value
|
||||
* @return the first offset of the value, or -1 if it is not in
|
||||
* the list.
|
||||
* @see #binarySearch for faster searches on sorted lists
|
||||
*/
|
||||
public int indexOf( int offset, int value );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list back to front for the last index of
|
||||
* <tt>value</tt>.
|
||||
*
|
||||
* @param value an <code>int</code> value
|
||||
* @return the last offset of the value, or -1 if it is not in
|
||||
* the list.
|
||||
* @see #binarySearch for faster searches on sorted lists
|
||||
*/
|
||||
public int lastIndexOf( int value );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list back to front for the last index of
|
||||
* <tt>value</tt>, starting at <tt>offset</tt>.
|
||||
*
|
||||
* @param offset the offset at which to start the linear search
|
||||
* (exclusive)
|
||||
* @param value an <code>int</code> value
|
||||
* @return the last offset of the value, or -1 if it is not in
|
||||
* the list.
|
||||
* @see #binarySearch for faster searches on sorted lists
|
||||
*/
|
||||
public int lastIndexOf( int offset, int value );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list for <tt>value</tt>
|
||||
*
|
||||
* @param value an <code>int</code> value
|
||||
* @return true if value is in the list.
|
||||
*/
|
||||
public boolean contains( int value );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list for values satisfying <tt>condition</tt> in
|
||||
* the manner of the *nix <tt>grep</tt> utility.
|
||||
*
|
||||
* @param condition a condition to apply to each element in the list
|
||||
* @return a list of values which match the condition.
|
||||
*/
|
||||
public TIntList grep( TIntProcedure condition );
|
||||
|
||||
|
||||
/**
|
||||
* Searches the list for values which do <b>not</b> satisfy
|
||||
* <tt>condition</tt>. This is akin to *nix <code>grep -v</code>.
|
||||
*
|
||||
* @param condition a condition to apply to each element in the list
|
||||
* @return a list of values which do not match the condition.
|
||||
*/
|
||||
public TIntList inverseGrep( TIntProcedure condition );
|
||||
|
||||
|
||||
/**
|
||||
* Finds the maximum value in the list.
|
||||
*
|
||||
* @return the largest value in the list.
|
||||
* @exception IllegalStateException if the list is empty
|
||||
*/
|
||||
public int max();
|
||||
|
||||
|
||||
/**
|
||||
* Finds the minimum value in the list.
|
||||
*
|
||||
* @return the smallest value in the list.
|
||||
* @exception IllegalStateException if the list is empty
|
||||
*/
|
||||
public int min();
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,425 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.map;
|
||||
|
||||
import gnu.trove.iterator.TFloatObjectIterator;
|
||||
import gnu.trove.procedure.TFloatProcedure;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
import gnu.trove.procedure.TFloatObjectProcedure;
|
||||
import gnu.trove.function.TObjectFunction;
|
||||
import gnu.trove.set.TFloatSet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for a primitive map of float keys and Object values.
|
||||
*/
|
||||
public interface TFloatObjectMap<V> {
|
||||
|
||||
// Query Operations
|
||||
|
||||
/**
|
||||
* Returns the value that represents null in the {@link #keySet()}.
|
||||
* The default value is generally zero, but can be changed during
|
||||
* construction of the collection.
|
||||
*
|
||||
* @return the value that represents a null value in this collection.
|
||||
*/
|
||||
float getNoEntryKey();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of key-value mappings in this map. If the
|
||||
* map contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of key-value mappings in this map
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this map contains no key-value mappings.
|
||||
*
|
||||
* @return <tt>true</tt> if this map contains no key-value mappings
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this map contains a mapping for the specified
|
||||
* key. More formally, returns <tt>true</tt> if and only if
|
||||
* this map contains a mapping for a key <tt>k</tt> such that
|
||||
* <tt>key.equals(k)</tt>. (There can be at most one such mapping.)
|
||||
*
|
||||
* @param key key whose presence in this map is to be tested
|
||||
* @return <tt>true</tt> if this map contains a mapping for the specified
|
||||
* key
|
||||
* @throws ClassCastException if the key is of an inappropriate type for
|
||||
* this map (optional)
|
||||
* @throws NullPointerException if the specified key is null and this map
|
||||
* does not permit null keys (optional)
|
||||
*/
|
||||
boolean containsKey( float key );
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this map maps one or more keys to the
|
||||
* specified value. More formally, returns <tt>true</tt> if and only if
|
||||
* this map contains at least one mapping to a value <tt>v</tt> such that
|
||||
* <tt>(value==null ? v==null : value.equals(v))</tt>. This operation
|
||||
* will probably require time linear in the map size for most
|
||||
* implementations of the <tt>Map</tt> interface.
|
||||
*
|
||||
* @param value value whose presence in this map is to be tested
|
||||
* @return <tt>true</tt> if this map maps one or more keys to the
|
||||
* specified value
|
||||
* @throws ClassCastException if the value is of an inappropriate type for
|
||||
* this map (optional)
|
||||
* @throws NullPointerException if the specified value is null and this
|
||||
* map does not permit null values (optional)
|
||||
*/
|
||||
boolean containsValue( Object value );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value to which the specified key is mapped,
|
||||
* or {@code null} if this map contains no mapping for the key.
|
||||
*
|
||||
* <p>More formally, if this map contains a mapping from a key
|
||||
* {@code k} to a value {@code v} such that {@code (key==null ? k==null :
|
||||
* key.equals(k))}, then this method returns {@code v}; otherwise
|
||||
* it returns {@code null}. (There can be at most one such mapping.)
|
||||
*
|
||||
* <p>If this map permits null values, then a return value of
|
||||
* {@code null} does not <i>necessarily</i> indicate that the map
|
||||
* contains no mapping for the key; it's also possible that the map
|
||||
* explicitly maps the key to {@code null}. The {@link #containsKey
|
||||
* containsKey} operation may be used to distinguish these two cases.
|
||||
*
|
||||
* @param key the key whose associated value is to be returned
|
||||
* @return the <tt>float</tt> value to which the specified key is mapped, or
|
||||
* {@code null} if this map contains no mapping for the key
|
||||
* @throws ClassCastException if the key is of an inappropriate type for
|
||||
* this map (optional)
|
||||
* @throws NullPointerException if the specified key is null and this map
|
||||
* does not permit null keys (optional)
|
||||
*/
|
||||
V get( float key );
|
||||
|
||||
|
||||
// Modification Operations
|
||||
|
||||
/**
|
||||
* Associates the specified value with the specified key in this map
|
||||
* (optional operation). If the map previously contained a mapping for
|
||||
* the key, the old value is replaced by the specified value. (A map
|
||||
* <tt>m</tt> is said to contain a mapping for a key <tt>k</tt> if and only
|
||||
* if {@link #containsKey(float) m.containsKey(k)} would return
|
||||
* <tt>true</tt>.)
|
||||
*
|
||||
* @param key key with which the specified value is to be associated
|
||||
* @param value an <tt>float</tt> value value to be associated with the specified key
|
||||
* @return the previous value associated with <tt>key</tt>, or
|
||||
* <tt>no_entry_value</tt> if there was no mapping for <tt>key</tt>.
|
||||
* (A <tt>no_entry_value</tt> return can also indicate that the map
|
||||
* previously associated <tt>null</tt> with <tt>key</tt>,
|
||||
* if the implementation supports <tt>null</tt> values.)
|
||||
* @throws UnsupportedOperationException if the <tt>put</tt> operation
|
||||
* is not supported by this map
|
||||
* @throws ClassCastException if the class of the specified key or value
|
||||
* prevents it from being stored in this map
|
||||
* @throws NullPointerException if the specified key or value is null
|
||||
* and this map does not permit null keys or values
|
||||
* @throws IllegalArgumentException if some property of the specified key
|
||||
* or value prevents it from being stored in this map
|
||||
* @see #getNoEntryKey()
|
||||
*/
|
||||
V put( float key, V value);
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a key/value pair into the map if the specified key is not already
|
||||
* associated with a value.
|
||||
*
|
||||
* @param key key with which the specified value is to be associated
|
||||
* @param value an <tt>float</tt> value to be associated with the specified key
|
||||
*
|
||||
* @return the previous value associated with <tt>key</tt>, or null
|
||||
* if none was found.
|
||||
*/
|
||||
V putIfAbsent( float key, V value );
|
||||
|
||||
|
||||
/**
|
||||
* Removes the mapping for a key from this map if it is present
|
||||
* (optional operation). More formally, if this map contains a mapping
|
||||
* from key <tt>k</tt> to value <tt>v</tt> such that
|
||||
* <code>key.equals(k)</code>, that mapping
|
||||
* is removed. (The map can contain at most one such mapping.)
|
||||
*
|
||||
* <p>Returns the value to which this map previously associated the key,
|
||||
* or <tt>null</tt> if the map contained no mapping for the key.
|
||||
*
|
||||
* <p>If this map permits null values, then a return value of
|
||||
* <tt>null</tt> does not <i>necessarily</i> indicate that the map
|
||||
* contained no mapping for the key; it's also possible that the map
|
||||
* explicitly mapped the key to <tt>null</tt>.
|
||||
*
|
||||
* <p>The map will not contain a mapping for the specified key once the
|
||||
* call returns.
|
||||
*
|
||||
* @param key key whose mapping is to be removed from the map
|
||||
* @return the previous <tt>float</tt> value associated with <tt>key</tt>, or
|
||||
* <tt>null</tt> if there was no mapping for <tt>key</tt>.
|
||||
* @throws UnsupportedOperationException if the <tt>remove</tt> operation
|
||||
* is not supported by this map
|
||||
* @throws ClassCastException if the key is of an inappropriate type for
|
||||
* this map (optional)
|
||||
* @throws NullPointerException if the specified key is null and this
|
||||
* map does not permit null keys (optional)
|
||||
*/
|
||||
V remove( float key );
|
||||
|
||||
|
||||
// Bulk Operations
|
||||
|
||||
/**
|
||||
* Copies all of the mappings from the specified map to this map
|
||||
* (optional operation). The effect of this call is equivalent to that
|
||||
* of calling {@link #put(float,Object) put(k, v)} on this map once
|
||||
* for each mapping from key <tt>k</tt> to value <tt>v</tt> in the
|
||||
* specified map. The behavior of this operation is undefined if the
|
||||
* specified map is modified while the operation is in progress.
|
||||
*
|
||||
* @param m mappings to be stored in this map
|
||||
* @throws UnsupportedOperationException if the <tt>putAll</tt> operation
|
||||
* is not supported by this map
|
||||
* @throws ClassCastException if the class of a key or value in the
|
||||
* specified map prevents it from being stored in this map
|
||||
* @throws NullPointerException if the specified map is null, or if
|
||||
* this map does not permit null keys or values, and the
|
||||
* specified map contains null keys or values
|
||||
* @throws IllegalArgumentException if some property of a key or value in
|
||||
* the specified map prevents it from being stored in this map
|
||||
*/
|
||||
void putAll( Map<? extends Float, ? extends V> m);
|
||||
|
||||
|
||||
/**
|
||||
* Put all the entries from the given map into this map.
|
||||
*
|
||||
* @param map The map from which entries will be obtained to put into this map.
|
||||
*/
|
||||
void putAll( TFloatObjectMap<V> map );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the mappings from this map (optional operation).
|
||||
* The map will be empty after this call returns.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the <tt>clear</tt> operation
|
||||
* is not supported by this map
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
// Views
|
||||
|
||||
/**
|
||||
* Returns a {@link TFloatSet} view of the keys contained in this map.
|
||||
* The set is backed by the map, so changes to the map are
|
||||
* reflected in the set, and vice-versa. If the map is modified
|
||||
* while an iteration over the set is in progress (except through
|
||||
* the iterator's own <tt>remove</tt> operation), the results of
|
||||
* the iteration are undefined. The set supports element removal,
|
||||
* which removes the corresponding mapping from the map, via the
|
||||
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
|
||||
* <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
|
||||
* operations. It does not support the <tt>add</tt> or <tt>addAll</tt>
|
||||
* operations.
|
||||
*
|
||||
* @return a set view of the keys contained in this map
|
||||
*/
|
||||
TFloatSet keySet();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a copy of the keys of the map as an array.
|
||||
* Changes to the array of keys will not be reflected in the map
|
||||
* nor vice-versa.
|
||||
*
|
||||
* @return a copy of the keys of the map as an array.
|
||||
*/
|
||||
float[] keys();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a copy of the keys of the map as an array.
|
||||
* Changes to the array of keys will not be reflected in the map
|
||||
* nor vice-versa.
|
||||
*
|
||||
* @param array the array into which the elements of the list are to be stored,
|
||||
* if it is big enough; otherwise, a new array of the same type is
|
||||
* allocated for this purpose.
|
||||
* @return the keys of the map as an array.
|
||||
*/
|
||||
float[] keys( float[] array );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a {@link Collection} view of the values contained in this map.
|
||||
* The collection is backed by the map, so changes to the map are
|
||||
* reflected in the collection, and vice-versa. If the map is
|
||||
* modified while an iteration over the collection is in progress
|
||||
* (except through the iterator's own <tt>remove</tt> operation),
|
||||
* the results of the iteration are undefined. The collection
|
||||
* supports element removal, which removes the corresponding
|
||||
* mapping from the map, via the <tt>Iterator.remove</tt>,
|
||||
* <tt>Collection.remove</tt>, <tt>removeAll</tt>,
|
||||
* <tt>retainAll</tt> and <tt>clear</tt> operations. It does not
|
||||
* support the <tt>add</tt> or <tt>addAll</tt> operations.
|
||||
*
|
||||
* @return a collection view of the values contained in this map
|
||||
*/
|
||||
Collection<V> valueCollection();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the values of the map as an array of <tt>float</tt> values.
|
||||
* Changes to the array of values will not be reflected in the map
|
||||
* nor vice-versa.
|
||||
*
|
||||
* @return the values of the map as an array of <tt>float</tt> values.
|
||||
*/
|
||||
V[] values();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the values of the map using an existing array.
|
||||
* Changes to the array of values will not be reflected in the map
|
||||
* nor vice-versa.
|
||||
*
|
||||
* @param array the array into which the elements of the list are to be stored,
|
||||
* if it is big enough; otherwise, a new array of the same type is
|
||||
* allocated for this purpose.
|
||||
* @return the values of the map as an array of <tt>float</tt> values.
|
||||
*/
|
||||
<T> T[] values( T[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Returns a <tt>TFloatObjectIterator</tt> with access to this map's keys and values.
|
||||
*
|
||||
* @return a <tt>TFloatObjectIterator</tt> with access to this map's keys and values.
|
||||
*/
|
||||
public TFloatObjectIterator<V> iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each key in the map.
|
||||
*
|
||||
* @param procedure a <code>TObjectProcedure</code> value
|
||||
* @return false if the loop over the keys terminated because
|
||||
* the procedure returned false for some key.
|
||||
*/
|
||||
public boolean forEachKey( TFloatProcedure procedure );
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each value in the map.
|
||||
*
|
||||
* @param procedure a <code>TObjectProcedure</code> value
|
||||
* @return false if the loop over the values terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
public boolean forEachValue( TObjectProcedure<V> procedure );
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each key/value entry in the
|
||||
* map.
|
||||
*
|
||||
* @param procedure a <code>TFloatObjectProcedure</code> value
|
||||
* @return false if the loop over the entries terminated because
|
||||
* the procedure returned false for some entry.
|
||||
*/
|
||||
public boolean forEachEntry( TFloatObjectProcedure<V> procedure );
|
||||
|
||||
|
||||
/**
|
||||
* Transform the values in this map using <tt>function</tt>.
|
||||
*
|
||||
* @param function a <code>TObjectFunction</code> value
|
||||
*/
|
||||
public void transformValues( TObjectFunction<V,V> function );
|
||||
|
||||
|
||||
/**
|
||||
* Retains only those entries in the map for which the procedure
|
||||
* returns a true value.
|
||||
*
|
||||
* @param procedure determines which entries to keep
|
||||
* @return true if the map was modified.
|
||||
*/
|
||||
public boolean retainEntries( TFloatObjectProcedure<V> procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this map for equality. Returns
|
||||
* <tt>true</tt> if the given object is also a map and the two maps
|
||||
* represent the same mappings. More formally, two maps <tt>m1</tt> and
|
||||
* <tt>m2</tt> represent the same mappings if
|
||||
* <tt>m1.entrySet().equals(m2.entrySet())</tt>. This ensures that the
|
||||
* <tt>equals</tt> method works properly across different implementations
|
||||
* of the <tt>Map</tt> interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this map
|
||||
* @return <tt>true</tt> if the specified object is equal to this map
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this map. The hash code of a map is
|
||||
* defined to be the sum of the hash codes of each entry in the map's
|
||||
* <tt>entrySet()</tt> view. This ensures that <tt>m1.equals(m2)</tt>
|
||||
* implies that <tt>m1.hashCode()==m2.hashCode()</tt> for any two maps
|
||||
* <tt>m1</tt> and <tt>m2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this map
|
||||
|
||||
* @see Object#equals(Object)
|
||||
* @see #equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,42 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.procedure;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for procedures that take two parameters of type float and Object.
|
||||
*/
|
||||
public interface TFloatObjectProcedure<T> {
|
||||
|
||||
/**
|
||||
* Executes this procedure. A false return value indicates that
|
||||
* the application executing this procedure should not invoke this
|
||||
* procedure again.
|
||||
*
|
||||
* @param a a <code>float</code> value
|
||||
* @param b an <code>Object</code> value
|
||||
* @return true if additional invocations of the procedure are
|
||||
* allowed.
|
||||
*/
|
||||
public boolean execute( float a, T b );
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.procedure;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for procedures with one float parameter.
|
||||
*/
|
||||
public interface TFloatProcedure {
|
||||
/**
|
||||
* Executes this procedure. A false return value indicates that
|
||||
* the application executing this procedure should not invoke this
|
||||
* procedure again.
|
||||
*
|
||||
* @param value a value of type <code>float</code>
|
||||
* @return true if additional invocations of the procedure are
|
||||
* allowed.
|
||||
*/
|
||||
public boolean execute( float value );
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.procedure;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for procedures with one int parameter.
|
||||
*/
|
||||
public interface TIntProcedure {
|
||||
/**
|
||||
* Executes this procedure. A false return value indicates that
|
||||
* the application executing this procedure should not invoke this
|
||||
* procedure again.
|
||||
*
|
||||
* @param value a value of type <code>int</code>
|
||||
* @return true if additional invocations of the procedure are
|
||||
* allowed.
|
||||
*/
|
||||
public boolean execute( int value );
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.procedure;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Interface for procedures with one long parameter.
|
||||
*/
|
||||
public interface TLongProcedure {
|
||||
/**
|
||||
* Executes this procedure. A false return value indicates that
|
||||
* the application executing this procedure should not invoke this
|
||||
* procedure again.
|
||||
*
|
||||
* @param value a value of type <code>long</code>
|
||||
* @return true if additional invocations of the procedure are
|
||||
* allowed.
|
||||
*/
|
||||
public boolean execute( long value );
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
package gnu.trove.procedure;
|
||||
|
||||
/**
|
||||
* Interface for procedures with one Object parameter.
|
||||
*
|
||||
* Created: Mon Nov 5 21:45:49 2001
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @version $Id: TObjectProcedure.java,v 1.1.2.1 2009/09/02 21:52:33 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TObjectProcedure<T> {
|
||||
/**
|
||||
* Executes this procedure. A false return value indicates that
|
||||
* the application executing this procedure should not invoke this
|
||||
* procedure again.
|
||||
*
|
||||
* @param object an <code>Object</code> value
|
||||
* @return true if additional invocations of the procedure are
|
||||
* allowed.
|
||||
*/
|
||||
public boolean execute(T object);
|
||||
}// TObjectProcedure
|
|
@ -1,320 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.set;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
import gnu.trove.iterator.TFloatIterator;
|
||||
import gnu.trove.procedure.TFloatProcedure;
|
||||
import gnu.trove.TFloatCollection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An implementation of the <tt>Set</tt> interface that uses an
|
||||
* open-addressed hash table to store its contents.
|
||||
*
|
||||
* Created: Sat Nov 3 10:38:17 2001
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: _E_Set.template,v 1.1.2.5 2009/09/15 02:38:31 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TFloatSet extends TFloatCollection, Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
float getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this set (its cardinality). If this
|
||||
* set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of elements in this set (its cardinality)
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this set contains no elements.
|
||||
*
|
||||
* @return <tt>true</tt> if this set contains no elements
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this set contains the specified element.
|
||||
*
|
||||
* @param entry an <code>float</code> value
|
||||
* @return true if the set contains the specified element.
|
||||
*/
|
||||
boolean contains( float entry );
|
||||
|
||||
|
||||
/**
|
||||
* Creates an iterator over the values of the set. The iterator
|
||||
* supports element deletion.
|
||||
*
|
||||
* @return an <code>TFloatIterator</code> value
|
||||
*/
|
||||
TFloatIterator iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this set.
|
||||
* If this set makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the
|
||||
* elements in the same order.
|
||||
*
|
||||
* <p>The returned array will be "safe" in that no references to it
|
||||
* are maintained by this set. (In other words, this method must
|
||||
* allocate a new array even if this set is backed by an array).
|
||||
* The caller is thus free to modify the returned array.
|
||||
*
|
||||
* <p>This method acts as bridge between array-based and collection-based
|
||||
* APIs.
|
||||
*
|
||||
* @return an array containing all the elements in this set
|
||||
*/
|
||||
float[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing elements in this set.
|
||||
*
|
||||
* <p>If this set fits in the specified array with room to spare
|
||||
* (i.e., the array has more elements than this set), the element in
|
||||
* the array immediately following the end of the set is set to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
|
||||
* the length of this set <i>only</i> if the caller knows that this
|
||||
* set does not contain any elements representing null.)
|
||||
*
|
||||
* <p>If the native array is smaller than the set size,
|
||||
* the array will be filled with elements in Iterator order
|
||||
* until it is full and exclude the remainder.
|
||||
*
|
||||
* <p>If this set makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the elements
|
||||
* in the same order.
|
||||
*
|
||||
* @param dest the array into which the elements of this set are to be
|
||||
* stored.
|
||||
* @return an <tt>float[]</tt> containing all the elements in this set
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
float[] toArray( float[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a value into the set.
|
||||
*
|
||||
* @param entry a <code>float</code> value
|
||||
* @return true if the set was modified by the add operation
|
||||
*/
|
||||
boolean add( float entry );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>entry</tt> from the set.
|
||||
*
|
||||
* @param entry an <code>float</code> value
|
||||
* @return true if the set was modified by the remove operation.
|
||||
*/
|
||||
boolean remove( float entry );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>collection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>TFloatCollection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>array</tt> are present.
|
||||
*
|
||||
* @param array as <code>array</code> of float primitives.
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in <tt>collection</tt> to the set.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( Collection<? extends Float> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>TFloatCollection</tt> to the set.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>array</tt> to the set.
|
||||
*
|
||||
* @param array a <code>array</code> of float primitives.
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>collection</tt>.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>TFloatCollection</tt>.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>array</tt>.
|
||||
*
|
||||
* @param array an <code>array</code> of float primitives.
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>collection</tt> from the set.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>TFloatCollection</tt> from the set.
|
||||
*
|
||||
* @param collection a <code>TFloatCollection</code> value
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( TFloatCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>array</tt> from the set.
|
||||
*
|
||||
* @param array an <code>array</code> of float primitives.
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
public boolean removeAll( float[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Empties the set.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the set.
|
||||
*
|
||||
* @param procedure a <code>TFloatProcedure</code> value
|
||||
* @return false if the loop over the set terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
boolean forEach( TFloatProcedure procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this set for equality. Returns
|
||||
* <tt>true</tt> if the specified object is also a set, the two sets
|
||||
* have the same size, and every member of the specified set is
|
||||
* contained in this set (or equivalently, every member of this set is
|
||||
* contained in the specified set). This definition ensures that the
|
||||
* equals method works properly across different implementations of the
|
||||
* set interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this set
|
||||
* @return <tt>true</tt> if the specified object is equal to this set
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this set. The hash code of a set is
|
||||
* defined to be the sum of the hash codes of the elements in the set.
|
||||
* This ensures that <tt>s1.equals(s2)</tt> implies that
|
||||
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two sets <tt>s1</tt>
|
||||
* and <tt>s2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this set
|
||||
* @see Object#equals(Object)
|
||||
* @see Set#equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
|
||||
} // THashSet
|
|
@ -1,320 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.set;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
import gnu.trove.iterator.TIntIterator;
|
||||
import gnu.trove.procedure.TIntProcedure;
|
||||
import gnu.trove.TIntCollection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An implementation of the <tt>Set</tt> interface that uses an
|
||||
* open-addressed hash table to store its contents.
|
||||
*
|
||||
* Created: Sat Nov 3 10:38:17 2001
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: _E_Set.template,v 1.1.2.5 2009/09/15 02:38:31 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TIntSet extends TIntCollection, Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
int getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this set (its cardinality). If this
|
||||
* set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of elements in this set (its cardinality)
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this set contains no elements.
|
||||
*
|
||||
* @return <tt>true</tt> if this set contains no elements
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this set contains the specified element.
|
||||
*
|
||||
* @param entry an <code>int</code> value
|
||||
* @return true if the set contains the specified element.
|
||||
*/
|
||||
boolean contains( int entry );
|
||||
|
||||
|
||||
/**
|
||||
* Creates an iterator over the values of the set. The iterator
|
||||
* supports element deletion.
|
||||
*
|
||||
* @return an <code>TIntIterator</code> value
|
||||
*/
|
||||
TIntIterator iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this set.
|
||||
* If this set makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the
|
||||
* elements in the same order.
|
||||
*
|
||||
* <p>The returned array will be "safe" in that no references to it
|
||||
* are maintained by this set. (In other words, this method must
|
||||
* allocate a new array even if this set is backed by an array).
|
||||
* The caller is thus free to modify the returned array.
|
||||
*
|
||||
* <p>This method acts as bridge between array-based and collection-based
|
||||
* APIs.
|
||||
*
|
||||
* @return an array containing all the elements in this set
|
||||
*/
|
||||
int[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing elements in this set.
|
||||
*
|
||||
* <p>If this set fits in the specified array with room to spare
|
||||
* (i.e., the array has more elements than this set), the element in
|
||||
* the array immediately following the end of the set is set to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
|
||||
* the length of this set <i>only</i> if the caller knows that this
|
||||
* set does not contain any elements representing null.)
|
||||
*
|
||||
* <p>If the native array is smaller than the set size,
|
||||
* the array will be filled with elements in Iterator order
|
||||
* until it is full and exclude the remainder.
|
||||
*
|
||||
* <p>If this set makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the elements
|
||||
* in the same order.
|
||||
*
|
||||
* @param dest the array into which the elements of this set are to be
|
||||
* stored.
|
||||
* @return an <tt>int[]</tt> containing all the elements in this set
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
int[] toArray( int[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a value into the set.
|
||||
*
|
||||
* @param entry a <code>int</code> value
|
||||
* @return true if the set was modified by the add operation
|
||||
*/
|
||||
boolean add( int entry );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>entry</tt> from the set.
|
||||
*
|
||||
* @param entry an <code>int</code> value
|
||||
* @return true if the set was modified by the remove operation.
|
||||
*/
|
||||
boolean remove( int entry );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>collection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>TIntCollection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>array</tt> are present.
|
||||
*
|
||||
* @param array as <code>array</code> of int primitives.
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in <tt>collection</tt> to the set.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( Collection<? extends Integer> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>TIntCollection</tt> to the set.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>array</tt> to the set.
|
||||
*
|
||||
* @param array a <code>array</code> of int primitives.
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>collection</tt>.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>TIntCollection</tt>.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>array</tt>.
|
||||
*
|
||||
* @param array an <code>array</code> of int primitives.
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>collection</tt> from the set.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>TIntCollection</tt> from the set.
|
||||
*
|
||||
* @param collection a <code>TIntCollection</code> value
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( TIntCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>array</tt> from the set.
|
||||
*
|
||||
* @param array an <code>array</code> of int primitives.
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
public boolean removeAll( int[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Empties the set.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the set.
|
||||
*
|
||||
* @param procedure a <code>TIntProcedure</code> value
|
||||
* @return false if the loop over the set terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
boolean forEach( TIntProcedure procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this set for equality. Returns
|
||||
* <tt>true</tt> if the specified object is also a set, the two sets
|
||||
* have the same size, and every member of the specified set is
|
||||
* contained in this set (or equivalently, every member of this set is
|
||||
* contained in the specified set). This definition ensures that the
|
||||
* equals method works properly across different implementations of the
|
||||
* set interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this set
|
||||
* @return <tt>true</tt> if the specified object is equal to this set
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this set. The hash code of a set is
|
||||
* defined to be the sum of the hash codes of the elements in the set.
|
||||
* This ensures that <tt>s1.equals(s2)</tt> implies that
|
||||
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two sets <tt>s1</tt>
|
||||
* and <tt>s2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this set
|
||||
* @see Object#equals(Object)
|
||||
* @see Set#equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
|
||||
} // THashSet
|
|
@ -1,320 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.set;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
import gnu.trove.iterator.TLongIterator;
|
||||
import gnu.trove.procedure.TLongProcedure;
|
||||
import gnu.trove.TLongCollection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An implementation of the <tt>Set</tt> interface that uses an
|
||||
* open-addressed hash table to store its contents.
|
||||
*
|
||||
* Created: Sat Nov 3 10:38:17 2001
|
||||
*
|
||||
* @author Eric D. Friedman, Rob Eden, Jeff Randall
|
||||
* @version $Id: _E_Set.template,v 1.1.2.5 2009/09/15 02:38:31 upholderoftruth Exp $
|
||||
*/
|
||||
|
||||
public interface TLongSet extends TLongCollection, Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value that is used to represent null. The default
|
||||
* value is generally zero, but can be changed during construction
|
||||
* of the collection.
|
||||
*
|
||||
* @return the value that represents null
|
||||
*/
|
||||
long getNoEntryValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this set (its cardinality). If this
|
||||
* set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
|
||||
* <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return the number of elements in this set (its cardinality)
|
||||
*/
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this set contains no elements.
|
||||
*
|
||||
* @return <tt>true</tt> if this set contains no elements
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this set contains the specified element.
|
||||
*
|
||||
* @param entry an <code>long</code> value
|
||||
* @return true if the set contains the specified element.
|
||||
*/
|
||||
boolean contains( long entry );
|
||||
|
||||
|
||||
/**
|
||||
* Creates an iterator over the values of the set. The iterator
|
||||
* supports element deletion.
|
||||
*
|
||||
* @return an <code>TLongIterator</code> value
|
||||
*/
|
||||
TLongIterator iterator();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this set.
|
||||
* If this set makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the
|
||||
* elements in the same order.
|
||||
*
|
||||
* <p>The returned array will be "safe" in that no references to it
|
||||
* are maintained by this set. (In other words, this method must
|
||||
* allocate a new array even if this set is backed by an array).
|
||||
* The caller is thus free to modify the returned array.
|
||||
*
|
||||
* <p>This method acts as bridge between array-based and collection-based
|
||||
* APIs.
|
||||
*
|
||||
* @return an array containing all the elements in this set
|
||||
*/
|
||||
long[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array containing elements in this set.
|
||||
*
|
||||
* <p>If this set fits in the specified array with room to spare
|
||||
* (i.e., the array has more elements than this set), the element in
|
||||
* the array immediately following the end of the set is set to
|
||||
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
|
||||
* the length of this set <i>only</i> if the caller knows that this
|
||||
* set does not contain any elements representing null.)
|
||||
*
|
||||
* <p>If the native array is smaller than the set size,
|
||||
* the array will be filled with elements in Iterator order
|
||||
* until it is full and exclude the remainder.
|
||||
*
|
||||
* <p>If this set makes any guarantees as to what order its elements
|
||||
* are returned by its iterator, this method must return the elements
|
||||
* in the same order.
|
||||
*
|
||||
* @param dest the array into which the elements of this set are to be
|
||||
* stored.
|
||||
* @return an <tt>long[]</tt> containing all the elements in this set
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
long[] toArray( long[] dest );
|
||||
|
||||
|
||||
/**
|
||||
* Inserts a value into the set.
|
||||
*
|
||||
* @param entry a <code>long</code> value
|
||||
* @return true if the set was modified by the add operation
|
||||
*/
|
||||
boolean add( long entry );
|
||||
|
||||
|
||||
/**
|
||||
* Removes <tt>entry</tt> from the set.
|
||||
*
|
||||
* @param entry an <code>long</code> value
|
||||
* @return true if the set was modified by the remove operation.
|
||||
*/
|
||||
boolean remove( long entry );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>collection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>TLongCollection</tt> are present.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Tests the set to determine if all of the elements in
|
||||
* <tt>array</tt> are present.
|
||||
*
|
||||
* @param array as <code>array</code> of long primitives.
|
||||
* @return true if all elements were present in the set.
|
||||
*/
|
||||
boolean containsAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in <tt>collection</tt> to the set.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( Collection<? extends Long> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>TLongCollection</tt> to the set.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the <tt>array</tt> to the set.
|
||||
*
|
||||
* @param array a <code>array</code> of long primitives.
|
||||
* @return true if the set was modified by the add all operation.
|
||||
*/
|
||||
boolean addAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>collection</tt>.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>TLongCollection</tt>.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes any values in the set which are not contained in
|
||||
* <tt>array</tt>.
|
||||
*
|
||||
* @param array an <code>array</code> of long primitives.
|
||||
* @return true if the set was modified by the retain all operation
|
||||
*/
|
||||
boolean retainAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>collection</tt> from the set.
|
||||
*
|
||||
* @param collection a <code>Collection</code> value
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( Collection<?> collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>TLongCollection</tt> from the set.
|
||||
*
|
||||
* @param collection a <code>TLongCollection</code> value
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
boolean removeAll( TLongCollection collection );
|
||||
|
||||
|
||||
/**
|
||||
* Removes all of the elements in <tt>array</tt> from the set.
|
||||
*
|
||||
* @param array an <code>array</code> of long primitives.
|
||||
* @return true if the set was modified by the remove all operation.
|
||||
*/
|
||||
public boolean removeAll( long[] array );
|
||||
|
||||
|
||||
/**
|
||||
* Empties the set.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* Executes <tt>procedure</tt> for each element in the set.
|
||||
*
|
||||
* @param procedure a <code>TLongProcedure</code> value
|
||||
* @return false if the loop over the set terminated because
|
||||
* the procedure returned false for some value.
|
||||
*/
|
||||
boolean forEach( TLongProcedure procedure );
|
||||
|
||||
|
||||
// Comparison and hashing
|
||||
|
||||
/**
|
||||
* Compares the specified object with this set for equality. Returns
|
||||
* <tt>true</tt> if the specified object is also a set, the two sets
|
||||
* have the same size, and every member of the specified set is
|
||||
* contained in this set (or equivalently, every member of this set is
|
||||
* contained in the specified set). This definition ensures that the
|
||||
* equals method works properly across different implementations of the
|
||||
* set interface.
|
||||
*
|
||||
* @param o object to be compared for equality with this set
|
||||
* @return <tt>true</tt> if the specified object is equal to this set
|
||||
*/
|
||||
boolean equals( Object o );
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this set. The hash code of a set is
|
||||
* defined to be the sum of the hash codes of the elements in the set.
|
||||
* This ensures that <tt>s1.equals(s2)</tt> implies that
|
||||
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two sets <tt>s1</tt>
|
||||
* and <tt>s2</tt>, as required by the general contract of
|
||||
* {@link Object#hashCode}.
|
||||
*
|
||||
* @return the hash code value for this set
|
||||
* @see Object#equals(Object)
|
||||
* @see Set#equals(Object)
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
|
||||
} // THashSet
|
|
@ -1,551 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.set.hash;
|
||||
|
||||
import gnu.trove.set.TIntSet;
|
||||
import gnu.trove.iterator.TIntIterator;
|
||||
import gnu.trove.impl.*;
|
||||
import gnu.trove.impl.hash.*;
|
||||
import gnu.trove.TIntCollection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Externalizable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* An open addressed set implementation for int primitives.
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden
|
||||
* @author Jeff Randall
|
||||
*/
|
||||
|
||||
public class TIntHashSet extends TIntHash implements TIntSet, Externalizable {
|
||||
static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHashSet</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public TIntHashSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHashSet</code> instance with a prime
|
||||
* capacity equal to or greater than <tt>initialCapacity</tt> and
|
||||
* with the default load factor.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public TIntHashSet( int initialCapacity ) {
|
||||
super( initialCapacity );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param load_factor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
*/
|
||||
public TIntHashSet( int initialCapacity, float load_factor ) {
|
||||
super( initialCapacity, load_factor );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHashSet</code> instance with a prime
|
||||
* capacity equal to or greater than <tt>initial_capacity</tt> and
|
||||
* with the specified load factor.
|
||||
*
|
||||
* @param initial_capacity an <code>int</code> value
|
||||
* @param load_factor a <code>float</code> value
|
||||
* @param no_entry_value a <code>int</code> value that represents null.
|
||||
*/
|
||||
public TIntHashSet( int initial_capacity, float load_factor,
|
||||
int no_entry_value ) {
|
||||
super( initial_capacity, load_factor, no_entry_value );
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHashSet</code> instance that is a copy
|
||||
* of the existing Collection.
|
||||
*
|
||||
* @param collection a <tt>Collection</tt> that will be duplicated.
|
||||
*/
|
||||
public TIntHashSet( Collection<? extends Integer> collection ) {
|
||||
this( Math.max( collection.size(), DEFAULT_CAPACITY ) );
|
||||
addAll( collection );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHashSet</code> instance that is a copy
|
||||
* of the existing set.
|
||||
*
|
||||
* @param collection a <tt>TIntSet</tt> that will be duplicated.
|
||||
*/
|
||||
public TIntHashSet( TIntCollection collection ) {
|
||||
this( Math.max( collection.size(), DEFAULT_CAPACITY ) );
|
||||
if ( collection instanceof TIntHashSet ) {
|
||||
TIntHashSet hashset = ( TIntHashSet ) collection;
|
||||
this._loadFactor = hashset._loadFactor;
|
||||
this.no_entry_value = hashset.no_entry_value;
|
||||
//noinspection RedundantCast
|
||||
if ( this.no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, this.no_entry_value );
|
||||
}
|
||||
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
|
||||
}
|
||||
addAll( collection );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHashSet</code> instance containing the
|
||||
* elements of <tt>array</tt>.
|
||||
*
|
||||
* @param array an array of <code>int</code> primitives
|
||||
*/
|
||||
public TIntHashSet( int[] array ) {
|
||||
this( Math.max( array.length, DEFAULT_CAPACITY ) );
|
||||
addAll( array );
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public TIntIterator iterator() {
|
||||
return new TIntHashIterator( this );
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int[] toArray() {
|
||||
int[] result = new int[ size() ];
|
||||
int[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = states.length, j = 0; i-- > 0; ) {
|
||||
if ( states[i] == FULL ) {
|
||||
result[j++] = set[i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int[] toArray( int[] dest ) {
|
||||
int[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = states.length, j = 0; i-- > 0; ) {
|
||||
if ( states[i] == FULL ) {
|
||||
dest[j++] = set[i];
|
||||
}
|
||||
}
|
||||
|
||||
if ( dest.length > _size ) {
|
||||
dest[_size] = no_entry_value;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean add( int val ) {
|
||||
int index = insertionIndex(val);
|
||||
|
||||
if ( index < 0 ) {
|
||||
return false; // already present in set, nothing to add
|
||||
}
|
||||
|
||||
byte previousState = _states[index];
|
||||
_set[index] = val;
|
||||
_states[index] = FULL;
|
||||
postInsertHook( previousState == FREE );
|
||||
|
||||
return true; // yes, we added something
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean remove( int val ) {
|
||||
int index = index(val);
|
||||
if ( index >= 0 ) {
|
||||
removeAt( index );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean containsAll( Collection<?> collection ) {
|
||||
for ( Object element : collection ) {
|
||||
if ( element instanceof Integer ) {
|
||||
int c = ( ( Integer ) element ).intValue();
|
||||
if ( ! contains( c ) ) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean containsAll( TIntCollection collection ) {
|
||||
TIntIterator iter = collection.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
int element = iter.next();
|
||||
if ( ! contains( element ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean containsAll( int[] array ) {
|
||||
for ( int i = array.length; i-- > 0; ) {
|
||||
if ( ! contains( array[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addAll( Collection<? extends Integer> collection ) {
|
||||
boolean changed = false;
|
||||
for ( Integer element : collection ) {
|
||||
int e = element.intValue();
|
||||
if ( add( e ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addAll( TIntCollection collection ) {
|
||||
boolean changed = false;
|
||||
TIntIterator iter = collection.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
int element = iter.next();
|
||||
if ( add( element ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addAll( int[] array ) {
|
||||
boolean changed = false;
|
||||
for ( int i = array.length; i-- > 0; ) {
|
||||
if ( add( array[i] ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings({"SuspiciousMethodCalls"})
|
||||
public boolean retainAll( Collection<?> collection ) {
|
||||
boolean modified = false;
|
||||
TIntIterator iter = iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
if ( ! collection.contains( Integer.valueOf ( iter.next() ) ) ) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean retainAll( TIntCollection collection ) {
|
||||
if ( this == collection ) {
|
||||
return false;
|
||||
}
|
||||
boolean modified = false;
|
||||
TIntIterator iter = iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
if ( ! collection.contains( iter.next() ) ) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean retainAll( int[] array ) {
|
||||
boolean changed = false;
|
||||
Arrays.sort( array );
|
||||
int[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) {
|
||||
removeAt( i );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean removeAll( Collection<?> collection ) {
|
||||
boolean changed = false;
|
||||
for ( Object element : collection ) {
|
||||
if ( element instanceof Integer ) {
|
||||
int c = ( ( Integer ) element ).intValue();
|
||||
if ( remove( c ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean removeAll( TIntCollection collection ) {
|
||||
boolean changed = false;
|
||||
TIntIterator iter = collection.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
int element = iter.next();
|
||||
if ( remove( element ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean removeAll( int[] array ) {
|
||||
boolean changed = false;
|
||||
for ( int i = array.length; i-- > 0; ) {
|
||||
if ( remove(array[i]) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void clear() {
|
||||
super.clear();
|
||||
int[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
set[i] = no_entry_value;
|
||||
states[i] = FREE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected void rehash( int newCapacity ) {
|
||||
int oldCapacity = _set.length;
|
||||
|
||||
int oldSet[] = _set;
|
||||
byte oldStates[] = _states;
|
||||
|
||||
_set = new int[newCapacity];
|
||||
_states = new byte[newCapacity];
|
||||
|
||||
for ( int i = oldCapacity; i-- > 0; ) {
|
||||
if( oldStates[i] == FULL ) {
|
||||
int o = oldSet[i];
|
||||
int index = insertionIndex(o);
|
||||
_set[index] = o;
|
||||
_states[index] = FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean equals( Object other ) {
|
||||
if ( ! ( other instanceof TIntSet ) ) {
|
||||
return false;
|
||||
}
|
||||
TIntSet that = ( TIntSet ) other;
|
||||
if ( that.size() != this.size() ) {
|
||||
return false;
|
||||
}
|
||||
for ( int i = _states.length; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
if ( ! that.contains( _set[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int hashCode() {
|
||||
int hashcode = 0;
|
||||
for ( int i = _states.length; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
hashcode += HashFunctions.hash( _set[i] );
|
||||
}
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String toString() {
|
||||
StringBuilder buffy = new StringBuilder( _size * 2 + 2 );
|
||||
buffy.append("{");
|
||||
for ( int i = _states.length, j = 1; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
buffy.append( _set[i] );
|
||||
if ( j++ < _size ) {
|
||||
buffy.append( "," );
|
||||
}
|
||||
}
|
||||
}
|
||||
buffy.append("}");
|
||||
return buffy.toString();
|
||||
}
|
||||
|
||||
|
||||
class TIntHashIterator extends THashPrimitiveIterator implements TIntIterator {
|
||||
|
||||
/** the collection on which the iterator operates */
|
||||
private final TIntHash _hash;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public TIntHashIterator( TIntHash hash ) {
|
||||
super( hash );
|
||||
this._hash = hash;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int next() {
|
||||
moveToNextIndex();
|
||||
return _hash._set[_index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void writeExternal( ObjectOutput out ) throws IOException {
|
||||
|
||||
// VERSION
|
||||
out.writeByte( 1 );
|
||||
|
||||
// SUPER
|
||||
super.writeExternal( out );
|
||||
|
||||
// NUMBER OF ENTRIES
|
||||
out.writeInt( _size );
|
||||
|
||||
// LOAD FACTOR -- Added version 1
|
||||
out.writeFloat( _loadFactor );
|
||||
|
||||
// NO ENTRY VALUE -- Added version 1
|
||||
out.writeInt( no_entry_value );
|
||||
|
||||
// ENTRIES
|
||||
for ( int i = _states.length; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
out.writeInt( _set[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void readExternal( ObjectInput in )
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
// VERSION
|
||||
int version = in.readByte();
|
||||
|
||||
// SUPER
|
||||
super.readExternal( in );
|
||||
|
||||
// NUMBER OF ENTRIES
|
||||
int size = in.readInt();
|
||||
|
||||
if ( version >= 1 ) {
|
||||
// LOAD FACTOR
|
||||
_loadFactor = in.readFloat();
|
||||
|
||||
// NO ENTRY VALUE
|
||||
no_entry_value = in.readInt();
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( int ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
// ENTRIES
|
||||
setUp( size );
|
||||
while ( size-- > 0 ) {
|
||||
int val = in.readInt();
|
||||
add( val );
|
||||
}
|
||||
}
|
||||
} // TIntHashSet
|
|
@ -1,551 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
|
||||
// Copyright (c) 2009, Rob Eden All Rights Reserved.
|
||||
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package gnu.trove.set.hash;
|
||||
|
||||
import gnu.trove.set.TLongSet;
|
||||
import gnu.trove.iterator.TLongIterator;
|
||||
import gnu.trove.impl.*;
|
||||
import gnu.trove.impl.hash.*;
|
||||
import gnu.trove.TLongCollection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Externalizable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* An open addressed set implementation for long primitives.
|
||||
*
|
||||
* @author Eric D. Friedman
|
||||
* @author Rob Eden
|
||||
* @author Jeff Randall
|
||||
*/
|
||||
|
||||
public class TLongHashSet extends TLongHash implements TLongSet, Externalizable {
|
||||
static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHashSet</code> instance with the default
|
||||
* capacity and load factor.
|
||||
*/
|
||||
public TLongHashSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHashSet</code> instance with a prime
|
||||
* capacity equal to or greater than <tt>initialCapacity</tt> and
|
||||
* with the default load factor.
|
||||
*
|
||||
* @param initialCapacity an <code>int</code> value
|
||||
*/
|
||||
public TLongHashSet( int initialCapacity ) {
|
||||
super( initialCapacity );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TIntHash</code> instance with a prime
|
||||
* value at or near the specified capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity used to find a prime capacity for the table.
|
||||
* @param load_factor used to calculate the threshold over which
|
||||
* rehashing takes place.
|
||||
*/
|
||||
public TLongHashSet( int initialCapacity, float load_factor ) {
|
||||
super( initialCapacity, load_factor );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHashSet</code> instance with a prime
|
||||
* capacity equal to or greater than <tt>initial_capacity</tt> and
|
||||
* with the specified load factor.
|
||||
*
|
||||
* @param initial_capacity an <code>int</code> value
|
||||
* @param load_factor a <code>float</code> value
|
||||
* @param no_entry_value a <code>long</code> value that represents null.
|
||||
*/
|
||||
public TLongHashSet( int initial_capacity, float load_factor,
|
||||
long no_entry_value ) {
|
||||
super( initial_capacity, load_factor, no_entry_value );
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHashSet</code> instance that is a copy
|
||||
* of the existing Collection.
|
||||
*
|
||||
* @param collection a <tt>Collection</tt> that will be duplicated.
|
||||
*/
|
||||
public TLongHashSet( Collection<? extends Long> collection ) {
|
||||
this( Math.max( collection.size(), DEFAULT_CAPACITY ) );
|
||||
addAll( collection );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHashSet</code> instance that is a copy
|
||||
* of the existing set.
|
||||
*
|
||||
* @param collection a <tt>TLongSet</tt> that will be duplicated.
|
||||
*/
|
||||
public TLongHashSet( TLongCollection collection ) {
|
||||
this( Math.max( collection.size(), DEFAULT_CAPACITY ) );
|
||||
if ( collection instanceof TLongHashSet ) {
|
||||
TLongHashSet hashset = ( TLongHashSet ) collection;
|
||||
this._loadFactor = hashset._loadFactor;
|
||||
this.no_entry_value = hashset.no_entry_value;
|
||||
//noinspection RedundantCast
|
||||
if ( this.no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, this.no_entry_value );
|
||||
}
|
||||
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
|
||||
}
|
||||
addAll( collection );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new <code>TLongHashSet</code> instance containing the
|
||||
* elements of <tt>array</tt>.
|
||||
*
|
||||
* @param array an array of <code>long</code> primitives
|
||||
*/
|
||||
public TLongHashSet( long[] array ) {
|
||||
this( Math.max( array.length, DEFAULT_CAPACITY ) );
|
||||
addAll( array );
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public TLongIterator iterator() {
|
||||
return new TLongHashIterator( this );
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public long[] toArray() {
|
||||
long[] result = new long[ size() ];
|
||||
long[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = states.length, j = 0; i-- > 0; ) {
|
||||
if ( states[i] == FULL ) {
|
||||
result[j++] = set[i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public long[] toArray( long[] dest ) {
|
||||
long[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = states.length, j = 0; i-- > 0; ) {
|
||||
if ( states[i] == FULL ) {
|
||||
dest[j++] = set[i];
|
||||
}
|
||||
}
|
||||
|
||||
if ( dest.length > _size ) {
|
||||
dest[_size] = no_entry_value;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean add( long val ) {
|
||||
int index = insertionIndex(val);
|
||||
|
||||
if ( index < 0 ) {
|
||||
return false; // already present in set, nothing to add
|
||||
}
|
||||
|
||||
byte previousState = _states[index];
|
||||
_set[index] = val;
|
||||
_states[index] = FULL;
|
||||
postInsertHook( previousState == FREE );
|
||||
|
||||
return true; // yes, we added something
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean remove( long val ) {
|
||||
int index = index(val);
|
||||
if ( index >= 0 ) {
|
||||
removeAt( index );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean containsAll( Collection<?> collection ) {
|
||||
for ( Object element : collection ) {
|
||||
if ( element instanceof Long ) {
|
||||
long c = ( ( Long ) element ).longValue();
|
||||
if ( ! contains( c ) ) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean containsAll( TLongCollection collection ) {
|
||||
TLongIterator iter = collection.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
long element = iter.next();
|
||||
if ( ! contains( element ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean containsAll( long[] array ) {
|
||||
for ( int i = array.length; i-- > 0; ) {
|
||||
if ( ! contains( array[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addAll( Collection<? extends Long> collection ) {
|
||||
boolean changed = false;
|
||||
for ( Long element : collection ) {
|
||||
long e = element.longValue();
|
||||
if ( add( e ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addAll( TLongCollection collection ) {
|
||||
boolean changed = false;
|
||||
TLongIterator iter = collection.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
long element = iter.next();
|
||||
if ( add( element ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addAll( long[] array ) {
|
||||
boolean changed = false;
|
||||
for ( int i = array.length; i-- > 0; ) {
|
||||
if ( add( array[i] ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings({"SuspiciousMethodCalls"})
|
||||
public boolean retainAll( Collection<?> collection ) {
|
||||
boolean modified = false;
|
||||
TLongIterator iter = iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
if ( ! collection.contains( Long.valueOf ( iter.next() ) ) ) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean retainAll( TLongCollection collection ) {
|
||||
if ( this == collection ) {
|
||||
return false;
|
||||
}
|
||||
boolean modified = false;
|
||||
TLongIterator iter = iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
if ( ! collection.contains( iter.next() ) ) {
|
||||
iter.remove();
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean retainAll( long[] array ) {
|
||||
boolean changed = false;
|
||||
Arrays.sort( array );
|
||||
long[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) {
|
||||
removeAt( i );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean removeAll( Collection<?> collection ) {
|
||||
boolean changed = false;
|
||||
for ( Object element : collection ) {
|
||||
if ( element instanceof Long ) {
|
||||
long c = ( ( Long ) element ).longValue();
|
||||
if ( remove( c ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean removeAll( TLongCollection collection ) {
|
||||
boolean changed = false;
|
||||
TLongIterator iter = collection.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
long element = iter.next();
|
||||
if ( remove( element ) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean removeAll( long[] array ) {
|
||||
boolean changed = false;
|
||||
for ( int i = array.length; i-- > 0; ) {
|
||||
if ( remove(array[i]) ) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void clear() {
|
||||
super.clear();
|
||||
long[] set = _set;
|
||||
byte[] states = _states;
|
||||
|
||||
for ( int i = set.length; i-- > 0; ) {
|
||||
set[i] = no_entry_value;
|
||||
states[i] = FREE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected void rehash( int newCapacity ) {
|
||||
int oldCapacity = _set.length;
|
||||
|
||||
long oldSet[] = _set;
|
||||
byte oldStates[] = _states;
|
||||
|
||||
_set = new long[newCapacity];
|
||||
_states = new byte[newCapacity];
|
||||
|
||||
for ( int i = oldCapacity; i-- > 0; ) {
|
||||
if( oldStates[i] == FULL ) {
|
||||
long o = oldSet[i];
|
||||
int index = insertionIndex(o);
|
||||
_set[index] = o;
|
||||
_states[index] = FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean equals( Object other ) {
|
||||
if ( ! ( other instanceof TLongSet ) ) {
|
||||
return false;
|
||||
}
|
||||
TLongSet that = ( TLongSet ) other;
|
||||
if ( that.size() != this.size() ) {
|
||||
return false;
|
||||
}
|
||||
for ( int i = _states.length; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
if ( ! that.contains( _set[i] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int hashCode() {
|
||||
int hashcode = 0;
|
||||
for ( int i = _states.length; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
hashcode += HashFunctions.hash( _set[i] );
|
||||
}
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String toString() {
|
||||
StringBuilder buffy = new StringBuilder( _size * 2 + 2 );
|
||||
buffy.append("{");
|
||||
for ( int i = _states.length, j = 1; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
buffy.append( _set[i] );
|
||||
if ( j++ < _size ) {
|
||||
buffy.append( "," );
|
||||
}
|
||||
}
|
||||
}
|
||||
buffy.append("}");
|
||||
return buffy.toString();
|
||||
}
|
||||
|
||||
|
||||
class TLongHashIterator extends THashPrimitiveIterator implements TLongIterator {
|
||||
|
||||
/** the collection on which the iterator operates */
|
||||
private final TLongHash _hash;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public TLongHashIterator( TLongHash hash ) {
|
||||
super( hash );
|
||||
this._hash = hash;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public long next() {
|
||||
moveToNextIndex();
|
||||
return _hash._set[_index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void writeExternal( ObjectOutput out ) throws IOException {
|
||||
|
||||
// VERSION
|
||||
out.writeByte( 1 );
|
||||
|
||||
// SUPER
|
||||
super.writeExternal( out );
|
||||
|
||||
// NUMBER OF ENTRIES
|
||||
out.writeInt( _size );
|
||||
|
||||
// LOAD FACTOR -- Added version 1
|
||||
out.writeFloat( _loadFactor );
|
||||
|
||||
// NO ENTRY VALUE -- Added version 1
|
||||
out.writeLong( no_entry_value );
|
||||
|
||||
// ENTRIES
|
||||
for ( int i = _states.length; i-- > 0; ) {
|
||||
if ( _states[i] == FULL ) {
|
||||
out.writeLong( _set[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void readExternal( ObjectInput in )
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
// VERSION
|
||||
int version = in.readByte();
|
||||
|
||||
// SUPER
|
||||
super.readExternal( in );
|
||||
|
||||
// NUMBER OF ENTRIES
|
||||
int size = in.readInt();
|
||||
|
||||
if ( version >= 1 ) {
|
||||
// LOAD FACTOR
|
||||
_loadFactor = in.readFloat();
|
||||
|
||||
// NO ENTRY VALUE
|
||||
no_entry_value = in.readLong();
|
||||
//noinspection RedundantCast
|
||||
if ( no_entry_value != ( long ) 0 ) {
|
||||
Arrays.fill( _set, no_entry_value );
|
||||
}
|
||||
}
|
||||
|
||||
// ENTRIES
|
||||
setUp( size );
|
||||
while ( size-- > 0 ) {
|
||||
long val = in.readLong();
|
||||
add( val );
|
||||
}
|
||||
}
|
||||
} // TIntHashSet
|
Loading…
Reference in a new issue