You can subscribe to this list here.
2002 |
Jan
(14) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(3) |
Aug
(6) |
Sep
(14) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(1) |
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(2) |
Sep
(3) |
Oct
|
Nov
(7) |
Dec
(3) |
2004 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
2005 |
Jan
|
Feb
|
Mar
(11) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(7) |
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(29) |
Dec
(16) |
2007 |
Jan
(11) |
Feb
(6) |
Mar
(12) |
Apr
(2) |
May
|
Jun
(16) |
Jul
(9) |
Aug
(5) |
Sep
|
Oct
(4) |
Nov
(8) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(23) |
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(11) |
Nov
(2) |
Dec
(3) |
2009 |
Jan
|
Feb
(2) |
Mar
(15) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(65) |
Sep
(180) |
Oct
(52) |
Nov
(33) |
Dec
|
2010 |
Jan
(5) |
Feb
(3) |
Mar
(24) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(49) |
Oct
|
Nov
|
Dec
|
From: Jeff R. <uph...@us...> - 2009-09-02 21:52:43
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14856/test/gnu/trove/set/hash Added Files: Tag: TROVE_3_WORKING TPrimitiveHashSetTest.java THashSetTest.java Log Message: Implementation of HashSets, Add tests, changes as needed to allow those changes. --- NEW FILE: TPrimitiveHashSetTest.java --- package gnu.trove.set.hash; import junit.framework.TestCase; import java.util.*; import gnu.trove.set.TIntSet; import gnu.trove.iterator.TIntIterator; /** Test the primitive HashSet classes. */ public class TPrimitiveHashSetTest extends TestCase { public TPrimitiveHashSetTest( String name ) { super( name ); } public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testIsEmpty() throws Exception { TIntSet s = new TIntHashSet(); assertTrue( "new set wasn't empty", s.isEmpty() ); s.add( 1 ); assertTrue( "set with element reports empty", !s.isEmpty() ); s.clear(); assertTrue( "cleared set reports not-empty", s.isEmpty() ); } public void testContains() throws Exception { TIntSet s = new TIntHashSet(); int i = 100; s.add( i ); assertTrue( "contains failed", s.contains( i ) ); } public void testContainsAll() throws Exception { int[] ints = {1138, 42, 13, 86, 99}; TIntSet set = new TIntHashSet(); set.addAll( ints ); TIntSet other = new TIntHashSet(); other.addAll( ints ); List<Integer> ints_list = new ArrayList<Integer>(); for ( int element : ints ) { ints_list.add( element ); } for ( int index = 0; index < ints.length; index++ ) { assertTrue( Integer.valueOf( ints[index] ).toString(), set.contains( ints[index] ) ); } assertTrue( "containsAll(Collection<?>) failed: " + set, set.containsAll( ints_list ) ); assertTrue( "containsAll(TIntSet) failed (same set): " + set, set.containsAll( set ) ); assertTrue( "containsAll(TIntSet) failed (other set): " + set, set.containsAll( other ) ); assertTrue( "containsAll(int[]) failed: " + set, set.containsAll( ints ) ); } public void testRetainAll() throws Exception { int[] ints = {1138, 42, 13, 86, 99, 101, }; TIntSet set = new TIntHashSet(); set.addAll( ints ); TIntSet other = new TIntHashSet(); other.addAll( ints ); List<Integer> ints_list = new ArrayList<Integer>(); for ( int element : ints ) { ints_list.add( element ); } for ( int index = 0; index < ints.length; index++ ) { assertTrue( Integer.valueOf( ints[index] ).toString(), set.contains( ints[index] ) ); } assertTrue( "containsAll(Collection<?>) failed: " + set, set.containsAll( ints_list ) ); assertTrue( "containsAll(TIntSet) failed (same set): " + set, set.containsAll( set ) ); assertTrue( "containsAll(TIntSet) failed (other set): " + set, set.containsAll( other ) ); assertTrue( "containsAll(int[]) failed: " + set, set.containsAll( ints ) ); } public void testAdd() throws Exception { TIntSet set = new TIntHashSet(); assertTrue( "add failed", set.add( 1 ) ); assertFalse( "duplicated add modified set", set.add( 1 ) ); } public void testRemove() throws Exception { TIntSet set = new TIntHashSet(); set.add( 1 ); set.add( 2 ); assertTrue( "One was not added", set.contains( 1 ) ); assertTrue( "One was not removed", set.remove( 1 ) ); assertFalse( "One was not removed", set.contains( 1 ) ); } public void testSize() throws Exception { TIntSet set = new TIntHashSet(); assertEquals( "initial size was not 0", 0, set.size() ); for ( int i = 0; i < 99; i++ ) { set.add( i ); assertEquals( "size did not increase after add", i + 1, set.size() ); } } public void testClear() throws Exception { TIntSet set = new TIntHashSet(); set.addAll( new int[]{1, 2, 3} ); assertEquals( "size was not 3", 3, set.size() ); set.clear(); assertEquals( "initial size was not 0", 0, set.size() ); } // TODO: implement after serialzation is implemented public void testSerialize() throws Exception { // Set<String> s = new THashSet<String>(); // s.addAll( Arrays.asList( new String[]{"one", "two", "three"} ) ); // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // ObjectOutputStream oos = new ObjectOutputStream( baos ); // oos.writeObject( s ); // // ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() ); // ObjectInputStream ois = new ObjectInputStream( bais ); // // THashSet s2 = (THashSet) ois.readObject(); // // assertEquals( s, s2 ); } public void testToArray() { TIntSet set = new TIntHashSet(); int[] ints = {42, 1138, 13, 86, 99}; set.addAll( ints ); int[] res = set.toArray(); Arrays.sort( ints ); Arrays.sort( res ); assertTrue( Arrays.equals( ints, res ) ); } public void testToArrayWithParams() { TIntSet set = new TIntHashSet(); int[] ints = {42, 1138, 13, 86, 99}; set.addAll( ints ); int[] sink = new int[ints.length + 2]; sink[sink.length - 1] = -1; sink[sink.length - 2] = -2; int[] res = set.toArray( sink ); assertEquals( set.getNoEntryValue(), res[set.size()] ); Set<Integer> copy = new HashSet<Integer>(); for ( int element : sink ) { copy.add( Integer.valueOf( element ) ); } Set<Integer> bogey = new HashSet<Integer>(); for ( int element : ints ) { bogey.add( Integer.valueOf( element ) ); } bogey.add( -1 ); bogey.add( 0 ); assertEquals( bogey, copy ); } public void testRehashing() throws Exception { Set<Integer> s = new THashSet<Integer>( 10 ); for ( int i = 0; i < 10000; i++ ) { s.add( new Integer( i ) ); } } public void testIterator() { TIntSet set = new TIntHashSet(); set.add( 1 ); set.add( 2 ); TIntIterator iter = set.iterator(); while ( iter.hasNext() ) { int next = iter.next(); assertTrue( next == 1 || next == 2 ); } } } --- NEW FILE: THashSetTest.java --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001-2006, 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 junit.framework.TestCase; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Arrays; import java.util.HashSet; import java.util.Set; /** * Created: Sat Nov 3 10:33:15 2001 * * @author Eric D. Friedman, Rob Eden, Jeff Randall * @version $Id: THashSetTest.java,v 1.1.2.1 2009/09/02 21:52:33 upholderoftruth Exp $ */ public class THashSetTest extends TestCase { public THashSetTest( String name ) { super( name ); } public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testIsEmpty() throws Exception { Set<String> s = new THashSet<String>(); assertTrue( "new set wasn't empty", s.isEmpty() ); s.add( "One" ); assertTrue( "set with element reports empty", !s.isEmpty() ); s.clear(); assertTrue( "cleared set reports not-empty", s.isEmpty() ); } public void testContains() throws Exception { Set<String> s = new THashSet<String>(); String o = "testContains"; s.add( o ); assertTrue( "contains failed", s.contains( o ) ); } public void testContainsAll() throws Exception { Set<String> s = new THashSet<String>(); String[] o = {"Hello World", "Goodbye World", "Hello Goodbye"}; s.addAll( Arrays.asList( o ) ); for ( int i = 0; i < o.length; i++ ) { assertTrue( o[i], s.contains( o[i] ) ); } assertTrue( "containsAll failed: " + s, s.containsAll( Arrays.asList( o ) ) ); } public void testAdd() throws Exception { Set<String> s = new THashSet<String>(); assertTrue( "add failed", s.add( "One" ) ); assertTrue( "duplicated add succeded", !s.add( "One" ) ); } public void testRemove() throws Exception { Set<String> s = new THashSet<String>(); s.add( "One" ); s.add( "Two" ); assertTrue( "One was not added", s.contains( "One" ) ); assertTrue( "One was not removed", s.remove( "One" ) ); assertTrue( "One was not removed", !s.contains( "One" ) ); } public void testSize() throws Exception { Set<Object> o = new THashSet<Object>(); assertEquals( "initial size was not 0", 0, o.size() ); for ( int i = 0; i < 99; i++ ) { o.add( new Object() ); assertEquals( "size did not increase after add", i + 1, o.size() ); } } public void testClear() throws Exception { Set<String> s = new THashSet<String>(); s.addAll( Arrays.asList( new String[]{"one", "two", "three"} ) ); assertEquals( "size was not 3", 3, s.size() ); s.clear(); assertEquals( "initial size was not 0", 0, s.size() ); } // TODO: implement after serialzation is implemented public void testSerialize() throws Exception { // Set<String> s = new THashSet<String>(); // s.addAll( Arrays.asList( new String[]{"one", "two", "three"} ) ); // ByteArrayOutputStream baos = new ByteArrayOutputStream(); // ObjectOutputStream oos = new ObjectOutputStream( baos ); // oos.writeObject( s ); // // ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() ); // ObjectInputStream ois = new ObjectInputStream( bais ); // // THashSet s2 = (THashSet) ois.readObject(); // // assertEquals( s, s2 ); } public void testToArray() { Set<String> s = new THashSet<String>(); String[] str = {"hi", "bye", "hello", "goodbye"}; s.addAll( Arrays.asList( str ) ); Object[] res = s.toArray(); Arrays.sort( str ); Arrays.sort( res ); assertTrue( Arrays.equals( str, res ) ); } public void testToArrayWithParams() { Set<String> s = new THashSet<String>(); String[] str = {"hi", "bye", "hello", "goodbye"}; s.addAll( Arrays.asList( str ) ); String[] sink = new String[str.length + 2]; sink[sink.length - 1] = "residue"; sink[sink.length - 2] = "will be cleared"; Object[] res = s.toArray( sink ); Set copy = new HashSet(); copy.addAll( Arrays.asList( res ) ); Set bogey = new HashSet(); bogey.addAll( Arrays.asList( str ) ); bogey.add( "residue" ); bogey.add( null ); assertEquals( bogey, copy ); } public void testRehashing() throws Exception { Set<Integer> s = new THashSet<Integer>(); for ( int i = 0; i < 10000; i++ ) { s.add( new Integer( i ) ); } } /** * this tests that we throw when people violate the * general contract for hashcode on java.lang.Object */ public void testSomeBadlyWrittenObject() { Set<Object> s = new THashSet<Object>(); boolean didThrow = false; int i = 0; try { for (; i < 101; i++ ) { s.add( new Crap() ); } } catch ( IllegalArgumentException e ) { didThrow = true; } assertTrue( "expected THashSet to throw an IllegalArgumentException", didThrow ); } public void testIterable() { Set<String> set = new THashSet<String>(); set.add( "One" ); set.add( "Two" ); for ( String s : set ) { assertTrue( s.equals( "One" ) || s.equals( "Two" ) ); } } public void testToString() { Set<String> set = new THashSet<String>(); set.add( "One" ); set.add( "Two" ); String to_string = set.toString(); assertTrue( to_string, to_string.equals( "{One,Two}" ) || to_string.equals( "{Two,One}" ) ); } // in this junk class, all instances hash to the same // address, but some objects claim to be equal where // others do not. public static class Crap { public boolean equals( Object other ) { return other instanceof Crap; } public int hashCode() { return System.identityHashCode( this ); } } public static void main( String[] args ) throws Exception { junit.textui.TestRunner.run( new THashSetTest( "testBadlyWrittenObject" ) ); } } // THashSetTests |
From: Jeff R. <uph...@us...> - 2009-09-02 21:52:43
|
Update of /cvsroot/trove4j/trove/test/gnu/trove In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14856/test/gnu/trove Added Files: Tag: TROVE_3_WORKING TArrayListTest.java PrimeFinderTest.java TStackTest.java Log Message: Implementation of HashSets, Add tests, changes as needed to allow those changes. |
From: Jeff R. <uph...@us...> - 2009-09-02 21:52:43
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14856/test/gnu/trove/impl/hash Added Files: Tag: TROVE_3_WORKING THashTest.java Log Message: Implementation of HashSets, Add tests, changes as needed to allow those changes. --- NEW FILE: THashTest.java --- package gnu.trove.impl.hash; import junit.framework.TestCase; import gnu.trove.set.hash.THashSet; /** * Created by IntelliJ IDEA. * User: randall * Date: Sep 2, 2009 * Time: 2:52:23 PM * To change this template use File | Settings | File Templates. */ public class THashTest extends TestCase { public THashTest( String name ) { super( name ); } public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testNormalLoad() throws Exception { THashSet set = new THashSet( 11, 0.5f ); assertEquals( set._maxSize, 11 ); for ( int i = 0; i < 12; i++ ) { set.add( new Integer( i ) ); } assertTrue( set._maxSize > 12 ); } public void testMaxLoad() throws Exception { THashSet set = new THashSet( 11, 1.0f ); assertEquals( 10, set._maxSize ); for ( int i = 0; i < 12; i++ ) { set.add( new Integer( i ) ); } assertTrue( set._maxSize > 12 ); } public void testReusesRemovedSlotsOnCollision() { THashSet<Object> set = new THashSet<Object>( 11, 0.5f ); class Foo { public int hashCode() { return 4; } } Foo f1 = new Foo(); Foo f2 = new Foo(); Foo f3 = new Foo(); set.add( f1 ); int idx = set.insertionIndex( f2 ); set.add( f2 ); assertEquals( f2, set._set[idx] ); set.remove( f2 ); assertEquals( set.REMOVED, set._set[idx] ); assertEquals( idx, set.insertionIndex( f3 ) ); set.add( f3 ); assertEquals( f3, set._set[idx] ); } } |
From: Jeff R. <uph...@us...> - 2009-09-02 21:52:42
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14856/templates/gnu/trove/set/hash Added Files: Tag: TROVE_3_WORKING _E_HashSet.template Log Message: Implementation of HashSets, Add tests, changes as needed to allow those changes. --- NEW FILE: _E_HashSet.template --- /////////////////////////////////////////////////////////////////////////////// // 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.T#E#Set; import gnu.trove.iterator.T#E#Iterator; import gnu.trove.iterator.array.T#E#ArrayIterator; import gnu.trove.procedure.T#E#Procedure; import gnu.trove.impl.*; import gnu.trove.impl.hash.T#E#Hash; 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 #e# primitives. * * @author Eric D. Friedman * @author Rob Eden * @author Jeff Randall */ public class T#E#HashSet extends T#E#Hash implements T#E#Set, Externalizable { static final long serialVersionUID = 1L; /** * Creates a new <code>T#E#HashSet</code> instance with the default * capacity and load factor. */ public T#E#HashSet() { super(); } /** * Creates a new <code>T#E#HashSet</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 T#E#HashSet( int initialCapacity ) { super( initialCapacity ); } /** * Creates a new <code>T#E#HashSet</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>#e#</code> value that represents null. */ public T#E#HashSet( int initial_capacity, float load_factor, #e# no_entry_value ) { super( initial_capacity, load_factor, no_entry_value ); if ( no_entry_value != ( #e# ) 0 ) { Arrays.fill( _set, no_entry_value ); } } /** * Creates a new <code>T#E#HashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>#e#</code> primitives */ public T#E#HashSet( #e#[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); } /** * Creates a new <code>T#E#HashSet</code> instance with the default * capacity and load factor. * * @param set a <tt>T#E#HashSet</tt> that will be duplicated. */ public T#E#HashSet( T#E#HashSet set ) { this( Math.max( set.size(), DEFAULT_CAPACITY ), set._loadFactor, set.no_entry_value ); addAll( set ); } /** * @return a T#E#Iterator with access to the values in this set */ public T#E#Iterator iterator() { return new T#E#ArrayIterator(this); } /** * Returns a new array containing the values in the set. * * @return an <code>#e#[]</code> value */ public #e#[] toArray() { #e#[] result = new #e#[ size() ]; #e#[] set = _set; byte[] states = _states; for ( int i = states.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { result[j++] = set[i]; } } return result; } /** * 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>#e#[]</tt> containing all the elements in this set * @throws NullPointerException if the specified array is null */ public #e#[] toArray( #e#[] dest ) { #e#[] 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; } /** * Inserts a value into the set. * * @param val an <code>#e#</code> value * @return true if the set was modified by the add operation */ public boolean add( #e# 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 } /** * Removes <tt>val</tt> from the set. * * @param val an <code>#e#</code> value * @return true if the set was modified by the remove operation. */ public boolean remove( #e# val ) { int index = index(val); if ( index >= 0 ) { removeAt( index ); return true; } return false; } /** * Tests the set to determine if all of the elements in * <tt>collection</tt> are present. * * @param collection a <code>Collection</code> of Objects. * @return true if all elements were Characters and present in the set. */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( element instanceof #ET# ) { #e# c = ( ( #ET# ) element ).#e#Value(); if ( ! contains( c ) ) { return false; } } else { return false; } } return true; } /** * Tests the set to determine if all of the elements in * <tt>T#E#Set</tt> are present. * * @param set an <code>T#E#Set</code> * @return true if all elements were present in the set. */ public boolean containsAll( T#E#Set set ) { T#E#Iterator iter = set.iterator(); while ( iter.hasNext() ) { #e# element = iter.next(); if ( ! contains( element ) ) { return false; } } return true; } /** * Tests the set to determine if all of the elements in * <tt>array</tt> are present. * * @param array an <code>array</code> of #e# primitives. * @return true if all elements were present in the set. */ public boolean containsAll( #e#[] array ) { for ( int i = array.length; i-- > 0; ) { if ( ! contains(array[i]) ) { return false; } } return true; } /** * Adds all of the elements in <tt>collection</tt> to the set. * * @param collection an <code>Collection</code> to be added. * @return true if the set was modified by the add all operation. */ public boolean addAll( Collection<? extends #ET#> collection ) { boolean changed = false; for ( #ET# element : collection ) { #e# e = element.#e#Value(); if ( add( e ) ) { changed = true; } } return changed; } /** * Adds all of the elements in <tt>T#E#Set</tt> to the set. * * @param set an <code>T#E#Set</code> to be added. * @return true if the set was modified by the add all operation. */ public boolean addAll( T#E#Set set ) { boolean changed = false; T#E#Iterator iter = set.iterator(); while ( iter.hasNext() ) { #e# element = iter.next(); if ( add( element ) ) { changed = true; } } return changed; } /** * Adds all of the elements in <tt>array</tt> to the set. * * @param array an <code>array</code> of #e# primitives. * @return true if the set was modified by the add all operation. */ public boolean addAll( #e#[] array ) { boolean changed = false; for ( int i = array.length; i-- > 0; ) { if ( add( array[i] ) ) { changed = true; } } return changed; } /** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> of Objects. * @return true if the set was modified by the retain all operation */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { boolean modified = false; T#E#Iterator iter = iterator(); while ( iter.hasNext() ) { if ( ! collection.contains( #ET#.valueOf ( iter.next() ) ) ) { iter.remove(); modified = true; } } return modified; } /** * Removes any values in the set which are not contained in * <tt>set</tt>. * * @param set a <code>T#E#Set</code>. * @return true if the set was modified by the retain all operation */ public boolean retainAll( T#E#Set set ) { boolean modified = false; T#E#Iterator iter = iterator(); while ( iter.hasNext() ) { if ( ! set.contains( iter.next() ) ) { iter.remove(); modified = true; } } return modified; } /** * Removes any values in the set which are not contained in * <tt>array</tt>. * * @param array an <code>array</code> of #e# primitives. * @return true if the set was modified by the retain all operation */ public boolean retainAll( #e#[] array ) { boolean changed = false; Arrays.sort( array ); #e#[] set = _set; byte[] states = _states; for ( int i = set.length; i-- > 0; ) { if ( states[i] == FULL && ( Arrays.binarySearch( array,set[i] ) < 0) ) { remove(set[i]); changed = true; } } return changed; } /** * Removes all of the elements in <tt>collection</tt> from the set. * * @param collection an <code>Collection</code> of Objects. * @return true if the set was modified by the remove all operation. */ public boolean removeAll( Collection<?> collection ) { boolean changed = false; for ( Object element : collection ) { if ( element instanceof #ET# ) { #e# c = ( ( #ET# ) element ).#e#Value(); if ( remove( c ) ) { changed = true; } } } return changed; } /** * Removes all of the elements in <tt>T#E#Set</tt> from the set. * * @param set a <code>T#E#Set</code>. * @return true if the set was modified by the remove all operation. */ public boolean removeAll( T#E#Set set ) { boolean changed = false; T#E#Iterator iter = set.iterator(); while ( iter.hasNext() ) { #e# element = iter.next(); if ( remove( element ) ) { changed = true; } } return changed; } /** * Removes all of the elements in <tt>array</tt> from the set. * * @param array an <code>array</code> of #e# primitives. * @return true if the set was modified by the remove all operation. */ public boolean removeAll( #e#[] array ) { boolean changed = false; for ( int i = array.length; i-- > 0; ) { if ( remove(array[i]) ) { changed = true; } } return changed; } /** * Empties the set. */ public void clear() { super.clear(); #e#[] set = _set; byte[] states = _states; for ( int i = set.length; i-- > 0; ) { set[i] = no_entry_value; states[i] = FREE; } } /** * Delete the record at <tt>index</tt>. * * @param index an <code>int</code> value */ public void removeAt( int index ) { _set[index] = no_entry_value; _states[index] = REMOVED; _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(); } } } /** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ protected void rehash( int newCapacity ) { int oldCapacity = _set.length; #e# oldSet[] = _set; byte oldStates[] = _states; _set = new #e#[newCapacity]; _states = new byte[newCapacity]; for ( int i = oldCapacity; i-- > 0; ) { if( oldStates[i] == FULL ) { #e# o = oldSet[i]; int index = insertionIndex(o); _set[index] = o; _states[index] = FULL; } } } /** * 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: * * <ol> * <li> You'll free memory allocated to the table but no * longer needed because of the remove()s.</li> * * <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()); } } /** * Executes <tt>procedure</tt> for each element in the set. * * @param procedure a <code>T#E#Procedure</code> value * @return false if the loop over the set terminated because * the procedure returned false for some value. */ public boolean forEach( T#E#Procedure procedure ) { byte[] states = _states; #e#[] set = _set; for ( int i = set.length; i-- > 0; ) { if ( states[i] == FULL && ! procedure.execute( set[i] ) ) { return false; } } return true; } /** * Compares this set with another set for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean equals( Object other ) { if (! (other instanceof T#E#HashSet)) { return false; } final T#E#HashSet that = ( T#E#HashSet ) other; if ( that.size() != this.size() ) { return false; } return forEach( new T#E#Procedure() { public final boolean execute( #e# value ) { return that.contains( value ); } }); } public int hashCode() { HashProcedure p = new HashProcedure(); forEach(p); return p.getHashCode(); } private final class HashProcedure implements T#E#Procedure { private int h = 0; public int getHashCode() { return h; } public final boolean execute( #e# key ) { h += HashFunctions.hash( key ); return true; } } public void writeExternal( ObjectOutput out ) throws IOException { // VERSION out.writeByte( 1 ); // NUMBER OF ENTRIES out.writeInt( _size ); // LOAD FACTOR -- Added version 1 out.writeFloat( _loadFactor ); // NO ENTRY VALUE -- Added version 1 out.write#E#( no_entry_value ); // ENTRIES for ( int i = _states.length; i-- > 0; ) { if ( _states[i] == FULL ) { out.write#E#( _set[i] ); } } } public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION int version = in.readByte(); // NUMBER OF ENTRIES int size = in.readInt(); if ( version >= 1 ) { // LOAD FACTOR _loadFactor = in.readFloat(); // NO ENTRY VALUE no_entry_value = in.read#E#(); if ( no_entry_value != ( #e# ) 0 ) { Arrays.fill( _set, no_entry_value ); } } // ENTRIES setUp( size ); while ( size-- > 0 ) { #e# val = in.read#E#(); add( val ); } } } // TIntHashSet |
From: Jeff R. <uph...@us...> - 2009-09-02 21:52:42
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/procedure/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14856/src/gnu/trove/procedure/array Added Files: Tag: TROVE_3_WORKING ToObjectArrayProceedure.java Log Message: Implementation of HashSets, Add tests, changes as needed to allow those changes. --- NEW FILE: ToObjectArrayProceedure.java --- /////////////////////////////////////////////////////////////////////////////// // 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.array; import gnu.trove.procedure.TObjectProcedure; /** * A procedure which stores each value it receives into a target array. * <p/> * Created: Sat Jan 12 10:13:42 2002 * * @author Eric D. Friedman * @version $Id: ToObjectArrayProceedure.java,v 1.1.2.1 2009/09/02 21:52:33 upholderoftruth Exp $ */ public final class ToObjectArrayProceedure<T> implements TObjectProcedure<T> { private final T[] target; private int pos = 0; public ToObjectArrayProceedure( final T[] target ) { this.target = target; } public final boolean execute( T value ) { target[pos++] = value; return true; } } // ToObjectArrayProcedure |
From: Jeff R. <uph...@us...> - 2009-09-02 21:52:42
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14856/templates/gnu/trove/impl/hash Added Files: Tag: TROVE_3_WORKING _E_Hash.template Log Message: Implementation of HashSets, Add tests, changes as needed to allow those changes. --- NEW FILE: _E_Hash.template --- /////////////////////////////////////////////////////////////////////////////// // 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.T#E#Procedure; import gnu.trove.impl.HashFunctions; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * An open addressed hashing implementation for #e# 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.1 2009/09/02 21:52:33 upholderoftruth Exp $ */ abstract public class T#E#Hash extends TPrimitiveHash { /** the set of #e#s */ protected transient #e#[] _set; /** * value that represents null * * NOTE: should not be modified after the Hash is created, but is * not final because of Externalization * */ protected #e# no_entry_value; /** * Creates a new <code>T#E#Hash</code> instance with the default * capacity and load factor. */ public T#E#Hash() { super(); no_entry_value = ( #e# ) 0; } /** * Creates a new <code>T#E#Hash</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 T#E#Hash( int initialCapacity ) { super( initialCapacity ); no_entry_value = ( #e# ) 0; } /** * Creates a new <code>T#E#Hash</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 T#E#Hash( int initialCapacity, float loadFactor ) { super(initialCapacity, loadFactor); no_entry_value = ( #e# ) 0; } /** * Creates a new <code>T#E#Hash</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 T#E#Hash( int initialCapacity, float loadFactor, #e# no_entry_value ) { super(initialCapacity, loadFactor); this.no_entry_value = 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 #e# 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 #e#[capacity]; return capacity; } /** * Searches the set for <tt>val</tt> * * @param val an <code>#e#</code> value * @return a <code>boolean</code> value */ public boolean contains( #e# 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( T#E#Procedure procedure ) { byte[] states = _states; #e#[] 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 */ public void removeAt(int index) { _set[index] = (#e#)0; super.removeAt( index ); } /** * Locates the index of <tt>val</tt>. * * @param val an <code>#e#</code> value * @return the index of <tt>val</tt> or -1 if it isn't in the set. */ protected int index( #e# val ) { int hash, probe, index, length; final byte[] states = _states; final #e#[] 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>#e#</code> value * @return an <code>int</code> value */ protected int insertionIndex( #e# val ) { int hash, probe, index, length; final byte[] states = _states; final #e#[] 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; } } /** * Default implementation of T#E#HashingStrategy: * delegates hashing to HashFunctions.hash(#e#). * * @param val the value to hash * @return the hashcode. */ public final int computeHashCode( #e# val ) { return HashFunctions.hash( val ); } } // T#E#Hash |
From: Jeff R. <uph...@us...> - 2009-09-02 19:53:10
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4236/test/gnu/trove/impl/hash Log Message: Directory /cvsroot/trove4j/trove/test/gnu/trove/impl/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 19:52:58
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/impl In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4223/test/gnu/trove/impl Log Message: Directory /cvsroot/trove4j/trove/test/gnu/trove/impl added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 19:27:50
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1882/src/gnu/trove/iterator/hash Log Message: Directory /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 19:18:44
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/set In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1133/test/gnu/trove/set Log Message: Directory /cvsroot/trove4j/trove/test/gnu/trove/set added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 19:18:39
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1148/test/gnu/trove/set/hash Log Message: Directory /cvsroot/trove4j/trove/test/gnu/trove/set/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 19:15:58
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/procedure/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv714/src/gnu/trove/procedure/array Log Message: Directory /cvsroot/trove4j/trove/src/gnu/trove/procedure/array added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 19:06:32
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/procedure In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32200/src/gnu/trove/procedure Log Message: Directory /cvsroot/trove4j/trove/src/gnu/trove/procedure added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 18:59:59
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31280/src/gnu/trove/set/hash Log Message: Directory /cvsroot/trove4j/trove/src/gnu/trove/set/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 18:59:56
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/set In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31261/src/gnu/trove/set Log Message: Directory /cvsroot/trove4j/trove/src/gnu/trove/set added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 06:04:08
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18887/templates/gnu/trove/impl/hash Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 06:02:27
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/impl In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18795/templates/gnu/trove/impl Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/impl added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 06:01:55
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18715/src/gnu/trove/impl/hash Log Message: Directory /cvsroot/trove4j/trove/src/gnu/trove/impl/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-02 05:42:03
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17013/templates/gnu/trove/hash Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-01 21:05:28
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/iterator/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4647/templates/gnu/trove/iterator/array Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/iterator/array added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-01 19:06:38
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25089/templates/gnu/trove/set/hash Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/set/hash added to the repository |
From: Jeff R. <uph...@us...> - 2009-08-24 22:52:13
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12421/templates/gnu/trove/set Added Files: Tag: TROVE_3_WORKING _E_Set.template Log Message: Work in progress --- NEW FILE: _E_Set.template --- /////////////////////////////////////////////////////////////////////////////// // 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.T#E#Iterator; 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, * @author Rob Eden * @author Jeff Randall * @version $Id: _E_Set.template,v 1.1.2.1 2009/08/24 21:44:55 upholderoftruth Exp $ */ public interface T#E#Set 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. */ public #e# 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(); /** * Inserts a value into the set. * * @param entry a <code>#e#</code> value * @return true if the set was modified by the add operation */ public boolean add( #e# entry ); /** * 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 */ public #e#[] toArray(); /** * Returns an array containing all of the elements in this set; the * runtime type of the returned array is that of the specified array. * If the set fits in the specified array, it is returned therein. * Otherwise, a new array is allocated with the runtime type of the * specified array and the size of 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 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>Like the {@link #toArray()} method, this method acts as bridge between * array-based and collection-based APIs. Further, this method allows * precise control over the runtime type of the output array, and may, * under certain circumstances, be used to save allocation costs. * * <p>The following code can be used to dump the set into a newly * allocated array of <tt>#e#</tt>: * * <pre> * #e#[] y = x.toArray(new #e#[0]);</pre> * * Note that <tt>toArray(new #e#[0])</tt> is identical in function to * <tt>toArray()</tt>. * * @param a the array into which the elements of this set are to be * stored, if it is big enough; otherwise, a new array of the same * runtime type is allocated for this purpose. * @return an array containing all the elements in this set * @throws ArrayStoreException if the runtime type of the specified array * is not a supertype of the runtime type of every element in this * set * @throws NullPointerException if the specified array is null */ public #e#[] toArray( #e#[] a ); /** * Empties the set. */ public void clear(); /** * Removes <tt>entry</tt> from the set. * * @param entry an <code>#e#</code> value * @return true if the set was modified by the remove operation. */ public boolean remove( #e# entry ); /** * Creates an iterator over the values of the set. The iterator * supports element deletion. * * @return an <code>T#E#Iterator</code> value */ public T#E#Iterator iterator(); /** * 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. */ public boolean containsAll( Collection<?> collection ); /** * Tests the set to determine if all of the elements in * <tt>T#E#Set</tt> are present. * * @param set a <code>T#E#Set</code> value * @return true if all elements were present in the set. */ public boolean containsAll( T#E#Set set ); /** * 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. */ public boolean addAll( Collection<? extends #ET#> collection ); /** * Adds all of the elements in the <tt>T#E#Set</tt> to the set. * * @param set a <code>T#E#Set</code> value * @return true if the set was modified by the add all operation. */ public boolean addAll( T#E#Set set ); /** * 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. */ public boolean removeAll( Collection<?> collection ); /** * Removes all of the elements in <tt>T#E#Set</tt> from the set. * * @param set a <code>T#E#Set</code> value * @return true if the set was modified by the remove all operation. */ public boolean removeAll( T#E#Set set ); /** * 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 */ public boolean retainAll( Collection<?> collection ); /** * Removes any values in the set which are not contained in * <tt>T#E#Set</tt>. * * @param set a <code>T#E#Set</code> value * @return true if the set was modified by the retain all operation */ public boolean retainAll( T#E#Set set ); // 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( T#E#Set 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 |
From: Jeff R. <uph...@us...> - 2009-08-24 22:52:04
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12421/templates/gnu/trove/map/hash Added Files: Tag: TROVE_3_WORKING _K__V_HashMap.template Log Message: Work in progress --- NEW FILE: _K__V_HashMap.template --- /////////////////////////////////////////////////////////////////////////////// // 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.hash; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// import gnu.trove.map.T#K##V#Map; import gnu.trove.iterator.T#K##V#Iterator; import gnu.trove.procedure.*; import gnu.trove.function.T#V#Function; import java.io.*; import java.util.*; /** * An implementation of the Map interface which uses an open addressed * hash table to store its contents. * * @author Eric D. Friedman * @version $Id: _K__V_HashMap.template,v 1.1.2.1 2009/08/24 21:44:55 upholderoftruth Exp $ */ public class T#K##V#HashMap implements T#K##V#Map, Externalizable { /** * Returns the value that will be returned from {@link #get} or {@link #put} if no * entry exists for a given key. The default value is generally zero, but can be * changed during construction of the collection. */ public #v# getNoEntryValue() { return 0; // TODO: implement } /** * Inserts a key/value pair into the map. * * @param key an <code>#k#</code> value * @param value an <code>#v#</code> value * * @return the previous value associated with <tt>key</tt>, or the "no entry" value * if none was found (see {@link #getNoEntryValue}). */ public #v# put( #k# key, #v# value ) { return 0; // TODO: implement } /** * Inserts a key/value pair into the map if the specified key is not already * associated with a value. * * @param key an <code>#k#</code> value * @param value an <code>#v#</code> value * * @return the previous value associated with <tt>key</tt>, or the "no entry" value * if none was found (see {@link #getNoEntryValue}). */ public #v# putIfAbsent( #k# key, #v# value ) { return 0; // TODO: implement } /** * 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. */ public void putAll( T#K##V#Map map ) { // TODO: implement } /** * Retrieves the value for <tt>key</tt> * * @param key an <code>#k#</code> value * * @return the previous value associated with <tt>key</tt>, or the "no entry" value * if none was found (see {@link #getNoEntryValue}). */ public #v# get( #k# key ) { return 0; // TODO: implement } /** * Empties the map. * */ public void clear() { // TODO: implement } /** * Deletes a key/value pair from the map. * * @param key an <code>#k#</code> value * * @return the previous value associated with <tt>key</tt>, or the "no entry" value * if none was found (see {@link #getNoEntryValue}). */ public #v# remove( #k# key ) { return 0; // TODO: implement } /** * Returns the values of the map. */ public #v#[] values() { return new #v#[0]; // TODO: implement } /** * Returns the values of the map using an existing array. * * @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. */ public #v#[] values( #v#[] array ) { return new #v#[0]; // TODO: implement } /** * Returns the keys of the map. */ public #k#[] keys() { return new #k#[0]; // TODO: implement } /** * Returns the keys of the map. * * @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. */ public #k#[] keys( #k#[] array ) { return new #k#[0]; // TODO: implement } /** * Checks for the presence of <tt>val</tt> in the values of the map. * * @param val an <code>#v#</code> value * @return a <code>boolean</code> value */ public boolean containsValue( #v# val ) { return false; // TODO: implement } /** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>#k#</code> value * @return a <code>boolean</code> value */ public boolean containsKey( #k# key ) { return false; // TODO: implement } /** * @return a T#K##V#Iterator with access to this map's keys and values */ public T#K##V#Iterator iterator() { return null; // TODO: implement } /** * Executes <tt>procedure</tt> for each key in the map. * * @param procedure a <code>T#K#Procedure</code> value * @return false if the loop over the keys terminated because * the procedure returned false for some key. */ public boolean forEachKey( T#K#Procedure procedure ) { return false; // TODO: implement } /** * Executes <tt>procedure</tt> for each value in the map. * * @param procedure a <code>T#V#Procedure</code> value * @return false if the loop over the values terminated because * the procedure returned false for some value. */ public boolean forEachValue( T#V#Procedure procedure ) { return false; // TODO: implement } /** * Executes <tt>procedure</tt> for each key/value entry in the * map. * * @param procedure a <code>T#K##V#Procedure</code> value * @return false if the loop over the entries terminated because * the procedure returned false for some entry. */ public boolean forEachEntry( T#K##V#Procedure procedure ) { return false; // TODO: implement } /** * Transform the values in this map using <tt>function</tt>. * * @param function a <code>T#V#Function</code> value */ public void transformValues( T#V#Function function ) { // TODO: implement } /** * 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( T#K##V#Procedure procedure ) { return false; // TODO: implement } /** * Increments the primitive value mapped to key by 1 * * @param key the key of the value to increment * @return true if a mapping was found and modified. */ public boolean increment( #k# key ) { return false; // TODO: implement } /** * Adjusts the primitive value mapped to key. * * @param key the key of the value to increment * @param amount the amount to adjust the value by. * @return true if a mapping was found and modified. */ public boolean adjustValue( #k# key, #v# amount ) { return false; // TODO: implement } /** * Adjusts the primitive value mapped to the key if the key is present in the map. * Otherwise, the <tt>initial_value</tt> is put in the map. * * @param key the key of the value to increment * @param adjust_amount the amount to adjust the value by * @param put_amount the value put into the map if the key is not initial present * * @return the value present in the map after the adjustment or put operation */ public #v# adjustOrPutValue( #k# key, #v# adjust_amount, #v# put_amount ) { return 0; // TODO: implement } public void writeExternal(ObjectOutput out) throws IOException { // TODO: implement } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // TODO: implement } } // T#K##V#HashMap |
From: Jeff R. <uph...@us...> - 2009-08-24 20:21:05
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1009/templates/gnu/trove/set Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/set added to the repository |
From: Jeff R. <uph...@us...> - 2009-08-24 20:14:13
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32495/templates/gnu/trove/map/hash Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/map/hash added to the repository |