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-09 06:25:10
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10431/templates/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayList.template Log Message: Constructor that accepts arrays now uses the array size as the initial capacity. Index: _E_ArrayList.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/array/Attic/_E_ArrayList.template,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -C2 -d -r1.1.2.11 -r1.1.2.12 *** _E_ArrayList.template 9 Sep 2009 05:47:38 -0000 1.1.2.11 --- _E_ArrayList.template 9 Sep 2009 06:24:51 -0000 1.1.2.12 *************** *** 116,127 **** /** * Creates a new <code>T#E#ArrayList</code> instance whose ! * capacity is the greater of the length of <tt>values</tt> and ! * DEFAULT_CAPACITY and whose initial contents are the specified ! * values. * * @param values an <code>#e#[]</code> value */ public T#E#ArrayList( #e#[] values ) { ! this( Math.max( values.length, DEFAULT_CAPACITY ) ); add( values ); } --- 116,126 ---- /** * Creates a new <code>T#E#ArrayList</code> instance whose ! * capacity is the length of <tt>values</tt> array and whose ! * initial contents are the specified values. * * @param values an <code>#e#[]</code> value */ public T#E#ArrayList( #e#[] values ) { ! this( values.length ); add( values ); } |
From: Jeff R. <uph...@us...> - 2009-09-09 06:24:25
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10197/src/gnu/trove/impl/hash Modified Files: Tag: TROVE_3_WORKING TObjectHash.java Log Message: prevent potential ClassCastExceptions Index: TObjectHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/impl/hash/Attic/TObjectHash.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TObjectHash.java 4 Sep 2009 12:32:33 -0000 1.1.2.2 --- TObjectHash.java 9 Sep 2009 06:24:06 -0000 1.1.2.3 *************** *** 142,146 **** @SuppressWarnings({"unchecked"}) public boolean contains( Object obj ) { ! return index( (T) obj ) >= 0; } --- 142,146 ---- @SuppressWarnings({"unchecked"}) public boolean contains( Object obj ) { ! return index( obj ) >= 0; } *************** *** 152,156 **** * @return the index of <tt>obj</tt> or -1 if it isn't in the set. */ ! protected int index( T obj ) { final Object[] set = _set; --- 152,156 ---- * @return the index of <tt>obj</tt> or -1 if it isn't in the set. */ ! protected int index( Object obj ) { final Object[] set = _set; |
From: Jeff R. <uph...@us...> - 2009-09-09 06:24:20
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10197/src/gnu/trove/iterator/hash Modified Files: Tag: TROVE_3_WORKING TObjectHashIterator.java Log Message: prevent potential ClassCastExceptions Index: TObjectHashIterator.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash/Attic/TObjectHashIterator.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TObjectHashIterator.java 6 Sep 2009 17:02:20 -0000 1.1.2.2 --- TObjectHashIterator.java 9 Sep 2009 06:24:06 -0000 1.1.2.3 *************** *** 25,37 **** - /** * Iterator for hashtables that use open addressing to resolve collisions. - * <p/> - * NOTE: This class cannot currently use Generics without causing issues - * when used with THashMap, but that is hidden behind the scenes as - * the Interface returned to the user does use Generics. - * <p/> - * Created: Wed Nov 28 21:30:53 2001 * * @author Eric D. Friedman --- 25,30 ---- *************** *** 41,50 **** */ ! public class TObjectHashIterator extends THashIterator { protected final TObjectHash _objectHash; ! public TObjectHashIterator( TObjectHash hash ) { super( hash ); _objectHash = hash; --- 34,43 ---- */ ! public class TObjectHashIterator<E> extends THashIterator<E> { protected final TObjectHash _objectHash; ! public TObjectHashIterator( TObjectHash<E> hash ) { super( hash ); _objectHash = hash; *************** *** 52,57 **** ! protected Object objectAtIndex( int index ) { ! return _objectHash._set[index]; } --- 45,55 ---- ! @SuppressWarnings("unchecked") ! protected E objectAtIndex( int index ) { ! Object obj = _objectHash._set[index]; ! if ( obj == TObjectHash.FREE || obj == TObjectHash.REMOVED ) { ! return null; ! } ! return (E) obj; } |
From: Jeff R. <uph...@us...> - 2009-09-09 06:24:20
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10197/src/gnu/trove/set/hash Modified Files: Tag: TROVE_3_WORKING THashSet.java Log Message: prevent potential ClassCastExceptions Index: THashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/set/hash/Attic/THashSet.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** THashSet.java 6 Sep 2009 17:02:20 -0000 1.1.2.3 --- THashSet.java 9 Sep 2009 06:24:06 -0000 1.1.2.4 *************** *** 242,246 **** @SuppressWarnings({"unchecked"}) public boolean remove( Object obj ) { ! int index = index( (E) obj ); if ( index >= 0 ) { removeAt( index ); --- 242,246 ---- @SuppressWarnings({"unchecked"}) public boolean remove( Object obj ) { ! int index = index( obj ); if ( index >= 0 ) { removeAt( index ); *************** *** 258,263 **** */ @SuppressWarnings({"unchecked"}) ! public TObjectHashIterator iterator() { ! return new TObjectHashIterator( this ); } --- 258,263 ---- */ @SuppressWarnings({"unchecked"}) ! public TObjectHashIterator<E> iterator() { ! return new TObjectHashIterator<E>( this ); } |
From: Jeff R. <uph...@us...> - 2009-09-09 06:24:18
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10197/test/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING THashMapTest.java Log Message: prevent potential ClassCastExceptions Index: THashMapTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/map/hash/Attic/THashMapTest.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** THashMapTest.java 6 Sep 2009 17:02:20 -0000 1.1.2.1 --- THashMapTest.java 9 Sep 2009 06:24:06 -0000 1.1.2.2 *************** *** 190,193 **** --- 190,194 ---- + @SuppressWarnings({"SuspiciousMethodCalls"}) public void testGet() throws Exception { String key = "hi", val = "one", val2 = "two"; *************** *** 198,201 **** --- 199,205 ---- assertEquals( "get did not return expected value on second put", val2, ss_map.get( key ) ); + + // Invalid key should return null + assertNull( ss_map.get( new Object() ) ); } |
From: Jeff R. <uph...@us...> - 2009-09-09 06:24:18
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10197/src/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING THashMap.java Log Message: prevent potential ClassCastExceptions Index: THashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/map/hash/Attic/THashMap.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** THashMap.java 6 Sep 2009 17:02:20 -0000 1.1.2.1 --- THashMap.java 9 Sep 2009 06:24:06 -0000 1.1.2.2 *************** *** 412,417 **** @SuppressWarnings({"unchecked"}) public V get( Object key ) { ! int index = index( (K) key ); ! return index < 0 ? null : _values[index]; } --- 412,420 ---- @SuppressWarnings({"unchecked"}) public V get( Object key ) { ! int index = index( key ); ! if ( index < 0 || ! _set[index].equals( key ) ) { ! return null; ! } ! return _values[index]; } *************** *** 439,443 **** public V remove( Object key ) { V prev = null; ! int index = index( (K) key ); if ( index >= 0 ) { prev = _values[index]; --- 442,446 ---- public V remove( Object key ) { V prev = null; ! int index = index( key ); if ( index >= 0 ) { prev = _values[index]; *************** *** 787,796 **** // TODO: remove? - // void setKey( K aKey ) { - // this.key = aKey; - // } - - - // TODO: remove? void setValue0( V aValue ) { this.val = aValue; --- 790,793 ---- |
From: Jeff R. <uph...@us...> - 2009-09-09 05:47:51
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/iterator/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5377/templates/gnu/trove/iterator/array Removed Files: Tag: TROVE_3_WORKING _E_ArrayIterator.template Log Message: Implement TPrimitiveArrayIterators as an inner class. --- _E_ArrayIterator.template DELETED --- |
From: Jeff R. <uph...@us...> - 2009-09-09 05:47:49
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5377/templates/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayList.template Log Message: Implement TPrimitiveArrayIterators as an inner class. Index: _E_ArrayList.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/array/Attic/_E_ArrayList.template,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -C2 -d -r1.1.2.10 -r1.1.2.11 *** _E_ArrayList.template 9 Sep 2009 01:15:54 -0000 1.1.2.10 --- _E_ArrayList.template 9 Sep 2009 05:47:38 -0000 1.1.2.11 *************** *** 25,29 **** import gnu.trove.procedure.T#E#Procedure; import gnu.trove.iterator.T#E#Iterator; - import gnu.trove.iterator.array.T#E#ArrayIterator; import gnu.trove.T#E#Collection; import gnu.trove.impl.*; --- 25,28 ---- *************** *** 516,520 **** /** {@inheritDoc} */ public T#E#Iterator iterator() { ! return new T#E#ArrayIterator( this ); } --- 515,519 ---- /** {@inheritDoc} */ public T#E#Iterator iterator() { ! return new T#E#ArrayIterator(); } *************** *** 1217,1220 **** --- 1216,1251 ---- + /** T#E#ArrayList iterator */ + class T#E#ArrayIterator implements T#E#Iterator { + + /** The array of data to be iterated over. */ + private int index; + + + T#E#ArrayIterator() { + index = 0; + } + + + /** {@inheritDoc} */ + public boolean hasNext() { + return ! ( index < _pos); + } + + + /** {@inheritDoc} */ + public void remove() { + T#E#ArrayList.this.remove( index, 1 ); + } + + + /** {@inheritDoc} */ + public #e# next() { + index++; + return _data[index]; + } + } + + public void writeExternal( ObjectOutput out ) throws IOException { // VERSION |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:12
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING _K__V_HashMap.template Log Message: TPrimitiveCollection interface Index: _K__V_HashMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/hash/Attic/_K__V_HashMap.template,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** _K__V_HashMap.template 8 Sep 2009 16:26:40 -0000 1.1.2.2 --- _K__V_HashMap.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 *************** *** 34,37 **** --- 34,38 ---- import gnu.trove.impl.hash.*; import gnu.trove.impl.HashFunctions; + import gnu.trove.*; import java.io.*; *************** *** 322,326 **** * Returns the keys of the map as a <tt>T#K#Set</tt> */ ! public T#K#Set keys() { return new TKeyView(); } --- 323,327 ---- * Returns the keys of the map as a <tt>T#K#Set</tt> */ ! public T#K#Set keySet() { return new TKeyView(); } *************** *** 330,334 **** * Returns the keys of the map. */ ! public #k#[] keysAsArray() { #k#[] keys = new #k#[size()]; #k#[] k = _set; --- 331,335 ---- * Returns the keys of the map. */ ! public #k#[] keys() { #k#[] keys = new #k#[size()]; #k#[] k = _set; *************** *** 351,355 **** * allocated for this purpose. */ ! public #k#[] keysAsArray( #k#[] array ) { int size = size(); if ( array.length < size ) { --- 352,356 ---- * allocated for this purpose. */ ! public #k#[] keys( #k#[] array ) { int size = size(); if ( array.length < size ) { *************** *** 372,376 **** * Returns the values of the map as a <tt>T#V#Set</tt> */ ! public T#V#Set values() { return new TValueView(); } --- 373,377 ---- * Returns the values of the map as a <tt>T#V#Set</tt> */ ! public T#V#Collection valueCollection() { return new TValueView(); } *************** *** 380,384 **** * Returns the values of the map. */ ! public #v#[] valuesAsArray() { #v#[] vals = new #v#[size()]; #v#[] v = _values; --- 381,385 ---- * Returns the values of the map. */ ! public #v#[] values() { #v#[] vals = new #v#[size()]; #v#[] v = _values; *************** *** 401,405 **** * allocated for this purpose. */ ! public #v#[] valuesAsArray( #v#[] array ) { int size = size(); if ( array.length < size ) { --- 402,406 ---- * allocated for this purpose. */ ! public #v#[] values( #v#[] array ) { int size = size(); if ( array.length < size ) { *************** *** 672,676 **** /** {@inheritDoc} */ public #k#[] toArray() { ! return T#K##V#HashMap.this.keysAsArray(); } --- 673,677 ---- /** {@inheritDoc} */ public #k#[] toArray() { ! return T#K##V#HashMap.this.keys(); } *************** *** 678,682 **** /** {@inheritDoc} */ public #k#[] toArray( #k#[] dest ) { ! return T#K##V#HashMap.this.keysAsArray( dest ); } --- 679,683 ---- /** {@inheritDoc} */ public #k#[] toArray( #k#[] dest ) { ! return T#K##V#HashMap.this.keys( dest ); } *************** *** 715,720 **** /** {@inheritDoc} */ ! public boolean containsAll( T#K#Set set ) { ! T#K#Iterator iter = set.iterator(); while ( iter.hasNext() ) { if ( ! T#K##V#HashMap.this.containsKey( iter.next() ) ) { --- 716,721 ---- /** {@inheritDoc} */ ! public boolean containsAll( T#K#Collection collection ) { ! T#K#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! T#K##V#HashMap.this.containsKey( iter.next() ) ) { *************** *** 752,756 **** * {@inheritDoc} */ ! public boolean addAll( T#K#Set set ) { throw new UnsupportedOperationException(); } --- 753,757 ---- * {@inheritDoc} */ ! public boolean addAll( T#K#Collection collection ) { throw new UnsupportedOperationException(); } *************** *** 783,788 **** /** {@inheritDoc} */ ! public boolean retainAll( T#K#Set set ) { ! if ( this == set ) { return false; } --- 784,789 ---- /** {@inheritDoc} */ ! public boolean retainAll( T#K#Collection collection ) { ! if ( this == collection ) { return false; } *************** *** 790,794 **** T#K#Iterator iter = iterator(); while ( iter.hasNext() ) { ! if ( ! set.contains( iter.next() ) ) { iter.remove(); modified = true; --- 791,795 ---- T#K#Iterator iter = iterator(); while ( iter.hasNext() ) { ! if ( ! collection.contains( iter.next() ) ) { iter.remove(); modified = true; *************** *** 832,838 **** /** {@inheritDoc} */ ! public boolean removeAll( T#K#Set set ) { boolean changed = false; ! T#K#Iterator iter = set.iterator(); while ( iter.hasNext() ) { #k# element = iter.next(); --- 833,839 ---- /** {@inheritDoc} */ ! public boolean removeAll( T#K#Collection collection ) { boolean changed = false; ! T#K#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { #k# element = iter.next(); *************** *** 871,875 **** /** a view onto the values of the map. */ ! protected class TValueView implements T#V#Set { /** {@inheritDoc} */ --- 872,876 ---- /** a view onto the values of the map. */ ! protected class TValueView implements T#V#Collection { /** {@inheritDoc} */ *************** *** 932,936 **** /** {@inheritDoc} */ public #v#[] toArray() { ! return T#K##V#HashMap.this.valuesAsArray(); } --- 933,937 ---- /** {@inheritDoc} */ public #v#[] toArray() { ! return T#K##V#HashMap.this.values(); } *************** *** 938,942 **** /** {@inheritDoc} */ public #v#[] toArray( #v#[] dest ) { ! return T#K##V#HashMap.this.valuesAsArray( dest ); } --- 939,943 ---- /** {@inheritDoc} */ public #v#[] toArray( #v#[] dest ) { ! return T#K##V#HashMap.this.values( dest ); } *************** *** 980,985 **** /** {@inheritDoc} */ ! public boolean containsAll( T#V#Set set ) { ! T#V#Iterator iter = set.iterator(); while ( iter.hasNext() ) { if ( ! T#K##V#HashMap.this.containsValue( iter.next() ) ) { --- 981,986 ---- /** {@inheritDoc} */ ! public boolean containsAll( T#V#Collection collection ) { ! T#V#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! T#K##V#HashMap.this.containsValue( iter.next() ) ) { *************** *** 1009,1013 **** /** {@inheritDoc} */ ! public boolean addAll( T#V#Set set ) { throw new UnsupportedOperationException(); } --- 1010,1014 ---- /** {@inheritDoc} */ ! public boolean addAll( T#V#Collection collection ) { throw new UnsupportedOperationException(); } *************** *** 1036,1041 **** /** {@inheritDoc} */ ! public boolean retainAll( T#V#Set set ) { ! if ( this == set ) { return false; } --- 1037,1042 ---- /** {@inheritDoc} */ ! public boolean retainAll( T#V#Collection collection ) { ! if ( this == collection ) { return false; } *************** *** 1043,1047 **** T#V#Iterator iter = iterator(); while ( iter.hasNext() ) { ! if ( ! set.contains( iter.next() ) ) { iter.remove(); modified = true; --- 1044,1048 ---- T#V#Iterator iter = iterator(); while ( iter.hasNext() ) { ! if ( ! collection.contains( iter.next() ) ) { iter.remove(); modified = true; *************** *** 1085,1091 **** /** {@inheritDoc} */ ! public boolean removeAll( T#V#Set set ) { boolean changed = false; ! T#V#Iterator iter = set.iterator(); while ( iter.hasNext() ) { #v# element = iter.next(); --- 1086,1092 ---- /** {@inheritDoc} */ ! public boolean removeAll( T#V#Collection collection ) { boolean changed = false; ! T#V#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { #v# element = iter.next(); *************** *** 1123,1127 **** ! public class T#K##V#KeyHashIterator extends TPrimitiveIterator implements T#K#Iterator { /** --- 1124,1128 ---- ! class T#K##V#KeyHashIterator extends TPrimitiveIterator implements T#K#Iterator { /** *************** *** 1130,1134 **** * @param hash the <tt>TPrimitiveHash</tt> we will be iterating over. */ ! public T#K##V#KeyHashIterator( TPrimitiveHash hash ) { super( hash ); } --- 1131,1135 ---- * @param hash the <tt>TPrimitiveHash</tt> we will be iterating over. */ ! T#K##V#KeyHashIterator( TPrimitiveHash hash ) { super( hash ); } *************** *** 1146,1167 **** return _set[_index]; } - - - /** - * 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# set( #v# val ) { - throw new UnsupportedOperationException(); - } } ! public class T#K##V#ValueHashIterator extends TPrimitiveIterator implements T#V#Iterator { /** --- 1147,1155 ---- return _set[_index]; } } ! class T#K##V#ValueHashIterator extends TPrimitiveIterator implements T#V#Iterator { /** *************** *** 1170,1174 **** * @param hash the <tt>TPrimitiveHash</tt> we will be iterating over. */ ! public T#K##V#ValueHashIterator( TPrimitiveHash hash ) { super( hash ); } --- 1158,1162 ---- * @param hash the <tt>TPrimitiveHash</tt> we will be iterating over. */ ! T#K##V#ValueHashIterator( TPrimitiveHash hash ) { super( hash ); } *************** *** 1204,1213 **** ! ! ! ! ! ! public class T#K##V#HashIterator extends TPrimitiveIterator implements T#K##V#Iterator { /** --- 1192,1196 ---- ! class T#K##V#HashIterator extends TPrimitiveIterator implements T#K##V#Iterator { /** *************** *** 1216,1220 **** * @param map the <tt>T#K##V#HashMap</tt> we will be iterating over. */ ! public T#K##V#HashIterator( T#K##V#HashMap map ) { super( map ); } --- 1199,1203 ---- * @param map the <tt>T#K##V#HashMap</tt> we will be iterating over. */ ! T#K##V#HashIterator( T#K##V#HashMap map ) { super( map ); } |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:12
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/test/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING TPrimitivePrimitiveHashMapTest.java Log Message: TPrimitiveCollection interface Index: TPrimitivePrimitiveHashMapTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/map/hash/Attic/TPrimitivePrimitiveHashMapTest.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** TPrimitivePrimitiveHashMapTest.java 8 Sep 2009 16:26:40 -0000 1.1.2.1 --- TPrimitivePrimitiveHashMapTest.java 9 Sep 2009 01:15:54 -0000 1.1.2.2 *************** *** 29,39 **** import gnu.trove.iterator.TIntIterator; import gnu.trove.map.TIntLongMap; - import gnu.trove.impl.hash.TPrimitiveHash; import gnu.trove.set.TIntSet; - import gnu.trove.set.TLongSet; import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TLongProcedure; import gnu.trove.procedure.TIntLongProcedure; import gnu.trove.function.TLongFunction; import junit.framework.TestCase; --- 29,38 ---- import gnu.trove.iterator.TIntIterator; import gnu.trove.map.TIntLongMap; import gnu.trove.set.TIntSet; import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TLongProcedure; import gnu.trove.procedure.TIntLongProcedure; import gnu.trove.function.TLongFunction; + import gnu.trove.TLongCollection; import junit.framework.TestCase; *************** *** 269,273 **** TIntList list = new TIntArrayList( keys ); ! TIntSet set = map.keys(); assertEquals( map.getNoEntryValue(), set.getNoEntryValue() ); --- 268,272 ---- TIntList list = new TIntArrayList( keys ); ! TIntSet set = map.keySet(); assertEquals( map.getNoEntryValue(), set.getNoEntryValue() ); *************** *** 315,319 **** assertEquals( 2, map.size() ); ! int[] keys = map.keysAsArray( new int[map.size()] ); assertEquals( 2, keys.length ); TIntList keys_list = new TIntArrayList( keys ); --- 314,318 ---- assertEquals( 2, map.size() ); ! int[] keys = map.keys( new int[map.size()] ); assertEquals( 2, keys.length ); TIntList keys_list = new TIntArrayList( keys ); *************** *** 322,326 **** assertTrue( keys_list.contains( KEY_TWO ) ); ! int[] keys2 = map.keysAsArray(); assertEquals( 2, keys2.length ); TIntList keys_list2 = new TIntArrayList( keys2 ); --- 321,325 ---- assertTrue( keys_list.contains( KEY_TWO ) ); ! int[] keys2 = map.keys(); assertEquals( 2, keys2.length ); TIntList keys_list2 = new TIntArrayList( keys2 ); *************** *** 339,343 **** assertEquals( 2, map.size() ); ! long[] values = map.valuesAsArray( new long[map.size()] ); assertEquals( 2, values.length ); TLongList values_list = new TLongArrayList( values ); --- 338,342 ---- assertEquals( 2, map.size() ); ! long[] values = map.values( new long[map.size()] ); assertEquals( 2, values.length ); TLongList values_list = new TLongArrayList( values ); *************** *** 346,350 **** assertTrue( values_list.contains( 2 ) ); ! long[] values2 = map.valuesAsArray(); assertEquals( 2, values2.length ); TLongList keys_list2 = new TLongArrayList( values2 ); --- 345,349 ---- assertTrue( values_list.contains( 2 ) ); ! long[] values2 = map.values(); assertEquals( 2, values2.length ); TLongList keys_list2 = new TLongArrayList( values2 ); *************** *** 559,563 **** int[] keys = new int[sz]; ! m.keysAsArray( keys ); boolean[] seen = new boolean[sz]; --- 558,562 ---- int[] keys = new int[sz]; ! m.keys( keys ); boolean[] seen = new boolean[sz]; *************** *** 597,606 **** public long remove( int key ) { return 0; } public int size() { return 0; } ! public TIntSet keys() { return null; } ! public int[] keysAsArray() { return new int[0]; } ! public int[] keysAsArray( int[] array ) { return new int[0]; } ! public TLongSet values() { return null; } ! public long[] valuesAsArray() { return new long[0]; } ! public long[] valuesAsArray( long[] array ) { return new long[0]; } public boolean containsValue( long val ) { return false; } public boolean containsKey( int key ) { return false; } --- 596,605 ---- public long remove( int key ) { return 0; } public int size() { return 0; } ! public TIntSet keySet() { return null; } ! public int[] keys() { return new int[0]; } ! public int[] keys( int[] array ) { return new int[0]; } ! public TLongCollection valueCollection() { return null; } ! public long[] values() { return new long[0]; } ! public long[] values( long[] array ) { return new long[0]; } public boolean containsValue( long val ) { return false; } public boolean containsKey( int key ) { return false; } |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:08
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayList.template Log Message: TPrimitiveCollection interface Index: _E_ArrayList.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/array/Attic/_E_ArrayList.template,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -C2 -d -r1.1.2.9 -r1.1.2.10 *** _E_ArrayList.template 4 Sep 2009 12:32:34 -0000 1.1.2.9 --- _E_ArrayList.template 9 Sep 2009 01:15:54 -0000 1.1.2.10 *************** *** 24,27 **** --- 24,30 ---- import gnu.trove.list.T#E#List; import gnu.trove.procedure.T#E#Procedure; + import gnu.trove.iterator.T#E#Iterator; + import gnu.trove.iterator.array.T#E#ArrayIterator; + import gnu.trove.T#E#Collection; import gnu.trove.impl.*; *************** *** 31,34 **** --- 34,38 ---- import java.io.ObjectOutput; import java.util.Arrays; + import java.util.Collection; import java.util.Random; *************** *** 194,201 **** * * @param val an <code>#e#</code> value */ ! public void add( #e# val ) { ensureCapacity( _pos + 1 ); _data[ _pos++ ] = val; } --- 198,207 ---- * * @param val an <code>#e#</code> value + * @return true if the list was modified by the add operation */ ! public boolean add( #e# val ) { ensureCapacity( _pos + 1 ); _data[ _pos++ ] = val; + return true; } *************** *** 443,446 **** --- 449,473 ---- /** + * Removes the first occurrence of the specified value from this list, + * if it is present. If the list does not contain the value, it is + * unchanged. Returns <tt>true</tt> if this list + * contained the specified value (or equivalently, if this list + * changed as a result of the call). + * + * @param value a <tt>#e#</tt> value to be removed from this list, if present + * @return <tt>true</tt> if this list contained the specified element + */ + public boolean remove( #e# value ) { + for ( int index = 0; index < _pos; index++ ) { + if ( value == _data[index] ) { + remove( index, 1 ); + return true; + } + } + return false; + } + + + /** * Removes the value at <tt>offset</tt> from the list. * *************** *** 448,452 **** * @return the value previously stored at offset. */ ! public #e# remove( int offset ) { #e# old = get( offset ); remove( offset, 1 ); --- 475,479 ---- * @return the value previously stored at offset. */ ! public #e# removeAt( int offset ) { #e# old = get( offset ); remove( offset, 1 ); *************** *** 487,490 **** --- 514,691 ---- + /** {@inheritDoc} */ + public T#E#Iterator iterator() { + return new T#E#ArrayIterator( this ); + } + + + /** {@inheritDoc} */ + 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; + } + + + /** {@inheritDoc} */ + public boolean containsAll( T#E#Collection collection ) { + T#E#Iterator iter = collection.iterator(); + while ( iter.hasNext() ) { + #e# element = iter.next(); + if ( ! contains( element ) ) { + return false; + } + } + return true; + } + + + /** {@inheritDoc} */ + public boolean containsAll( #e#[] array ) { + for ( int i = array.length; i-- > 0; ) { + if ( ! contains( array[i] ) ) { + return false; + } + } + return true; + } + + + /** {@inheritDoc} */ + 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; + } + + + /** {@inheritDoc} */ + public boolean addAll( T#E#Collection collection ) { + boolean changed = false; + T#E#Iterator iter = collection.iterator(); + while ( iter.hasNext() ) { + #e# element = iter.next(); + if ( add( element ) ) { + changed = true; + } + } + return changed; + } + + + /** {@inheritDoc} */ + public boolean addAll( #e#[] array ) { + boolean changed = false; + for ( int i = array.length; i-- > 0; ) { + if ( add( array[i] ) ) { + changed = true; + } + } + return changed; + } + + + /** {@inheritDoc} */ + 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; + } + + + /** {@inheritDoc} */ + public boolean retainAll( T#E#Collection collection ) { + if ( this == collection ) { + return false; + } + boolean modified = false; + T#E#Iterator iter = iterator(); + while ( iter.hasNext() ) { + if ( ! collection.contains( iter.next() ) ) { + iter.remove(); + modified = true; + } + } + return modified; + } + + + /** {@inheritDoc} */ + public boolean retainAll( #e#[] array ) { + boolean changed = false; + Arrays.sort( array ); + #e#[] data = _data; + + for ( int i = data.length; i-- > 0; ) { + if ( Arrays.binarySearch( array, data[i] ) < 0 ) { + remove( i, 1 ); + changed = true; + } + } + return changed; + } + + + /** {@inheritDoc} */ + 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; + } + + + /** {@inheritDoc} */ + public boolean removeAll( T#E#Collection collection ) { + boolean changed = false; + T#E#Iterator iter = collection.iterator(); + while ( iter.hasNext() ) { + #e# element = iter.next(); + if ( remove( element ) ) { + changed = true; + } + } + return changed; + } + + + /** {@inheritDoc} */ + public boolean removeAll( #e#[] array ) { + boolean changed = false; + for ( int i = array.length; i-- > 0; ) { + if ( remove(array[i]) ) { + changed = true; + } + } + return changed; + } + + /** * Transform each value in the list using the specified function. |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:06
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove Added Files: Tag: TROVE_3_WORKING _E_Collection.template Log Message: TPrimitiveCollection interface --- NEW FILE: _E_Collection.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; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// import gnu.trove.iterator.T#E#Iterator; import gnu.trove.procedure.T#E#Procedure; 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.1 2009/09/09 01:15:54 upholderoftruth Exp $ */ public interface T#E#Collection 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 */ public #e# 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>#e#</code> value * @return true if the collection contains the specified element. */ public boolean contains( #e# entry ); /** * Creates an iterator over the values of the collection. The iterator * supports element deletion. * * @return an <code>T#E#Iterator</code> value */ public T#E#Iterator 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 */ public #e#[] 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>#e#[]</tt> containing all the elements in this collection * @throws NullPointerException if the specified array is null */ public #e#[] toArray( #e#[] dest ); /** * Inserts a value into the collection. * * @param entry a <code>#e#</code> value * @return true if the collection was modified by the add operation */ public boolean add( #e# entry ); /** * Removes <tt>entry</tt> from the collection. * * @param entry an <code>#e#</code> value * @return true if the collection was modified by the remove operation. */ public boolean remove( #e# 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. */ public boolean containsAll( Collection<?> collection ); /** * Tests the collection to determine if all of the elements in * <tt>T#E#Collection</tt> are present. * * @param collection a <code>T#E#Collection</code> value * @return true if all elements were present in the collection. */ public boolean containsAll( T#E#Collection collection ); /** * Tests the collection to determine if all of the elements in * <tt>array</tt> are present. * * @param array as <code>array</code> of #e# primitives. * @return true if all elements were present in the collection. */ public boolean containsAll( #e#[] 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. */ public boolean addAll( Collection<? extends #ET#> collection ); /** * Adds all of the elements in the <tt>T#E#Collection</tt> to the collection. * * @param collection a <code>T#E#Collection</code> value * @return true if the collection was modified by the add all operation. */ public boolean addAll( T#E#Collection collection ); /** * Adds all of the elements in the <tt>array</tt> to the collection. * * @param array a <code>array</code> of #e# primitives. * @return true if the collection was modified by the add all operation. */ public boolean addAll( #e#[] 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 */ public boolean retainAll( Collection<?> collection ); /** * Removes any values in the collection which are not contained in * <tt>T#E#Collection</tt>. * * @param collection a <code>T#E#Collection</code> value * @return true if the collection was modified by the retain all operation */ public boolean retainAll( T#E#Collection collection ); /** * Removes any values in the collection which are not contained in * <tt>array</tt>. * * @param array an <code>array</code> of #e# primitives. * @return true if the collection was modified by the retain all operation */ public boolean retainAll( #e#[] 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. */ public boolean removeAll( Collection<?> collection ); /** * Removes all of the elements in <tt>T#E#Collection</tt> from the collection. * * @param collection a <code>T#E#Collection</code> value * @return true if the collection was modified by the remove all operation. */ public boolean removeAll( T#E#Collection collection ); /** * Removes all of the elements in <tt>array</tt> from the collection. * * @param array an <code>array</code> of #e# primitives. * @return true if the collection was modified by the remove all operation. */ public boolean removeAll( #e#[] array ); /** * Empties the collection. */ public void clear(); /** * Executes <tt>procedure</tt> for each element in the collection. * * @param procedure a <code>T#E#Procedure</code> value * @return false if the loop over the collection terminated because * the procedure returned false for some value. */ public boolean forEach( T#E#Procedure 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(); } // T#E#Collection |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:06
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/list Modified Files: Tag: TROVE_3_WORKING _E_List.template Log Message: TPrimitiveCollection interface Index: _E_List.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/Attic/_E_List.template,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** _E_List.template 2 Sep 2009 21:52:33 -0000 1.1.2.2 --- _E_List.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 *************** *** 27,30 **** --- 27,31 ---- import gnu.trove.function.*; import gnu.trove.procedure.*; + import gnu.trove.T#E#Collection; import java.io.Serializable; *************** *** 36,40 **** * Interface for Trove list implementations. */ ! public interface T#E#List extends Serializable { /** --- 37,41 ---- * Interface for Trove list implementations. */ ! public interface T#E#List extends T#E#Collection, Serializable { /** *************** *** 68,73 **** * * @param val an <code>#e#</code> value */ ! public void add(#e# val); --- 69,75 ---- * * @param val an <code>#e#</code> value + * @return true if the list was modified by the add operation */ ! public boolean add(#e# val); *************** *** 188,197 **** /** ! * Removes the value at <tt>offset</tt> from the list. * ! * @param offset an <code>int</code> value ! * @return the value previously stored at offset. */ ! public #e# remove( int offset ); --- 190,208 ---- /** ! * Removes <tt>value</tt> from the list. * ! * @param value an <code>#e#</code> value ! * @return true if the list was modified by the remove operation. */ ! public boolean remove( #e# value ); ! ! ! /** ! * Removes <tt>value</tt> at a given offset from the list. ! * ! * @param entry an <code>#e#</code> value ! * @return an <tt>#e#</tt> that is the value removed. ! */ ! public #e# removeAt( int offset ); |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:06
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/set/hash Modified Files: Tag: TROVE_3_WORKING _E_HashSet.template Log Message: TPrimitiveCollection interface Index: _E_HashSet.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/set/hash/Attic/_E_HashSet.template,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** _E_HashSet.template 4 Sep 2009 12:32:33 -0000 1.1.2.2 --- _E_HashSet.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 *************** *** 27,30 **** --- 27,31 ---- import gnu.trove.impl.*; import gnu.trove.impl.hash.T#E#Hash; + import gnu.trove.T#E#Collection; import java.io.IOException; *************** *** 124,128 **** * @param set a <tt>T#E#Set</tt> that will be duplicated. */ ! public T#E#HashSet( T#E#Set set ) { this( Math.max( set.size(), DEFAULT_CAPACITY ) ); if ( set instanceof T#E#HashSet ) { --- 125,129 ---- * @param set a <tt>T#E#Set</tt> that will be duplicated. */ ! public T#E#HashSet( T#E#Collection set ) { this( Math.max( set.size(), DEFAULT_CAPACITY ) ); if ( set instanceof T#E#HashSet ) { *************** *** 267,277 **** /** * 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(); --- 268,278 ---- /** * Tests the set to determine if all of the elements in ! * <tt>T#E#Collection</tt> are present. * ! * @param collection an <code>T#E#Collection</code> * @return true if all elements were present in the set. */ ! public boolean containsAll( T#E#Collection collection ) { ! T#E#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { #e# element = iter.next(); *************** *** 292,297 **** */ public boolean containsAll( #e#[] array ) { ! for ( int i = array.length; i-- > 0; ) { ! if ( ! contains(array[i]) ) { return false; } --- 293,298 ---- */ public boolean containsAll( #e#[] array ) { ! for ( int i = array.length; i-- > 0; ) { ! if ( ! contains( array[i] ) ) { return false; } *************** *** 320,331 **** /** ! * 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(); --- 321,332 ---- /** ! * Adds all of the elements in <tt>T#E#Collection</tt> to the set. * ! * @param collection an <code>T#E#Collection</code> to be added. * @return true if the set was modified by the add all operation. */ ! public boolean addAll( T#E#Collection collection ) { boolean changed = false; ! T#E#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { #e# element = iter.next(); *************** *** 380,388 **** * <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 ) { ! if ( this == set ) { return false; } --- 381,389 ---- * <tt>set</tt>. * ! * @param set a <code>T#E#Collection</code>. * @return true if the set was modified by the retain all operation */ ! public boolean retainAll( T#E#Collection collection ) { ! if ( this == collection ) { return false; } *************** *** 390,394 **** T#E#Iterator iter = iterator(); while ( iter.hasNext() ) { ! if ( ! set.contains( iter.next() ) ) { iter.remove(); modified = true; --- 391,395 ---- T#E#Iterator iter = iterator(); while ( iter.hasNext() ) { ! if ( ! collection.contains( iter.next() ) ) { iter.remove(); modified = true; *************** *** 444,453 **** * 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(); --- 445,454 ---- * Removes all of the elements in <tt>T#E#Set</tt> from the set. * ! * @param set a <code>T#E#Collection</code>. * @return true if the set was modified by the remove all operation. */ ! public boolean removeAll( T#E#Collection collection ) { boolean changed = false; ! T#E#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { #e# element = iter.next(); |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:06
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/stack/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/stack/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayStack.template Log Message: TPrimitiveCollection interface Index: _E_ArrayStack.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/stack/array/Attic/_E_ArrayStack.template,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -C2 -d -r1.1.2.8 -r1.1.2.9 *** _E_ArrayStack.template 4 Sep 2009 12:32:33 -0000 1.1.2.8 --- _E_ArrayStack.template 9 Sep 2009 01:15:54 -0000 1.1.2.9 *************** *** 124,128 **** */ public #e# pop() { ! return _list.remove( _list.size() - 1 ); } --- 124,128 ---- */ public #e# pop() { ! return _list.removeAt( _list.size() - 1 ); } *************** *** 134,138 **** */ public #e# peek() { ! return _list.get(_list.size() - 1); } --- 134,138 ---- */ public #e# peek() { ! return _list.get( _list.size() - 1 ); } |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:06
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/test/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING TPrimitiveArrayListTest.java Log Message: TPrimitiveCollection interface Index: TPrimitiveArrayListTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/list/array/Attic/TPrimitiveArrayListTest.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** TPrimitiveArrayListTest.java 4 Sep 2009 12:32:34 -0000 1.1.2.1 --- TPrimitiveArrayListTest.java 9 Sep 2009 01:15:54 -0000 1.1.2.2 *************** *** 378,382 **** for ( int i = element_count; i >= 0; i-- ) { if ( i % 2 == 1 ) { ! a.remove( i ); } } --- 378,382 ---- for ( int i = element_count; i >= 0; i-- ) { if ( i % 2 == 1 ) { ! a.removeAt( i ); } } |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:04
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/iterator/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/iterator/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayIterator.template Log Message: TPrimitiveCollection interface Index: _E_ArrayIterator.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/iterator/array/Attic/_E_ArrayIterator.template,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** _E_ArrayIterator.template 4 Sep 2009 12:32:34 -0000 1.1.2.2 --- _E_ArrayIterator.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 *************** *** 23,26 **** --- 23,27 ---- import gnu.trove.iterator.T#E#Iterator; import gnu.trove.set.hash.T#E#HashSet; + import gnu.trove.T#E#Collection; ////////////////////////////////////////////////// *************** *** 34,38 **** public class T#E#ArrayIterator implements T#E#Iterator { ! public T#E#ArrayIterator( T#E#HashSet set ) { // TODO: implement } --- 35,39 ---- public class T#E#ArrayIterator implements T#E#Iterator { ! public T#E#ArrayIterator( T#E#Collection collection ) { // TODO: implement } |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:04
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/map Modified Files: Tag: TROVE_3_WORKING _K__V_Map.template Log Message: TPrimitiveCollection interface Index: _K__V_Map.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/Attic/_K__V_Map.template,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** _K__V_Map.template 8 Sep 2009 16:26:40 -0000 1.1.2.2 --- _K__V_Map.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 *************** *** 28,31 **** --- 28,32 ---- import gnu.trove.procedure.*; import gnu.trove.set.*; + import gnu.trove.T#V#Collection; import java.util.Map; *************** *** 140,144 **** * Returns the keys of the map as a <tt>T#K#Set</tt> */ ! public T#K#Set keys(); --- 141,145 ---- * Returns the keys of the map as a <tt>T#K#Set</tt> */ ! public T#K#Set keySet(); *************** *** 146,150 **** * Returns the keys of the map. */ ! public #k#[] keysAsArray(); --- 147,151 ---- * Returns the keys of the map. */ ! public #k#[] keys(); *************** *** 156,166 **** * allocated for this purpose. */ ! public #k#[] keysAsArray( #k#[] array ); /** ! * Returns the values of the map as a <tt>T#V#Set</tt> */ ! public T#V#Set values(); --- 157,167 ---- * allocated for this purpose. */ ! public #k#[] keys( #k#[] array ); /** ! * Returns the values of the map as a <tt>T#V#Collection</tt> */ ! public T#V#Collection valueCollection(); *************** *** 168,172 **** * Returns the values of the map. */ ! public #v#[] valuesAsArray(); --- 169,173 ---- * Returns the values of the map. */ ! public #v#[] values(); *************** *** 178,182 **** * allocated for this purpose. */ ! public #v#[] valuesAsArray( #v#[] array ); --- 179,183 ---- * allocated for this purpose. */ ! public #v#[] values( #v#[] array ); |
From: Jeff R. <uph...@us...> - 2009-09-09 01:16:04
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32565/templates/gnu/trove/set Modified Files: Tag: TROVE_3_WORKING _E_Set.template Log Message: TPrimitiveCollection interface Index: _E_Set.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/set/Attic/_E_Set.template,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** _E_Set.template 4 Sep 2009 12:32:33 -0000 1.1.2.3 --- _E_Set.template 9 Sep 2009 01:15:54 -0000 1.1.2.4 *************** *** 28,31 **** --- 28,32 ---- import gnu.trove.iterator.T#E#Iterator; import gnu.trove.procedure.T#E#Procedure; + import gnu.trove.T#E#Collection; import java.util.Collection; *************** *** 43,47 **** */ ! public interface T#E#Set extends Serializable { --- 44,48 ---- */ ! public interface T#E#Set extends T#E#Collection, Serializable { *************** *** 167,176 **** /** * 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 ); --- 168,177 ---- /** * Tests the set to determine if all of the elements in ! * <tt>T#E#Collection</tt> are present. * ! * @param collection a <code>T#E#Collection</code> value * @return true if all elements were present in the set. */ ! public boolean containsAll( T#E#Collection collection ); *************** *** 195,204 **** /** ! * 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 ); --- 196,205 ---- /** ! * Adds all of the elements in the <tt>T#E#Collection</tt> to the set. * ! * @param collection a <code>T#E#Collection</code> value * @return true if the set was modified by the add all operation. */ ! public boolean addAll( T#E#Collection collection ); *************** *** 224,233 **** /** * 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 ); --- 225,234 ---- /** * Removes any values in the set which are not contained in ! * <tt>T#E#Collection</tt>. * ! * @param collection a <code>T#E#Collection</code> value * @return true if the set was modified by the retain all operation */ ! public boolean retainAll( T#E#Collection collection ); *************** *** 252,261 **** /** ! * 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 ); --- 253,262 ---- /** ! * Removes all of the elements in <tt>T#E#Collection</tt> from the set. * ! * @param collection a <code>T#E#Collection</code> value * @return true if the set was modified by the remove all operation. */ ! public boolean removeAll( T#E#Collection collection ); |
From: Jeff R. <uph...@us...> - 2009-09-08 16:26:56
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13460/templates/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING _K__V_HashMap.template Log Message: TPrimitivePrimitiveHashMap implementation and partial tests, changes required to implement it. Index: _K__V_HashMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/hash/Attic/_K__V_HashMap.template,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** _K__V_HashMap.template 24 Aug 2009 21:44:55 -0000 1.1.2.1 --- _K__V_HashMap.template 8 Sep 2009 16:26:40 -0000 1.1.2.2 *************** *** 27,33 **** 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.*; --- 27,37 ---- import gnu.trove.map.T#K##V#Map; [...1469 lines suppressed...] ! } ! } } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { ! // VERSION ! in.readByte(); ! ! // NUMBER OF ENTRIES ! int size = in.readInt(); ! setUp( size ); ! ! // ENTRIES ! while (size-- > 0) { ! #k# key = in.read#K#(); ! #v# val = in.read#V#(); ! put(key, val); ! } } } // T#K##V#HashMap |
From: Jeff R. <uph...@us...> - 2009-09-08 16:26:52
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13460/test/gnu/trove/map/hash Added Files: Tag: TROVE_3_WORKING TPrimitivePrimitiveHashMapTest.java Log Message: TPrimitivePrimitiveHashMap implementation and partial tests, changes required to implement it. --- NEW FILE: TPrimitivePrimitiveHashMapTest.java --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2006-2008, 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; //import gnu.trove.decorator.TByteIntHashMapDecorator; import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TLongArrayList; import gnu.trove.list.TIntList; import gnu.trove.list.TLongList; import gnu.trove.iterator.TIntLongIterator; import gnu.trove.iterator.TIntIterator; import gnu.trove.map.TIntLongMap; import gnu.trove.impl.hash.TPrimitiveHash; import gnu.trove.set.TIntSet; import gnu.trove.set.TLongSet; import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TLongProcedure; import gnu.trove.procedure.TIntLongProcedure; import gnu.trove.function.TLongFunction; import junit.framework.TestCase; import java.util.*; /** * */ public class TPrimitivePrimitiveHashMapTest extends TestCase { final int KEY_ONE = 100; final int KEY_TWO = 101; public TPrimitivePrimitiveHashMapTest( String name ) { super( name ); } public void testConstructors() { int[] keys = {1138, 42, 86, 99, 101}; long[] vals = {1138, 42, 86, 99, 101}; TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { map.put( keys[i], vals[i] ); } assertEquals( keys.length, map.size() ); TIntLongMap capacity = new TIntLongHashMap( 20 ); for ( int i = 0; i < keys.length; i++ ) { capacity.put( keys[i], vals[i] ); } assertEquals( keys.length, capacity.size() ); TIntLongMap cap_and_factor = new TIntLongHashMap( 20, 0.75f ); for ( int i = 0; i < keys.length; i++ ) { cap_and_factor.put( keys[i], vals[i] ); } assertEquals( keys.length, cap_and_factor.size() ); TIntLongMap fully_specified = new TIntLongHashMap( 20, 0.5f, Integer.MIN_VALUE, Long.MIN_VALUE ); for ( int i = 0; i < keys.length; i++ ) { fully_specified.put( keys[i], vals[i] ); } assertEquals( keys.length, fully_specified.size() ); TIntLongMap copy = new TIntLongHashMap( map ); assertEquals( keys.length, fully_specified.size() ); TIntLongMap arrays = new TIntLongHashMap( keys, vals ); assertEquals( keys.length, arrays.size() ); // Equals in all combinations is paranoid.. but.. assertEquals( map, map ); assertEquals( map, capacity ); assertEquals( map, cap_and_factor ); assertEquals( map, fully_specified ); assertEquals( map, copy ); assertEquals( map, arrays ); assertEquals( capacity, map ); assertEquals( capacity, capacity ); assertEquals( capacity, cap_and_factor ); assertEquals( capacity, fully_specified ); assertEquals( capacity, copy ); assertEquals( capacity, arrays ); assertEquals( cap_and_factor, map ); assertEquals( cap_and_factor, capacity ); assertEquals( cap_and_factor, cap_and_factor ); assertEquals( cap_and_factor, fully_specified ); assertEquals( cap_and_factor, copy ); assertEquals( cap_and_factor, arrays ); assertEquals( fully_specified, map ); assertEquals( fully_specified, capacity ); assertEquals( fully_specified, cap_and_factor ); assertEquals( fully_specified, fully_specified ); assertEquals( fully_specified, copy ); assertEquals( fully_specified, arrays ); assertEquals( copy, map ); assertEquals( copy, capacity ); assertEquals( copy, cap_and_factor ); assertEquals( copy, fully_specified ); assertEquals( copy, copy ); assertEquals( copy, arrays ); assertEquals( arrays, map ); assertEquals( arrays, capacity ); assertEquals( arrays, cap_and_factor ); assertEquals( arrays, fully_specified ); assertEquals( arrays, copy ); assertEquals( arrays, arrays ); } /** Be sure that size is large enough to force a resize or two. */ public void testRehash() { int size = 1000; int[] keys = new int[size]; long[] vals = new long[size]; for ( int i = 0; i < size; i++ ) { keys[i] = i + 1; vals[i] = keys[i] * 2; } TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { map.put( keys[i], vals[i] ); } assertEquals( keys.length, map.size() ); for ( int i = 0; i < keys.length; i++ ) { int key = keys[i]; long val = vals[i]; assertEquals( "got incorrect value for index " + i + ", map: " + map, val, map.get( key ) ); } } public void testPutAll() { int[] keys = {1138, 42, 86, 99, 101}; long[] vals = {1138, 42, 86, 99, 101}; TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { map.put( keys[i], vals[i] * 2 ); } assertEquals( keys.length, map.size() ); TIntLongMap target = new TIntLongHashMap(); target.put( 1, 2 ); assertEquals( 1, target.size() ); target.putAll( map ); assertEquals( keys.length + 1, target.size() ); for ( int i = 0; i < keys.length; i++ ) { assertEquals( vals[i] * 2, target.get( keys[i] ) ); } assertEquals( 2, target.get( 1 ) ); // java.util.Map source Map<Integer, Long> java_map = new HashMap<Integer, Long>(); for ( int i = 0; i < keys.length; i++ ) { java_map.put( keys[i], vals[i] * 2 ); } // fresh TIntLongMap target = new TIntLongHashMap(); target.put( 1, 2 ); assertEquals( 1, target.size() ); target.putAll( java_map ); assertEquals( "map size is incorrect: " + keys.length + ", source: " + java_map + ", target: " + target, keys.length + 1, target.size() ); for ( int i = 0; i < keys.length; i++ ) { assertEquals( vals[i] * 2, target.get( keys[i] ) ); } assertEquals( 2, target.get( 1 ) ); try { TIntLongMap bad_map = new BadMap(); target = new TIntLongHashMap(); target.putAll( bad_map ); fail( "Expected UnsupportedOperationException" ); } catch ( UnsupportedOperationException ex ) { // Expected } } public void testClear() { int[] keys = {1138, 42, 86, 99, 101}; long[] vals = {1138, 42, 86, 99, 101}; TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { map.put( keys[i], vals[i] * 2 ); } assertEquals( keys.length, map.size() ); map.clear(); assertEquals( 0, map.size() ); assertTrue( map.isEmpty() ); TIntLongMap empty = new TIntLongHashMap(); assertEquals( empty, map ); // Map<String,String> jmap = new HashMap<String, String>(); // jmap.isEmpty() } public void testRemove() { int[] keys = {1138, 42, 86, 99, 101, 727, 117}; long[] vals = new long[keys.length]; TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { vals[i] = keys[i] * 2; map.put( keys[i], vals[i] ); } assertEquals( keys.length, map.size() ); for ( int i = 0; i < keys.length; i++ ) { assertEquals( vals[i], map.get( keys[i] ) ); } assertEquals( vals[0], map.remove( keys[0] ) ); assertEquals( vals[3], map.remove( keys[3] ) ); assertEquals( map.getNoEntryValue(), map.remove( keys[0] ) ); assertEquals( vals[5], map.remove( keys[5] ) ); assertEquals( map.getNoEntryValue(), map.remove( 11010110 ) ); } public void testKeysIterator() { int[] keys = {1138, 42, 86, 99, 101, 727, 117}; long[] vals = new long[keys.length]; TIntLongMap map = new TIntLongHashMap(); for ( int i = 0; i < keys.length; i++ ) { vals[i] = keys[i] * 2; map.put( keys[i], vals[i] ); } TIntList list = new TIntArrayList( keys ); TIntSet set = map.keys(); assertEquals( map.getNoEntryValue(), set.getNoEntryValue() ); // test basic iterator function. TIntIterator iter = set.iterator(); while ( iter.hasNext() ) { int key = iter.next(); assertTrue( "key set should only contain keys: " + key + ", set; " + set, list.contains( key ) ); } assertFalse( iter.hasNext() ); try { iter.next(); fail( "Expect NoSuchElementException" ); } catch ( NoSuchElementException ex ) { // Expected. } // Start over with new iterator -- test iter.remove() iter = set.iterator(); while ( iter.hasNext() ) { int key = iter.next(); assertTrue( "key set should only contain keys: " + key + ", set; " + set, list.contains( key ) ); if ( key == keys[3] ) { iter.remove(); assertFalse( "set contains removed element: " + key + ", set: " + set, set.contains( key ) ); } } assertEquals( map.size(), set.size() ); assertEquals( keys.length - 1, map.size() ); assertEquals( map.getNoEntryValue(), map.get( keys[3] ) ); } public void testKeysAsArray() { TIntLongMap map = new TIntLongHashMap(); map.put( KEY_ONE, 1 ); map.put( KEY_TWO, 2 ); assertEquals( 2, map.size() ); int[] keys = map.keysAsArray( new int[map.size()] ); assertEquals( 2, keys.length ); TIntList keys_list = new TIntArrayList( keys ); assertTrue( keys_list.contains( KEY_ONE ) ); assertTrue( keys_list.contains( KEY_TWO ) ); int[] keys2 = map.keysAsArray(); assertEquals( 2, keys2.length ); TIntList keys_list2 = new TIntArrayList( keys2 ); assertTrue( keys_list2.contains( KEY_ONE ) ); assertTrue( keys_list2.contains( KEY_TWO ) ); } public void testValuesAsArray() { TIntLongMap map = new TIntLongHashMap(); map.put( KEY_ONE, 1 ); map.put( KEY_TWO, 2 ); assertEquals( 2, map.size() ); long[] values = map.valuesAsArray( new long[map.size()] ); assertEquals( 2, values.length ); TLongList values_list = new TLongArrayList( values ); assertTrue( values_list.contains( 1 ) ); assertTrue( values_list.contains( 2 ) ); long[] values2 = map.valuesAsArray(); assertEquals( 2, values2.length ); TLongList keys_list2 = new TLongArrayList( values2 ); assertTrue( keys_list2.contains( 1 ) ); assertTrue( keys_list2.contains( 2 ) ); } public void testDecorator() { // TByteIntHashMap map = new TByteIntHashMap(); // // map.put( KEY_ONE, 1 ); // map.put( KEY_TWO, 2 ); // // Map<Byte, Integer> decorator = new TByteIntHashMapDecorator( map ); // // assertEquals( 2, decorator.size() ); // assertEquals( Integer.valueOf( 1 ), decorator.get( Byte.valueOf( KEY_ONE ) ) ); // assertEquals( Integer.valueOf( 2 ), decorator.get( Byte.valueOf( KEY_TWO ) ) ); // // Set<Byte> decorator_keys = decorator.keySet(); // assertEquals( 2, decorator_keys.size() ); // Iterator<Byte> it = decorator_keys.iterator(); // int count = 0; // while ( it.hasNext() ) { // count++; // System.out.println( it.next() ); // } // assertEquals( 2, count ); // // assertSame( map, ( (TByteIntHashMapDecorator) decorator ).getMap() ); } public void testIterator() { TIntLongMap map = new TIntLongHashMap(); TIntLongIterator iterator = map.iterator(); assertFalse( iterator.hasNext() ); map.put( KEY_ONE, 1 ); map.put( KEY_TWO, 2 ); iterator = map.iterator(); assertTrue( iterator.hasNext() ); iterator.advance(); assertTrue( iterator.hasNext() ); iterator.advance(); assertFalse( iterator.hasNext() ); } public void testAdjustValue() { TIntLongHashMap map = new TIntLongHashMap(); map.put( KEY_ONE, 1 ); boolean changed = map.adjustValue( KEY_ONE, 1 ); assertTrue( changed ); assertEquals( 2, map.get( KEY_ONE ) ); changed = map.adjustValue( KEY_ONE, 5 ); assertTrue( changed ); assertEquals( 7, map.get( KEY_ONE ) ); changed = map.adjustValue( KEY_ONE, -3 ); assertTrue( changed ); assertEquals( 4, map.get( KEY_ONE ) ); changed = map.adjustValue( KEY_TWO, 1 ); assertFalse( changed ); assertFalse( map.containsKey( KEY_TWO ) ); } public void testAdjustOrPutValue() { TIntLongMap map = new TIntLongHashMap(); map.put( KEY_ONE, 1 ); long new_value = map.adjustOrPutValue( KEY_ONE, 1, 100 ); assertEquals( 2, new_value ); assertEquals( 2, map.get( KEY_ONE ) ); new_value = map.adjustOrPutValue( KEY_ONE, 5, 100 ); assertEquals( 7, new_value ); assertEquals( 7, map.get( KEY_ONE ) ); new_value = map.adjustOrPutValue( KEY_ONE, -3, 100 ); assertEquals( 4, new_value ); assertEquals( 4, map.get( KEY_ONE ) ); new_value = map.adjustOrPutValue( KEY_TWO, 1, 100 ); assertEquals( 100, new_value ); assertTrue( map.containsKey( KEY_TWO ) ); assertEquals( 100, map.get( KEY_TWO ) ); new_value = map.adjustOrPutValue( KEY_TWO, 1, 100 ); assertEquals( 101, new_value ); assertEquals( 101, map.get( KEY_TWO ) ); } /** * Test for tracking issue #1204014. +0.0 and -0.0 have different bit patterns, but * should be counted the same as keys in a map. Checks for doubles and floats. */ public void testFloatZeroHashing() { // TDoubleObjectHashMap<String> po_double_map = new TDoubleObjectHashMap<String>(); // TDoubleIntHashMap pp_double_map = new TDoubleIntHashMap(); // TFloatObjectHashMap<String> po_float_map = new TFloatObjectHashMap<String>(); // TFloatIntHashMap pp_float_map = new TFloatIntHashMap(); // // final double zero_double = 0.0; // final double negative_zero_double = -zero_double; // final float zero_float = 0.0f; // final float negative_zero_float = -zero_float; // // // Sanity check... make sure I'm really creating two different values. // final String zero_bits_double = // Long.toBinaryString( Double.doubleToLongBits( zero_double ) ); // final String negative_zero_bits_double = // Long.toBinaryString( Double.doubleToLongBits( negative_zero_double ) ); // assertFalse( zero_bits_double + " == " + negative_zero_bits_double, // zero_bits_double.equals( negative_zero_bits_double ) ); // // final String zero_bits_float = // Integer.toBinaryString( Float.floatToIntBits( zero_float ) ); // final String negative_zero_bits_float = // Integer.toBinaryString( Float.floatToIntBits( negative_zero_float ) ); // assertFalse( zero_bits_float + " == " + negative_zero_bits_float, // zero_bits_float.equals( negative_zero_bits_float ) ); // // // po_double_map.put( zero_double, "Zero" ); // po_double_map.put( negative_zero_double, "Negative Zero" ); // // pp_double_map.put( zero_double, 0 ); // pp_double_map.put( negative_zero_double, -1 ); // // po_float_map.put( zero_float, "Zero" ); // po_float_map.put( negative_zero_float, "Negative Zero" ); // // pp_float_map.put( zero_float, 0 ); // pp_float_map.put( negative_zero_float, -1 ); // // // assertEquals( 1, po_double_map.size() ); // assertEquals( po_double_map.get( zero_double ), "Negative Zero" ); // assertEquals( po_double_map.get( negative_zero_double ), "Negative Zero" ); // // assertEquals( 1, pp_double_map.size() ); // assertEquals( pp_double_map.get( zero_double ), -1 ); // assertEquals( pp_double_map.get( negative_zero_double ), -1 ); // // assertEquals( 1, po_float_map.size() ); // assertEquals( po_float_map.get( zero_float ), "Negative Zero" ); // assertEquals( po_float_map.get( negative_zero_float ), "Negative Zero" ); // // assertEquals( 1, pp_float_map.size() ); // assertEquals( pp_float_map.get( zero_float ), -1 ); // assertEquals( pp_float_map.get( negative_zero_float ), -1 ); // // // po_double_map.put( zero_double, "Zero" ); // pp_double_map.put( zero_double, 0 ); // po_float_map.put( zero_float, "Zero" ); // pp_float_map.put( zero_float, 0 ); // // // assertEquals( 1, po_double_map.size() ); // assertEquals( po_double_map.get( zero_double ), "Zero" ); // assertEquals( po_double_map.get( negative_zero_double ), "Zero" ); // // assertEquals( 1, pp_double_map.size() ); // assertEquals( pp_double_map.get( zero_double ), 0 ); // assertEquals( pp_double_map.get( negative_zero_double ), 0 ); // // assertEquals( 1, po_float_map.size() ); // assertEquals( po_float_map.get( zero_float ), "Zero" ); // assertEquals( po_float_map.get( negative_zero_float ), "Zero" ); // // assertEquals( 1, pp_float_map.size() ); // assertEquals( pp_float_map.get( zero_float ), 0 ); // assertEquals( pp_float_map.get( negative_zero_float ), 0 ); } public void testPutIfAbsent() { TIntLongMap map = new TIntLongHashMap(); map.put( 1, 10 ); map.put( 2, 20 ); map.put( 3, 30 ); assertEquals( 10, map.putIfAbsent( 1, 111 ) ); assertEquals( 10, map.get( 1 ) ); assertEquals( 0, map.putIfAbsent( 9, 90 ) ); assertEquals( 90, map.get( 9 ) ); } public void testBug2037709() { TIntLongMap m = new TIntLongHashMap(); for ( int i = 0; i < 10; i++ ) { m.put( i, i ); } int sz = m.size(); assertEquals( 10, sz ); int[] keys = new int[sz]; m.keysAsArray( keys ); boolean[] seen = new boolean[sz]; Arrays.fill( seen, false ); for ( int i = 0; i < 10; i++ ) { seen[keys[i]] = true; } for ( int i = 0; i < 10; i++ ) { if ( !seen[i] ) { TestCase.fail( "Missing key for: " + i ); } } } public void testToString() { TIntLongMap m = new TIntLongHashMap(); m.put( 11, 1 ); m.put( 22, 2 ); String to_string = m.toString(); assertTrue( to_string, to_string.equals( "{11=1,22=2}" ) || to_string.equals( "{22=2,11=1}" ) ); } /** a non TIntLongHashMap to test putAll exception */ class BadMap implements TIntLongMap { public int getNoEntryKey() { return 0; } public long getNoEntryValue() { return 0; } public long put( int key, long value ) { return 0; } public long putIfAbsent( int key, long value ) { return 0; } public void putAll( Map<Integer, Long> map ) {} public void putAll( TIntLongMap map ) {} public long get( int key ) { return 0; } public void clear() {} public long remove( int key ) { return 0; } public int size() { return 0; } public TIntSet keys() { return null; } public int[] keysAsArray() { return new int[0]; } public int[] keysAsArray( int[] array ) { return new int[0]; } public TLongSet values() { return null; } public long[] valuesAsArray() { return new long[0]; } public long[] valuesAsArray( long[] array ) { return new long[0]; } public boolean containsValue( long val ) { return false; } public boolean containsKey( int key ) { return false; } public TIntLongIterator iterator() { return null; } public boolean forEachKey( TIntProcedure procedure ) { return false; } public boolean forEachValue( TLongProcedure procedure ) { return false; } public boolean forEachEntry( TIntLongProcedure procedure ) { return false; } public void transformValues( TLongFunction function ) { } public boolean retainEntries( TIntLongProcedure procedure ) { return false; } public boolean increment( int key ) { return false; } public boolean adjustValue( int key, long amount ) { return false; } public long adjustOrPutValue( int key, long adjust_amount, long put_amount ) { return 0; } public boolean isEmpty() { return true; } } } |
From: Jeff R. <uph...@us...> - 2009-09-08 16:26:51
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13460/templates/gnu/trove/impl/hash Added Files: Tag: TROVE_3_WORKING _K__V_Hash.template Log Message: TPrimitivePrimitiveHashMap implementation and partial tests, changes required to implement it. --- NEW FILE: _K__V_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.*; import gnu.trove.impl.HashFunctions; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * An open addressed hashing implementation for #k#/#v# primitive entries. * * Created: Sun Nov 4 08:56:06 2001 * * @author Eric D. Friedman * @author Rob Eden * @author Jeff Randall * @version $Id: _K__V_Hash.template,v 1.1.2.1 2009/09/08 16:26:40 upholderoftruth Exp $ */ abstract public class T#K##V#Hash extends TPrimitiveHash { /** the set of #k#s */ public transient #k#[] _set; /** * key that represents null * * NOTE: should not be modified after the Hash is created, but is * not final because of Externalization * */ protected #k# no_entry_key; /** * value that represents null * * NOTE: should not be modified after the Hash is created, but is * not final because of Externalization * */ protected #v# no_entry_value; /** * Creates a new <code>T#E#Hash</code> instance with the default * capacity and load factor. */ public T#K##V#Hash() { super(); no_entry_key = ( #k# ) 0; no_entry_value = ( #v# ) 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#K##V#Hash( int initialCapacity ) { super( initialCapacity ); no_entry_key = ( #k# ) 0; no_entry_value = ( #v# ) 0; } /** * Creates a new <code>T#K##V#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#K##V#Hash( int initialCapacity, float loadFactor ) { super(initialCapacity, loadFactor); no_entry_key = ( #k# ) 0; no_entry_value = ( #v# ) 0; } /** * Creates a new <code>T#K##V#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#K##V#Hash( int initialCapacity, float loadFactor, #k# no_entry_key, #v# no_entry_value ) { super(initialCapacity, loadFactor); this.no_entry_key = no_entry_key; this.no_entry_value = no_entry_value; } /** * Returns the value that is used to represent null as a key. The default * value is generally zero, but can be changed during construction * of the collection. * * @return the value that represents null */ public #k# getNoEntryKey() { return no_entry_key; } /** * 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 #v# 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 #k#[capacity]; return capacity; } /** * Searches the set for <tt>val</tt> * * @param val an <code>#k#</code> value * @return a <code>boolean</code> value */ public boolean contains( #k# val ) { return index(val) >= 0; } /** * 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 set terminated because * the procedure returned false for some value. */ public boolean forEach( T#K#Procedure procedure ) { byte[] states = _states; #k#[] 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] = ( #k# ) no_entry_value; super.removeAt( index ); } /** * Locates the index of <tt>val</tt>. * * @param key an <code>#k#</code> value * @return the index of <tt>val</tt> or -1 if it isn't in the set. */ protected int index( #k# key ) { int hash, probe, index, length; final byte[] states = _states; final #k#[] set = _set; length = states.length; hash = HashFunctions.hash( key ) & 0x7fffffff; index = hash % length; if ( states[index] != FREE && ( states[index] == REMOVED || set[index] != key ) ) { // 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] != key ) ); } 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 key an <code>#k#</code> value * @return an <code>int</code> value */ protected int insertionIndex( #k# key ) { int hash, probe, index, length; final byte[] states = _states; final #k#[] set = _set; length = states.length; hash = HashFunctions.hash( key ) & 0x7fffffff; index = hash % length; if ( states[index] == FREE ) { return index; // empty, all done } else if ( states[index] == FULL && set[index] == key ) { 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] != key ); } // 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] != key ) ) { 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; } } } // T#K##V#Hash |
From: Jeff R. <uph...@us...> - 2009-09-08 16:26:51
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13460/templates/gnu/trove/map Modified Files: Tag: TROVE_3_WORKING _K__V_Map.template Log Message: TPrimitivePrimitiveHashMap implementation and partial tests, changes required to implement it. Index: _K__V_Map.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/Attic/_K__V_Map.template,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** _K__V_Map.template 14 Aug 2009 21:20:57 -0000 1.1.2.1 --- _K__V_Map.template 8 Sep 2009 16:26:40 -0000 1.1.2.2 *************** *** 27,31 **** --- 27,33 ---- import gnu.trove.iterator.*; import gnu.trove.procedure.*; + import gnu.trove.set.*; + import java.util.Map; import java.io.Serializable; *************** *** 35,38 **** --- 37,48 ---- */ public interface T#K##V#Map extends Serializable { + + /** + * 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 #k# getNoEntryKey(); + /** * Returns the value that will be returned from {@link #get} or {@link #put} if no *************** *** 54,57 **** --- 64,68 ---- public #v# put( #k# key, #v# value ); + /** * Inserts a key/value pair into the map if the specified key is not already *************** *** 66,69 **** --- 77,89 ---- public #v# putIfAbsent( #k# key, #v# value ); + + /** + * 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( Map<#KT#, #VT#> map ); + + /** * Put all the entries from the given map into this map. *************** *** 73,76 **** --- 93,97 ---- public void putAll( T#K##V#Map map ); + /** * Retrieves the value for <tt>key</tt> *************** *** 83,86 **** --- 104,108 ---- public #v# get( #k# key ); + /** * Empties the map. *************** *** 89,92 **** --- 111,123 ---- public void clear(); + + /** + * Returns <tt>true</tt> if this map contains no key-value mappings. + * + * @returns <tt>true</tt> if this map contains no key-value mappings + */ + public boolean isEmpty(); + + /** * Deletes a key/value pair from the map. *************** *** 101,110 **** /** ! * Returns the values of the map. */ ! public #v#[] values(); /** ! * 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, --- 132,154 ---- /** ! * Returns an <tt>int</tt> value that is the number of elements in the map. */ ! public int size(); ! /** ! * Returns the keys of the map as a <tt>T#K#Set</tt> ! */ ! public T#K#Set keys(); ! ! ! /** ! * Returns the keys of the map. ! */ ! public #k#[] keysAsArray(); ! ! ! /** ! * Returns the keys of the map. * * @param array the array into which the elements of the list are to be stored, *************** *** 112,124 **** * allocated for this purpose. */ ! public #v#[] values( #v#[] array ); /** ! * Returns the keys of the map. */ ! public #k#[] keys(); /** ! * Returns the keys of the map. * * @param array the array into which the elements of the list are to be stored, --- 156,176 ---- * allocated for this purpose. */ ! public #k#[] keysAsArray( #k#[] array ); ! /** ! * Returns the values of the map as a <tt>T#V#Set</tt> */ ! public T#V#Set values(); ! /** ! * Returns the values of the map. ! */ ! public #v#[] valuesAsArray(); ! ! ! /** ! * 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, *************** *** 126,130 **** * allocated for this purpose. */ ! public #k#[] keys( #k#[] array ); --- 178,182 ---- * allocated for this purpose. */ ! public #v#[] valuesAsArray( #v#[] array ); *************** *** 137,140 **** --- 189,193 ---- public boolean containsValue( #v# val ); + /** * Checks for the present of <tt>key</tt> in the keys of the map. *************** *** 151,154 **** --- 204,208 ---- public T#K##V#Iterator iterator(); + /** * Executes <tt>procedure</tt> for each key in the map. *************** *** 160,167 **** public boolean forEachKey( T#K#Procedure procedure ); /** * 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. --- 214,222 ---- public boolean forEachKey( T#K#Procedure procedure ); + /** * Executes <tt>procedure</tt> for each value in the map. * ! * @param procedure a <code>T#F#Procedure</code> value * @return false if the loop over the values terminated because * the procedure returned false for some value. *************** *** 169,172 **** --- 224,228 ---- public boolean forEachValue( T#V#Procedure procedure ); + /** * Executes <tt>procedure</tt> for each key/value entry in the *************** *** 179,182 **** --- 235,239 ---- public boolean forEachEntry( T#K##V#Procedure procedure ); + /** * Transform the values in this map using <tt>function</tt>. *************** *** 196,199 **** --- 253,257 ---- public boolean retainEntries( T#K##V#Procedure procedure ); + /** * Increments the primitive value mapped to key by 1 *************** *** 204,207 **** --- 262,266 ---- public boolean increment( #k# key ); + /** * Adjusts the primitive value mapped to key. *************** *** 213,216 **** --- 272,276 ---- public boolean adjustValue( #k# key, #v# amount ); + /** * Adjusts the primitive value mapped to the key if the key is present in the map. |
From: Jeff R. <uph...@us...> - 2009-09-08 16:26:51
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13460/test/gnu/trove/impl/hash Modified Files: Tag: TROVE_3_WORKING THashTest.java Log Message: TPrimitivePrimitiveHashMap implementation and partial tests, changes required to implement it. Index: THashTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/impl/hash/Attic/THashTest.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** THashTest.java 6 Sep 2009 17:02:20 -0000 1.1.2.3 --- THashTest.java 8 Sep 2009 16:26:40 -0000 1.1.2.4 *************** *** 4,7 **** --- 4,9 ---- import gnu.trove.set.hash.THashSet; import gnu.trove.map.hash.THashMap; + import gnu.trove.map.hash.TIntLongHashMap; + import gnu.trove.map.TIntLongMap; *************** *** 120,122 **** --- 122,157 ---- } + + @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) + public void testTPHashMapConstructors() { + + int cap = 20; + + THashMap cap_and_factor = new THashMap( cap, 0.75f ); + assertTrue( "capacity not sufficient: " + cap + ", " + cap_and_factor.capacity(), + cap <= cap_and_factor.capacity() ); + assertEquals( 0.75f, cap_and_factor._loadFactor ); + } + + + public void testTPrimitivePrimitveHashMapConstructors() { + + int cap = 20; + + TIntLongMap cap_and_factor = new TIntLongHashMap( cap, 0.75f ); + TPrimitiveHash cap_and_factor_hash = (TPrimitiveHash) cap_and_factor; + assertTrue( "capacity not sufficient: " + cap + ", " + cap_and_factor_hash.capacity(), + cap <= cap_and_factor_hash.capacity() ); + assertEquals( 0.75f, cap_and_factor_hash._loadFactor ); + + TIntLongMap fully_specified = + new TIntLongHashMap( cap, 0.5f, Integer.MIN_VALUE, Long.MIN_VALUE ); + TPrimitiveHash fully_specified_hash = (TPrimitiveHash) fully_specified; + assertTrue( "capacity not sufficient: " + cap + ", " + fully_specified_hash.capacity(), + cap <= fully_specified_hash.capacity() ); + assertEquals( 0.5f, fully_specified_hash._loadFactor ); + assertEquals( Integer.MIN_VALUE, fully_specified.getNoEntryKey() ); + assertEquals( Long.MIN_VALUE, fully_specified.getNoEntryValue() ); + } + } |
From: Jeff R. <uph...@us...> - 2009-09-08 16:26:51
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13460/src/gnu/trove/iterator/hash Modified Files: Tag: TROVE_3_WORKING TPrimitiveIterator.java Log Message: TPrimitivePrimitiveHashMap implementation and partial tests, changes required to implement it. Index: TPrimitiveIterator.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash/Attic/TPrimitiveIterator.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** TPrimitiveIterator.java 4 Sep 2009 12:32:34 -0000 1.1.2.1 --- TPrimitiveIterator.java 8 Sep 2009 16:26:40 -0000 1.1.2.2 *************** *** 49,53 **** * you aren't in a performance critical spot.</p> */ ! abstract class TPrimitiveIterator implements TIterator { /** the data structure this iterator traverses */ --- 49,53 ---- * you aren't in a performance critical spot.</p> */ ! public abstract class TPrimitiveIterator implements TIterator { /** the data structure this iterator traverses */ |