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-17 05:19:30
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/decorator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28003/test/gnu/trove/decorator Log Message: Directory /cvsroot/trove4j/trove/test/gnu/trove/decorator added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-16 20:58:14
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12785/templates/gnu/trove/map Modified Files: Tag: TROVE_3_WORKING _E_ObjectMap.template Object_E_Map.template Log Message: Return generic versions of the Iterators. Index: _E_ObjectMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/Attic/_E_ObjectMap.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 *** _E_ObjectMap.template 15 Sep 2009 02:38:30 -0000 1.1.2.1 --- _E_ObjectMap.template 16 Sep 2009 20:57:51 -0000 1.1.2.2 *************** *** 340,344 **** * @return a <tt>T#E#ObjectIterator</tt> with access to this map's keys and values. */ ! public T#E#ObjectIterator iterator(); --- 340,344 ---- * @return a <tt>T#E#ObjectIterator</tt> with access to this map's keys and values. */ ! public T#E#ObjectIterator<V> iterator(); Index: Object_E_Map.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/Attic/Object_E_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 *** Object_E_Map.template 14 Sep 2009 19:02:20 -0000 1.1.2.1 --- Object_E_Map.template 16 Sep 2009 20:57:51 -0000 1.1.2.2 *************** *** 345,349 **** * @return a <tt>TObject#E#Iterator</tt> with access to this map's keys and values. */ ! public TObject#E#Iterator iterator(); --- 345,349 ---- * @return a <tt>TObject#E#Iterator</tt> with access to this map's keys and values. */ ! public TObject#E#Iterator<K> iterator(); |
From: Jeff R. <uph...@us...> - 2009-09-16 15:29:28
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/decorator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7987/templates/gnu/trove/decorator Log Message: Directory /cvsroot/trove4j/trove/templates/gnu/trove/decorator added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:16
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/templates/gnu/trove/set/hash Modified Files: Tag: TROVE_3_WORKING _E_HashSet.template Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: _E_HashSet.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/set/hash/Attic/_E_HashSet.template,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** _E_HashSet.template 15 Sep 2009 02:38:30 -0000 1.1.2.5 --- _E_HashSet.template 15 Sep 2009 18:40:57 -0000 1.1.2.6 *************** *** 96,103 **** * @param no_entry_value a <code>#e#</code> value that represents null. */ - @SuppressWarnings({"RedundantCast"}) public T#E#HashSet( int initial_capacity, float load_factor, #e# no_entry_value ) { super( initial_capacity, load_factor, no_entry_value ); if ( no_entry_value != ( #e# ) 0 ) { Arrays.fill( _set, no_entry_value ); --- 96,103 ---- * @param no_entry_value a <code>#e#</code> value that represents null. */ public T#E#HashSet( int initial_capacity, float load_factor, #e# no_entry_value ) { super( initial_capacity, load_factor, no_entry_value ); + //noinspection RedundantCast if ( no_entry_value != ( #e# ) 0 ) { Arrays.fill( _set, no_entry_value ); *************** *** 122,142 **** * of the existing set. * ! * @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 ) { ! T#E#HashSet hashset = ( T#E#HashSet ) set; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } ! addAll( set ); } ! /** ! * @return a T#E#Iterator with access to the values in this set ! */ public T#E#Iterator iterator() { return new T#E#HashIterator( this ); --- 122,144 ---- * of the existing set. * ! * @param collection a <tt>T#E#Set</tt> that will be duplicated. */ ! public T#E#HashSet( T#E#Collection collection ) { ! this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); ! if ( collection instanceof T#E#HashSet ) { ! T#E#HashSet hashset = ( T#E#HashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; + //noinspection RedundantCast + if ( this.no_entry_value != ( #e# ) 0 ) { + Arrays.fill( _set, this.no_entry_value ); + } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } ! addAll( collection ); } ! /** {@inheritDoc} */ public T#E#Iterator iterator() { return new T#E#HashIterator( this ); *************** *** 144,152 **** ! /** ! * Returns a new array containing the values in the set. ! * ! * @return an <code>#e#[]</code> value ! */ public #e#[] toArray() { #e#[] result = new #e#[ size() ]; --- 146,150 ---- ! /** {@inheritDoc} */ public #e#[] toArray() { #e#[] result = new #e#[ size() ]; *************** *** 414,421 **** /** {@inheritDoc} */ public boolean equals( Object other ) { ! if (! (other instanceof T#E#HashSet)) { return false; } ! final T#E#HashSet that = ( T#E#HashSet ) other; if ( that.size() != this.size() ) { return false; --- 412,419 ---- /** {@inheritDoc} */ public boolean equals( Object other ) { ! if ( ! ( other instanceof T#E#Set ) ) { return false; } ! T#E#Set that = ( T#E#Set ) other; if ( that.size() != this.size() ) { return false; *************** *** 508,512 **** /** {@inheritDoc} */ - @SuppressWarnings({"RedundantCast"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { --- 506,509 ---- *************** *** 527,530 **** --- 524,528 ---- // NO ENTRY VALUE no_entry_value = in.read#E#(); + //noinspection RedundantCast if ( no_entry_value != ( #e# ) 0 ) { Arrays.fill( _set, no_entry_value ); |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:16
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/templates/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING Object_E_HashMap.template _E_ObjectHashMap.template _K__V_HashMap.template Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: Object_E_HashMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/hash/Attic/Object_E_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 *** Object_E_HashMap.template 14 Sep 2009 19:02:20 -0000 1.1.2.1 --- Object_E_HashMap.template 15 Sep 2009 18:40:57 -0000 1.1.2.2 *************** *** 120,124 **** public TObject#E#HashMap(int initialCapacity, float loadFactor, #e# noEntryValue) { super( initialCapacity, loadFactor ); ! this.no_entry_value = noEntryValue; } --- 120,128 ---- public TObject#E#HashMap(int initialCapacity, float loadFactor, #e# noEntryValue) { super( initialCapacity, loadFactor ); ! no_entry_value = noEntryValue; ! //noinspection RedundantCast ! if ( no_entry_value != ( #e# ) 0 ) { ! Arrays.fill( _values, no_entry_value ); ! } } *************** *** 132,135 **** --- 136,149 ---- public TObject#E#HashMap( TObject#E#Map<K> map ) { this( map.size(), 0.5f, map.getNoEntryValue() ); + if ( map instanceof TObject#E#HashMap ) { + TObject#E#HashMap hashmap = ( TObject#E#HashMap ) map; + this._loadFactor = hashmap._loadFactor; + this.no_entry_value = hashmap.no_entry_value; + //noinspection RedundantCast + if ( this.no_entry_value != ( #e# ) 0 ) { + Arrays.fill( _values, this.no_entry_value ); + } + setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); + } putAll( map ); } *************** *** 157,163 **** * @param newCapacity an <code>int</code> value */ - @SuppressWarnings({"unchecked"}) protected void rehash( int newCapacity ) { int oldCapacity = _set.length; K oldKeys[] = ( K[] ) _set; #e# oldVals[] = _values; --- 171,177 ---- * @param newCapacity an <code>int</code> value */ protected void rehash( int newCapacity ) { int oldCapacity = _set.length; + //noinspection unchecked K oldKeys[] = ( K[] ) _set; #e# oldVals[] = _values; *************** *** 166,169 **** --- 180,184 ---- Arrays.fill( _set, FREE ); _values = new #e#[newCapacity]; + Arrays.fill( _values, no_entry_value ); for ( int i = oldCapacity; i-- > 0; ) { *************** *** 234,238 **** - @SuppressWarnings({"unchecked"}) private #e# doPut( K key, #e# value, int index ) { #e# previous = no_entry_value; --- 249,252 ---- *************** *** 243,246 **** --- 257,261 ---- isNewMapping = false; } + //noinspection unchecked K oldKey = ( K ) _set[index]; _set[index] = key; *************** *** 314,326 **** /** {@inheritDoc} */ - @SuppressWarnings({"unchecked"}) public Object[] keys() { K[] keys = ( K[] ) new Object[size()]; Object[] k = _set; for ( int i = k.length, j = 0; i-- > 0; ) { ! if ( k[i] != FREE && k[i] != REMOVED ) { ! keys[j++] = ( K ) k[i]; ! } } return keys; --- 329,342 ---- /** {@inheritDoc} */ public Object[] keys() { + //noinspection unchecked K[] keys = ( K[] ) new Object[size()]; Object[] k = _set; for ( int i = k.length, j = 0; i-- > 0; ) { ! if ( k[i] != FREE && k[i] != REMOVED ) { ! //noinspection unchecked ! keys[j++] = ( K ) k[i]; ! } } return keys; *************** *** 329,336 **** /** {@inheritDoc} */ - @SuppressWarnings({"unchecked"}) public K[] keys( K[] a ) { int size = size(); if ( a.length < size ) { a = ( K[] ) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(), size ); --- 345,352 ---- /** {@inheritDoc} */ public K[] keys( K[] a ) { int size = size(); if ( a.length < size ) { + //noinspection unchecked a = ( K[] ) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(), size ); *************** *** 340,346 **** for ( int i = k.length, j = 0; i-- > 0; ) { ! if ( k[i] != FREE && k[i] != REMOVED ) { ! a[j++] = ( K ) k[i]; ! } } return a; --- 356,363 ---- for ( int i = k.length, j = 0; i-- > 0; ) { ! if ( k[i] != FREE && k[i] != REMOVED ) { ! //noinspection unchecked ! a[j++] = ( K ) k[i]; ! } } return a; *************** *** 361,367 **** for ( int i = v.length, j = 0; i-- > 0; ) { ! if ( keys[i] != FREE && keys[i] != REMOVED ) { ! vals[j++] = v[i]; ! } } return vals; --- 378,384 ---- for ( int i = v.length, j = 0; i-- > 0; ) { ! if ( keys[i] != FREE && keys[i] != REMOVED ) { ! vals[j++] = v[i]; ! } } return vals; *************** *** 380,386 **** for ( int i = v.length, j = 0; i-- > 0; ) { ! if ( keys[i] != FREE && keys[i] != REMOVED ) { ! array[j++] = v[i]; ! } } if ( array.length > size ) { --- 397,403 ---- for ( int i = v.length, j = 0; i-- > 0; ) { ! if ( keys[i] != FREE && keys[i] != REMOVED ) { ! array[j++] = v[i]; ! } } if ( array.length > size ) { *************** *** 402,405 **** --- 419,423 ---- @SuppressWarnings({"RedundantCast"}) public boolean increment( K key ) { + //noinspection RedundantCast return adjustValue( key, (#e#)1 ); } *************** *** 419,423 **** /** {@inheritDoc} */ - @SuppressWarnings({"unchecked"}) public #e# adjustOrPutValue( final K key, final #e# adjust_amount, final #e# put_amount ) { int index = insertionIndex( key ); --- 437,440 ---- *************** *** 433,437 **** } ! K oldKey = (K) _set[index]; _set[index] = key; --- 450,455 ---- } ! //noinspection unchecked ! K oldKey = ( K ) _set[index]; _set[index] = key; *************** *** 506,512 **** * @return true if the map was modified. */ - @SuppressWarnings({"unchecked"}) public boolean retainEntries( TObject#E#Procedure<K> procedure ) { boolean modified = false; K[] keys = ( K[] ) _set; #e#[] values = _values; --- 524,530 ---- * @return true if the map was modified. */ public boolean retainEntries( TObject#E#Procedure<K> procedure ) { boolean modified = false; + //noinspection unchecked K[] keys = ( K[] ) _set; #e#[] values = _values; *************** *** 557,565 **** * @return a <code>boolean</code> value */ - @SuppressWarnings({"unchecked"}) public boolean equals( Object other ) { if (! ( other instanceof TObject#E#Map ) ) { return false; } TObject#E#Map<K> that = ( TObject#E#Map<K> ) other; return ( that.size() == this.size() ) && forEachEntry( new EqProcedure<K>( that ) ); --- 575,583 ---- * @return a <code>boolean</code> value */ public boolean equals( Object other ) { if (! ( other instanceof TObject#E#Map ) ) { return false; } + //noinspection unchecked TObject#E#Map<K> that = ( TObject#E#Map<K> ) other; return ( that.size() == this.size() ) && forEachEntry( new EqProcedure<K>( that ) ); *************** *** 640,647 **** } - @SuppressWarnings({"unchecked"}) public <T> T[] toArray( T[] a ) { int size = size(); if ( a.length < size ) { a = (T[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(), size ); } --- 658,665 ---- } public <T> T[] toArray( T[] a ) { int size = size(); if ( a.length < size ) { + //noinspection unchecked a = (T[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(), size ); } *************** *** 1075,1078 **** --- 1093,1102 ---- out.writeByte( 0 ); + // SUPER + super.writeExternal( out ); + + // NO_ENTRY_VALUE + out.write#E#( no_entry_value ); + // NUMBER OF ENTRIES out.writeInt( _size ); *************** *** 1088,1092 **** - @SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { --- 1112,1115 ---- *************** *** 1095,1098 **** --- 1118,1127 ---- in.readByte(); + // SUPER + super.readExternal( in ); + + // NO_ENTRY_VALUE + no_entry_value = in.read#E#(); + // NUMBER OF ENTRIES int size = in.readInt(); *************** *** 1101,1105 **** // ENTRIES while (size-- > 0) { ! K key = (K) in.readObject(); #e# val = in.read#E#(); put(key, val); --- 1130,1135 ---- // ENTRIES while (size-- > 0) { ! //noinspection unchecked ! K key = ( K ) in.readObject(); #e# val = in.read#E#(); put(key, val); Index: _E_ObjectHashMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/hash/Attic/_E_ObjectHashMap.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 *** _E_ObjectHashMap.template 15 Sep 2009 02:38:31 -0000 1.1.2.1 --- _E_ObjectHashMap.template 15 Sep 2009 18:40:57 -0000 1.1.2.2 *************** *** 469,496 **** /** {@inheritDoc} */ - @SuppressWarnings({"unchecked"}) public boolean equals( Object other ) { ! if ( ! ( other instanceof T#E#ObjectHashMap ) ) { return false; } ! T#E#ObjectHashMap<V> that = ( T#E#ObjectHashMap<V> ) other; if ( that.size() != this.size() ) { return false; } ! V[] values = _values; ! byte[] states = _states; ! for ( int i = values.length; i-- > 0; ) { ! if ( states[i] == FULL ) { ! #e# key = _set[i]; ! int index = that.index( key ); ! if ( index < 0 ) { ! V this_value = values[i]; ! V that_value = that.get( key ); ! if ( ( this_value != that_value ) || ( this_value == null ) || ! ! this_value.equals( that_value ) ) { return false; } } } } return true; --- 469,498 ---- /** {@inheritDoc} */ public boolean equals( Object other ) { ! if ( ! ( other instanceof T#E#ObjectMap ) ) { return false; } ! T#E#ObjectMap that = ( T#E#ObjectMap ) other; if ( that.size() != this.size() ) { return false; } ! try { ! T#E#ObjectIterator iter = this.iterator(); ! while ( iter.hasNext() ) { ! iter.advance(); ! #e# key = iter.key(); ! Object value = iter.value(); ! if ( value == null ) { ! if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { ! return false; ! } ! } else { ! if ( !value.equals( that.get( key ) ) ) { return false; } } } + } catch ( ClassCastException ex ) { + // unused. } return true; *************** *** 498,501 **** --- 500,518 ---- + /** {@inheritDoc} */ + public int hashCode() { + int hashcode = 0; + V[] values = _values; + byte[] states = _states; + for ( int i = values.length; i-- > 0; ) { + if ( states[i] == FULL ) { + hashcode += HashFunctions.hash( _set[i] ) ^ + values[i].hashCode(); + } + } + return hashcode; + } + + class KeyView implements T#E#Set { *************** *** 687,690 **** --- 704,737 ---- } + /** {@inheritDoc) */ + public boolean equal( Object other ) { + if (! (other instanceof T#E#Set)) { + return false; + } + final T#E#Set that = ( T#E#Set ) other; + if ( that.size() != this.size() ) { + return false; + } + for ( int i = _states.length; i-- > 0; ) { + if ( _states[i] == FULL ) { + if ( ! that.contains( _set[i] ) ) { + return false; + } + } + } + return true; + } + + + public int hashCode() { + int hashcode = 0; + for ( int i = _states.length; i-- > 0; ) { + if ( _states[i] == FULL ) { + hashcode += HashFunctions.hash( _set[i] ); + } + } + return hashcode; + } + class T#E#HashIterator extends TPrimitiveIterator implements T#E#Iterator { *************** *** 892,914 **** - /** {@inheritDoc} */ - public int hashCode() { - int hashcode = 0; - V[] values = _values; - byte[] states = _states; - for ( int i = values.length; i-- > 0; ) { - if ( states[i] == FULL ) { - hashcode += HashFunctions.hash( _set[i] ) ^ - values[i].hashCode(); - } - } - return hashcode; - } - - public void writeExternal( ObjectOutput out ) throws IOException { // VERSION out.writeByte( 0 ); // NUMBER OF ENTRIES out.writeInt( _size ); --- 939,952 ---- public void writeExternal( ObjectOutput out ) throws IOException { // VERSION out.writeByte( 0 ); + // SUPER + super.writeExternal( out ); + + // NO_ENTRY_KEY + out.write#E#( no_entry_key ); + // NUMBER OF ENTRIES out.writeInt( _size ); *************** *** 931,934 **** --- 969,978 ---- in.readByte(); + // SUPER + super.readExternal( in ); + + // NO_ENTRY_KEY + no_entry_key = in.read#E#(); + // NUMBER OF ENTRIES int size = in.readInt(); 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.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** _K__V_HashMap.template 14 Sep 2009 19:02:20 -0000 1.1.2.5 --- _K__V_HashMap.template 15 Sep 2009 18:40:57 -0000 1.1.2.6 *************** *** 131,134 **** --- 131,149 ---- public T#K##V#HashMap( T#K##V#Map map ) { super( map.size() ); + if ( map instanceof T#K##V#HashMap ) { + T#K##V#HashMap hashmap = ( T#K##V#HashMap ) map; + this._loadFactor = hashmap._loadFactor; + this.no_entry_key = hashmap.no_entry_key; + this.no_entry_value = hashmap.no_entry_value; + //noinspection RedundantCast + if ( this.no_entry_key != ( #k# ) 0 ) { + Arrays.fill( _set, this.no_entry_key ); + } + //noinspection RedundantCast + if ( this.no_entry_value != ( #v# ) 0 ) { + Arrays.fill( _values, this.no_entry_value ); + } + setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); + } putAll( map ); } *************** *** 179,192 **** ! /** ! * Inserts a key/value pair into the map. ! * ! * @param key an <code>#k#</code> value ! * @param value an <code>#v#</code> value ! * ! * @return the previous value associated with <tt>key</tt>, or the "no entry" value ! * if none was found (see {@link #getNoEntryValue}). ! */ ! /** {@inheritDoc} */ public #v# put( #k# key, #v# value ) { int index = insertionIndex( key ); --- 194,198 ---- ! /** {@inheritDoc} */ public #v# put( #k# key, #v# value ) { int index = insertionIndex( key ); *************** *** 195,209 **** ! /** ! * Inserts a key/value pair into the map if the specified key is not already ! * associated with a value. ! * ! * @param key an <code>#k#</code> value ! * @param value an <code>#v#</code> value ! * ! * @return the previous value associated with <tt>key</tt>, or the "no entry" value ! * if none was found (see {@link #getNoEntryValue}). ! */ ! /** {@inheritDoc} */ public #v# putIfAbsent( #k# key, #v# value ) { int index = insertionIndex( key ); --- 201,205 ---- ! /** {@inheritDoc} */ public #v# putIfAbsent( #k# key, #v# value ) { int index = insertionIndex( key ); *************** *** 235,243 **** ! /** ! * 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 ) { ensureCapacity( map.size() ); --- 231,235 ---- ! /** {@inheritDoc} */ public void putAll( Map<#KT#, #VT#> map ) { ensureCapacity( map.size() ); *************** *** 249,257 **** ! /** ! * Put all the entries from the given T#K##V#Map into this map. ! * ! * @param map The map from which entries will be obtained to put into this map. ! */ public void putAll( T#K##V#Map map ) { ensureCapacity( map.size() ); --- 241,245 ---- ! /** {@inheritDoc} */ public void putAll( T#K##V#Map map ) { ensureCapacity( map.size() ); *************** *** 264,275 **** ! /** ! * Retrieves the value for <tt>key</tt> ! * ! * @param key an <code>#k#</code> value ! * ! * @return the previous value associated with <tt>key</tt>, or the "no entry" value ! * if none was found (see {@link #getNoEntryValue}). ! */ public #v# get( #k# key ) { int index = index( key ); --- 252,256 ---- ! /** {@inheritDoc} */ public #v# get( #k# key ) { int index = index( key ); *************** *** 278,285 **** ! /** ! * Empties the map. ! * ! */ public void clear() { super.clear(); --- 259,263 ---- ! /** {@inheritDoc} */ public void clear() { super.clear(); *************** *** 296,307 **** ! /** ! * Deletes a key/value pair from the map. ! * ! * @param key an <code>#k#</code> value ! * ! * @return the previous value associated with <tt>key</tt>, or the "no entry" value ! * if none was found (see {@link #getNoEntryValue}). ! */ public #v# remove( #k# key ) { #v# prev = (#v#) 0; --- 274,278 ---- ! /** {@inheritDoc} */ public #v# remove( #k# key ) { #v# prev = (#v#) 0; *************** *** 315,323 **** ! /** ! * removes the mapping at <tt>index</tt> from the map. ! * ! * @param index an <code>int</code> value ! */ public void removeAt( int index ) { _values[index] = no_entry_value; --- 286,290 ---- ! /** {@inheritDoc} */ public void removeAt( int index ) { _values[index] = no_entry_value; *************** *** 326,332 **** ! /** ! * Returns the keys of the map as a <tt>T#K#Set</tt> ! */ public T#K#Set keySet() { return new TKeyView(); --- 293,297 ---- ! /** {@inheritDoc} */ public T#K#Set keySet() { return new TKeyView(); *************** *** 334,340 **** ! /** ! * Returns the keys of the map. ! */ public #k#[] keys() { #k#[] keys = new #k#[size()]; --- 299,303 ---- ! /** {@inheritDoc} */ public #k#[] keys() { #k#[] keys = new #k#[size()]; *************** *** 351,361 **** ! /** ! * Returns the keys of the map. ! * ! * @param array the array into which the elements of the list are to be stored, ! * if it is big enough; otherwise, a new array of the same type is ! * allocated for this purpose. ! */ public #k#[] keys( #k#[] array ) { int size = size(); --- 314,318 ---- ! /** {@inheritDoc} */ public #k#[] keys( #k#[] array ) { int size = size(); *************** *** 376,382 **** ! /** ! * Returns the values of the map as a <tt>T#V#Set</tt> ! */ public T#V#Collection valueCollection() { return new TValueView(); --- 333,337 ---- ! /** {@inheritDoc} */ public T#V#Collection valueCollection() { return new TValueView(); *************** *** 384,390 **** ! /** ! * Returns the values of the map. ! */ public #v#[] values() { #v#[] vals = new #v#[size()]; --- 339,343 ---- ! /** {@inheritDoc} */ public #v#[] values() { #v#[] vals = new #v#[size()]; *************** *** 401,411 **** ! /** ! * Returns the values of the map using an existing array. ! * ! * @param array the array into which the elements of the list are to be stored, ! * if it is big enough; otherwise, a new array of the same type is ! * allocated for this purpose. ! */ public #v#[] values( #v#[] array ) { int size = size(); --- 354,358 ---- ! /** {@inheritDoc} */ public #v#[] values( #v#[] array ) { int size = size(); *************** *** 426,435 **** ! /** ! * Checks for the presence of <tt>val</tt> in the values of the map. ! * ! * @param val an <code>#v#</code> value ! * @return a <code>boolean</code> value ! */ public boolean containsValue( #v# val ) { byte[] states = _states; --- 373,377 ---- ! /** {@inheritDoc} */ public boolean containsValue( #v# val ) { byte[] states = _states; *************** *** 445,454 **** ! /** ! * Checks for the present of <tt>key</tt> in the keys of the map. ! * ! * @param key an <code>#k#</code> value ! * @return a <code>boolean</code> value ! */ public boolean containsKey( #k# key ) { return contains( key ); --- 387,391 ---- ! /** {@inheritDoc} */ public boolean containsKey( #k# key ) { return contains( key ); *************** *** 456,462 **** ! /** ! * @return a T#K##V#Iterator with access to this map's keys and values ! */ public T#K##V#Iterator iterator() { return new T#K##V#HashIterator( this ); --- 393,397 ---- ! /** {@inheritDoc} */ public T#K##V#Iterator iterator() { return new T#K##V#HashIterator( this ); *************** *** 464,474 **** ! /** ! * Executes <tt>procedure</tt> for each key in the map. ! * ! * @param procedure a <code>T#K#Procedure</code> value ! * @return false if the loop over the keys terminated because ! * the procedure returned false for some key. ! */ public boolean forEachKey( T#K#Procedure procedure ) { return forEach( procedure ); --- 399,403 ---- ! /** {@inheritDoc} */ public boolean forEachKey( T#K#Procedure procedure ) { return forEach( procedure ); *************** *** 476,486 **** ! /** ! * 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. ! */ public boolean forEachValue( T#V#Procedure procedure ) { byte[] states = _states; --- 405,409 ---- ! /** {@inheritDoc} */ public boolean forEachValue( T#V#Procedure procedure ) { byte[] states = _states; *************** *** 495,506 **** ! /** ! * Executes <tt>procedure</tt> for each key/value entry in the ! * map. ! * ! * @param procedure a <code>TO#K##V#Procedure</code> value ! * @return false if the loop over the entries terminated because ! * the procedure returned false for some entry. ! */ public boolean forEachEntry( T#K##V#Procedure procedure ) { byte[] states = _states; --- 418,422 ---- ! /** {@inheritDoc} */ public boolean forEachEntry( T#K##V#Procedure procedure ) { byte[] states = _states; *************** *** 516,524 **** ! /** ! * Transform the values in this map using <tt>function</tt>. ! * ! * @param function a <code>T#V#Function</code> value ! */ public void transformValues( T#V#Function function ) { byte[] states = _states; --- 432,436 ---- ! /** {@inheritDoc} */ public void transformValues( T#V#Function function ) { byte[] states = _states; *************** *** 532,542 **** ! /** ! * Retains only those entries in the map for which the procedure ! * returns a true value. ! * ! * @param procedure determines which entries to keep ! * @return true if the map was modified. ! */ public boolean retainEntries( T#K##V#Procedure procedure ) { boolean modified = false; --- 444,448 ---- ! /** {@inheritDoc} */ public boolean retainEntries( T#K##V#Procedure procedure ) { boolean modified = false; *************** *** 564,573 **** ! /** ! * Increments the primitive value mapped to key by 1 ! * ! * @param key the key of the value to increment ! * @return true if a mapping was found and modified. ! */ public boolean increment( #k# key ) { return adjustValue( key, ( #v# ) 1 ); --- 470,474 ---- ! /** {@inheritDoc} */ public boolean increment( #k# key ) { return adjustValue( key, ( #v# ) 1 ); *************** *** 575,585 **** ! /** ! * Adjusts the primitive value mapped to key. ! * ! * @param key the key of the value to increment ! * @param amount the amount to adjust the value by. ! * @return true if a mapping was found and modified. ! */ public boolean adjustValue( #k# key, #v# amount ) { int index = index( key ); --- 476,480 ---- ! /** {@inheritDoc} */ public boolean adjustValue( #k# key, #v# amount ) { int index = index( key ); *************** *** 593,606 **** ! /** ! * Adjusts the primitive value mapped to the key if the key is present in the map. ! * Otherwise, the <tt>initial_value</tt> is put in the map. ! * ! * @param key the key of the value to increment ! * @param adjust_amount the amount to adjust the value by ! * @param put_amount the value put into the map if the key is not initial present ! * ! * @return the value present in the map after the adjustment or put operation ! */ public #v# adjustOrPutValue( #k# key, #v# adjust_amount, #v# put_amount ) { int index = insertionIndex( key ); --- 488,492 ---- ! /** {@inheritDoc} */ public #v# adjustOrPutValue( #k# key, #v# adjust_amount, #v# put_amount ) { int index = insertionIndex( key ); *************** *** 866,870 **** @Override public boolean equals( Object other ) { ! if ( !( other instanceof T#K#Set ) ) { return false; } --- 752,756 ---- @Override public boolean equals( Object other ) { ! if (! (other instanceof T#K#Set)) { return false; } *************** *** 873,881 **** return false; } ! return forEach( new T#K#Procedure() { ! public final boolean execute( #k# key ) { ! return that.contains( key ); } ! } ); } --- 759,770 ---- return false; } ! for ( int i = _states.length; i-- > 0; ) { ! if ( _states[i] == FULL ) { ! if ( ! that.contains( _set[i] ) ) { ! return false; ! } } ! } ! return true; } *************** *** 883,902 **** @Override public int hashCode() { ! class HashProcedure implements T#K#Procedure { ! int hashcode = 0; ! ! public boolean execute( #k# key ) { ! hashcode += HashFunctions.hash( key ); ! return true; ! } ! ! public int getHashCode() { ! return hashcode; } } ! ! HashProcedure p = new HashProcedure(); ! forEachKey( p ); ! return p.getHashCode(); } --- 772,782 ---- @Override public int hashCode() { ! int hashcode = 0; ! for ( int i = _states.length; i-- > 0; ) { ! if ( _states[i] == FULL ) { ! hashcode += HashFunctions.hash( _set[i] ); } } ! return hashcode; } *************** *** 1155,1196 **** ! @Override ! public boolean equals( Object other ) { ! if ( !( other instanceof T#V#Collection ) ) { ! return false; ! } ! final T#V#Collection that = ( T#V#Collection ) other; ! if ( that.size() != this.size() ) { ! return false; ! } ! return forEach( new T#V#Procedure() { ! public final boolean execute( #v# value ) { ! return that.contains( value ); ! } ! } ); ! } ! ! ! @Override ! public int hashCode() { ! class HashProcedure implements T#V#Procedure { ! int hashcode = 0; ! ! public boolean execute( #v# value ) { ! hashcode += HashFunctions.hash( value ); ! return true; ! } ! ! public int getHashCode() { ! return hashcode; ! } ! } ! ! HashProcedure p = new HashProcedure(); ! forEachValue( p ); ! return p.getHashCode(); ! } ! ! @Override public String toString() { --- 1035,1039 ---- ! /** {@inheritDoc} */ @Override public String toString() { *************** *** 1227,1238 **** } ! ! /** ! * Provides access to the value of the mapping at the iterator's position. ! * Note that you must <tt>advance()</tt> the iterator at least once ! * before invoking this method. ! * ! * @return the value of the entry at the iterator's current position. ! */ public #k# next() { moveToNextIndex(); --- 1070,1074 ---- } ! /** {@inheritDoc} */ public #k# next() { moveToNextIndex(); *************** *** 1240,1244 **** } - /** @{inheritDoc} */ public void remove() { --- 1076,1079 ---- *************** *** 1273,1284 **** } ! ! /** ! * Provides access to the value of the mapping at the iterator's position. ! * Note that you must <tt>advance()</tt> the iterator at least once ! * before invoking this method. ! * ! * @return the value of the entry at the iterator's current position. ! */ public #v# next() { moveToNextIndex(); --- 1108,1112 ---- } ! /** {@inheritDoc} */ public #v# next() { moveToNextIndex(); *************** *** 1286,1290 **** } - /** @{inheritDoc} */ public void remove() { --- 1114,1117 ---- *************** *** 1318,1364 **** } ! ! /** ! * Moves the iterator forward to the next entry in the underlying map. ! * ! * @throws NoSuchElementException if the iterator is already exhausted ! */ public void advance() { moveToNextIndex(); } ! ! /** ! * Provides access to the key of the mapping at the iterator's position. ! * Note that you must <tt>advance()</tt> the iterator at least once ! * before invoking this method. ! * ! * @return the key of the entry at the iterator's current position. ! */ public #k# key() { return _set[_index]; } ! ! /** ! * Provides access to the value of the mapping at the iterator's position. ! * Note that you must <tt>advance()</tt> the iterator at least once ! * before invoking this method. ! * ! * @return the value of the entry at the iterator's current position. ! */ public #v# value() { return _values[_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# setValue( #v# val ) { #v# old = value(); --- 1145,1164 ---- } ! /** {@inheritDoc} */ public void advance() { moveToNextIndex(); } ! /** {@inheritDoc} */ public #k# key() { return _set[_index]; } ! /** {@inheritDoc} */ public #v# value() { return _values[_index]; } ! /** {@inheritDoc} */ public #v# setValue( #v# val ) { #v# old = value(); *************** *** 1367,1371 **** } - /** @{inheritDoc} */ public void remove() { --- 1167,1170 ---- *************** *** 1373,1377 **** throw new ConcurrentModificationException(); } - // Disable auto compaction during the remove. This is a workaround for bug 1642768. try { --- 1172,1175 ---- *************** *** 1382,1386 **** _hash.reenableAutoCompaction( false ); } - _expectedSize--; } --- 1180,1183 ---- *************** *** 1388,1465 **** ! ! ! ! ! /** ! * Compares this map with another map for equality of their stored ! * entries. ! * ! * @param other an <code>Object</code> value ! * @return a <code>boolean</code> value ! */ @Override public boolean equals( Object other ) { ! if (! ( other instanceof T#K##V#HashMap ) ) { return false; } ! T#K##V#HashMap that = ( T#K##V#HashMap ) other; if ( that.size() != this.size() ) { return false; } ! return forEachEntry( new EqProcedure( that ) ); } @Override public int hashCode() { ! HashProcedure p = new HashProcedure(); ! forEachEntry( p ); ! return p.getHashCode(); ! } ! ! ! /** T#K##V#Procedure for use in {@link #equals(Object)} */ ! private static final class EqProcedure implements T#K##V#Procedure { ! private final T#K##V#HashMap _otherMap; ! ! ! EqProcedure( T#K##V#HashMap otherMap ) { ! _otherMap = otherMap; ! } ! ! ! public boolean execute( #k# key, #v# value ) { ! int index = _otherMap.index( key ); ! if ( index >= 0 && eq( value, _otherMap.get( key ) ) ) { ! return true; } - return false; - } - - - /** - * Compare two #v#s for equality. - */ - private final boolean eq( #v# v1, #v# v2) { - return v1 == v2; - } - } - - - private final class HashProcedure implements T#K##V#Procedure { - private int h = 0; - - public int getHashCode() { - return h; - } - - public final boolean execute( #k# key, #v# value ) { - h += ( HashFunctions.hash(key) ^ HashFunctions.hash(value) ); - return true; } } @Override public String toString() { --- 1185,1234 ---- ! /** {@inheritDoc} */ @Override public boolean equals( Object other ) { ! if ( ! ( other instanceof T#K##V#Map ) ) { return false; } ! T#K##V#Map that = ( T#K##V#Map ) other; if ( that.size() != this.size() ) { return false; } ! #v#[] values = _values; ! byte[] states = _states; ! #v# this_no_entry_value = getNoEntryValue(); ! #v# that_no_entry_value = that.getNoEntryValue(); ! for ( int i = values.length; i-- > 0; ) { ! if ( states[i] == FULL ) { ! #k# key = _set[i]; ! #v# that_value = that.get( key ); ! #v# this_value = values[i]; ! if ( ( this_value != that_value ) && ! ( this_value != this_no_entry_value ) && ! ( that_value != that_no_entry_value ) ) { ! return false; ! } ! } ! } ! return true; } + /** {@inheritDoc} */ @Override public int hashCode() { ! int hashcode = 0; ! byte[] states = _states; ! for ( int i = _values.length; i-- > 0; ) { ! if ( states[i] == FULL ) { ! hashcode += HashFunctions.hash( _set[i] ) ^ ! HashFunctions.hash( _values[i] ); } } + return hashcode; } + /** {@inheritDoc} */ @Override public String toString() { *************** *** 1482,1489 **** --- 1251,1262 ---- + /** {@inheritDoc} */ public void writeExternal(ObjectOutput out) throws IOException { // VERSION out.writeByte( 0 ); + // SUPER + super.writeExternal( out ); + // NUMBER OF ENTRIES out.writeInt( _size ); *************** *** 1498,1505 **** --- 1271,1283 ---- } + + /** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION in.readByte(); + // SUPER + super.readExternal( in ); + // NUMBER OF ENTRIES int size = in.readInt(); |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:11
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/impl In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/src/gnu/trove/impl Modified Files: Tag: TROVE_3_WORKING Constants.java Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: Constants.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/impl/Attic/Constants.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** Constants.java 14 Sep 2009 19:02:20 -0000 1.1.2.4 --- Constants.java 15 Sep 2009 18:40:57 -0000 1.1.2.5 *************** *** 24,27 **** --- 24,30 ---- public class Constants { + private static final boolean VERBOSE = + System.getProperty( "gnu.trove.verbose", null ) != null; + /** the default capacity for new collections */ public static final int DEFAULT_CAPACITY = 10; *************** *** 30,61 **** public static final float DEFAULT_LOAD_FACTOR = 0.5f; - // /** flag indicating that a slot in the hashtable is available */ - // public static final byte SLOT_FREE = 0; - // - // /** flag indicating that a slot in the hashtable is occupied */ - // public static final byte SLOT_FULL = 1; - // - // /** flag indicating that the value of a slot in the hashtable was deleted */ - // public static final byte SLOT_REMOVED = 2; /** the default value that represents for <tt>byte</tt> types. */ ! public static final int DEFAULT_BYTE_NO_ENTRY_VALUE = 0; /** the default value that represents for <tt>short</tt> types. */ ! public static final int DEFAULT_SHORT_NO_ENTRY_VALUE = 0; /** the default value that represents for <tt>char</tt> types. */ ! public static final int DEFAULT_CHAR_NO_ENTRY_VALUE = 0; /** the default value that represents for <tt>int</tt> types. */ ! public static final int DEFAULT_INT_NO_ENTRY_VALUE = 0; /** the default value that represents for <tt>long</tt> types. */ ! public static final int DEFAULT_LONG_NO_ENTRY_VALUE = 0; /** the default value that represents for <tt>float</tt> types. */ ! public static final int DEFAULT_FLOAT_NO_ENTRY_VALUE = 0; /** the default value that represents for <tt>double</tt> types. */ ! public static final int DEFAULT_DOUBLE_NO_ENTRY_VALUE = 0; } --- 33,163 ---- public static final float DEFAULT_LOAD_FACTOR = 0.5f; /** the default value that represents for <tt>byte</tt> types. */ ! public static final byte DEFAULT_BYTE_NO_ENTRY_VALUE; ! static { ! byte value; ! String property = System.getProperty( "gnu.trove.no_entry.byte", "0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Byte.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Byte.MIN_VALUE; ! else value = Byte.valueOf( property ); ! ! if ( value > Byte.MAX_VALUE ) value = Byte.MAX_VALUE; ! else if ( value < Byte.MIN_VALUE ) value = Byte.MIN_VALUE; ! DEFAULT_BYTE_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_BYTE_NO_ENTRY_VALUE: " + ! DEFAULT_BYTE_NO_ENTRY_VALUE ); ! } ! } ! /** the default value that represents for <tt>short</tt> types. */ ! public static final short DEFAULT_SHORT_NO_ENTRY_VALUE; ! static { ! short value; ! String property = System.getProperty( "gnu.trove.no_entry.short", "0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Short.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Short.MIN_VALUE; ! else value = Short.valueOf( property ); ! ! if ( value > Short.MAX_VALUE ) value = Short.MAX_VALUE; ! else if ( value < Short.MIN_VALUE ) value = Short.MIN_VALUE; ! DEFAULT_SHORT_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_SHORT_NO_ENTRY_VALUE: " + ! DEFAULT_SHORT_NO_ENTRY_VALUE ); ! } ! } ! /** the default value that represents for <tt>char</tt> types. */ ! public static final char DEFAULT_CHAR_NO_ENTRY_VALUE; ! static { ! char value; ! String property = System.getProperty( "gnu.trove.no_entry.char", "\0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Character.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Character.MIN_VALUE; ! else value = property.toCharArray()[0]; ! ! if ( value > Character.MAX_VALUE ) value = Character.MAX_VALUE; ! else if ( value < Character.MIN_VALUE ) value = Character.MIN_VALUE; ! DEFAULT_CHAR_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_CHAR_NO_ENTRY_VALUE: " + ! Integer.valueOf( value ) ); ! } ! } ! /** the default value that represents for <tt>int</tt> types. */ ! public static final int DEFAULT_INT_NO_ENTRY_VALUE; ! static { ! int value; ! String property = System.getProperty( "gnu.trove.no_entry.int", "0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Integer.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Integer.MIN_VALUE; ! else value = Integer.valueOf( property ); ! DEFAULT_INT_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_INT_NO_ENTRY_VALUE: " + ! DEFAULT_INT_NO_ENTRY_VALUE ); ! } ! } ! /** the default value that represents for <tt>long</tt> types. */ ! public static final long DEFAULT_LONG_NO_ENTRY_VALUE; ! static { ! long value; ! String property = System.getProperty( "gnu.trove.no_entry.long", "0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Long.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Long.MIN_VALUE; ! else value = Long.valueOf( property ); ! DEFAULT_LONG_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_LONG_NO_ENTRY_VALUE: " + ! DEFAULT_LONG_NO_ENTRY_VALUE ); ! } ! } ! /** the default value that represents for <tt>float</tt> types. */ ! public static final float DEFAULT_FLOAT_NO_ENTRY_VALUE; ! static { ! float value; ! String property = System.getProperty( "gnu.trove.no_entry.float", "0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Float.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Float.MIN_VALUE; ! else if ( "MIN_NORMAL".equalsIgnoreCase( property ) ) value = Float.MIN_NORMAL; ! else if ( "NEGATIVE_INFINITY".equalsIgnoreCase( property ) ) value = Float.NEGATIVE_INFINITY; ! else if ( "POSITIVE_INFINITY".equalsIgnoreCase( property ) ) value = Float.POSITIVE_INFINITY; ! // else if ( "NaN".equalsIgnoreCase( property ) ) value = Float.NaN; ! else value = Float.valueOf( property ); ! DEFAULT_FLOAT_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_FLOAT_NO_ENTRY_VALUE: " + ! DEFAULT_FLOAT_NO_ENTRY_VALUE ); ! } ! } ! /** the default value that represents for <tt>double</tt> types. */ ! public static final double DEFAULT_DOUBLE_NO_ENTRY_VALUE; ! static { ! double value; ! String property = System.getProperty( "gnu.trove.no_entry.double", "0" ); ! if ( "MAX_VALUE".equalsIgnoreCase( property ) ) value = Double.MAX_VALUE; ! else if ( "MIN_VALUE".equalsIgnoreCase( property ) ) value = Double.MIN_VALUE; ! else if ( "MIN_NORMAL".equalsIgnoreCase( property ) ) value = Double.MIN_NORMAL; ! else if ( "NEGATIVE_INFINITY".equalsIgnoreCase( property ) ) value = Double.NEGATIVE_INFINITY; ! else if ( "POSITIVE_INFINITY".equalsIgnoreCase( property ) ) value = Double.POSITIVE_INFINITY; ! // else if ( "NaN".equalsIgnoreCase( property ) ) value = Double.NaN; ! else value = Double.valueOf( property ); ! DEFAULT_DOUBLE_NO_ENTRY_VALUE = value; ! if ( VERBOSE ) { ! System.out.println( "DEFAULT_DOUBLE_NO_ENTRY_VALUE: " + ! DEFAULT_DOUBLE_NO_ENTRY_VALUE ); ! } ! } } |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:10
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/templates/gnu/trove/impl/hash Modified Files: Tag: TROVE_3_WORKING _E_Hash.template _K__V_Hash.template Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: _E_Hash.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash/Attic/_E_Hash.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_Hash.template 4 Sep 2009 12:32:33 -0000 1.1.2.2 --- _E_Hash.template 15 Sep 2009 18:40:57 -0000 1.1.2.3 *************** *** 23,26 **** --- 23,29 ---- import gnu.trove.procedure.T#E#Procedure; import gnu.trove.impl.HashFunctions; + import gnu.trove.impl.Constants; + + import java.util.Arrays; ////////////////////////////////////////////////// *************** *** 58,62 **** public T#E#Hash() { super(); ! no_entry_value = ( #e# ) 0; } --- 61,69 ---- public T#E#Hash() { super(); ! no_entry_value = Constants.DEFAULT_#EC#_NO_ENTRY_VALUE; ! //noinspection RedundantCast ! if ( no_entry_value != ( #e# ) 0 ) { ! Arrays.fill( _set, no_entry_value ); ! } } *************** *** 71,75 **** public T#E#Hash( int initialCapacity ) { super( initialCapacity ); ! no_entry_value = ( #e# ) 0; } --- 78,86 ---- public T#E#Hash( int initialCapacity ) { super( initialCapacity ); ! no_entry_value = Constants.DEFAULT_#EC#_NO_ENTRY_VALUE; ! //noinspection RedundantCast ! if ( no_entry_value != ( #e# ) 0 ) { ! Arrays.fill( _set, no_entry_value ); ! } } *************** *** 85,89 **** public T#E#Hash( int initialCapacity, float loadFactor ) { super(initialCapacity, loadFactor); ! no_entry_value = ( #e# ) 0; } --- 96,104 ---- public T#E#Hash( int initialCapacity, float loadFactor ) { super(initialCapacity, loadFactor); ! no_entry_value = Constants.DEFAULT_#EC#_NO_ENTRY_VALUE; ! //noinspection RedundantCast ! if ( no_entry_value != ( #e# ) 0 ) { ! Arrays.fill( _set, no_entry_value ); ! } } *************** *** 101,104 **** --- 116,123 ---- super(initialCapacity, loadFactor); this.no_entry_value = no_entry_value; + //noinspection RedundantCast + if ( no_entry_value != ( #e# ) 0 ) { + Arrays.fill( _set, no_entry_value ); + } } Index: _K__V_Hash.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash/Attic/_K__V_Hash.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_Hash.template 11 Sep 2009 22:20:48 -0000 1.1.2.2 --- _K__V_Hash.template 15 Sep 2009 18:40:57 -0000 1.1.2.3 *************** *** 24,27 **** --- 24,32 ---- import gnu.trove.impl.HashFunctions; + import java.io.ObjectOutput; + import java.io.ObjectInput; + import java.io.IOException; + + ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // *************** *** 302,304 **** --- 307,341 ---- } } + + + /** {@inheritDoc} */ + public void writeExternal( ObjectOutput out ) throws IOException { + // VERSION + out.writeByte( 0 ); + + // SUPER + super.writeExternal( out ); + + // NO_ENTRY_KEY + out.write#K#( no_entry_key ); + + // NO_ENTRY_VALUE + out.write#V#( no_entry_value ); + } + + + /** {@inheritDoc} */ + public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { + // VERSION + in.readByte(); + + // SUPER + super.readExternal( in ); + + // NO_ENTRY_KEY + no_entry_key = in.read#K#(); + + // NO_ENTRY_VALUE + no_entry_value = in.read#V#(); + } } // T#K##V#Hash |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:10
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/test/gnu/trove/impl/hash Modified Files: Tag: TROVE_3_WORKING THashTest.java Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: THashTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/impl/hash/Attic/THashTest.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** THashTest.java 8 Sep 2009 16:26:40 -0000 1.1.2.4 --- THashTest.java 15 Sep 2009 18:40:57 -0000 1.1.2.5 *************** *** 5,9 **** --- 5,18 ---- import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntLongHashMap; + import gnu.trove.map.hash.TIntObjectHashMap; + import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.map.TIntLongMap; + import gnu.trove.map.TIntObjectMap; + import gnu.trove.map.TObjectIntMap; + + import java.io.ByteArrayOutputStream; + import java.io.ObjectOutputStream; + import java.io.ByteArrayInputStream; + import java.io.ObjectInputStream; *************** *** 155,157 **** --- 164,258 ---- } + + // test all the way up the chain to THash + public void testTPrimitivePrimitveHashMapSerialize() throws Exception { + int[] keys = {1138, 42, 86, 99, 101, 727, 117}; + long[] vals = new long[keys.length]; + + TIntLongMap original_map = + new TIntLongHashMap( 200, 0.75f, Integer.MIN_VALUE, Long.MIN_VALUE ); + for ( int i = 0; i < keys.length; i++ ) { + vals[i] = keys[i] * 2; + original_map.put( keys[i], vals[i] ); + } + + THash original_hash = ( THash ) original_map; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream( baos ); + oos.writeObject( original_map ); + + ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() ); + ObjectInputStream ois = new ObjectInputStream( bias ); + + TIntLongMap deserialized_map = ( TIntLongMap ) ois.readObject(); + THash deserialized_hash = ( THash ) deserialized_map; + + assertEquals( original_map, deserialized_map ); + assertEquals( original_map.getNoEntryKey(), deserialized_map.getNoEntryKey() ); + assertEquals( original_map.getNoEntryValue(), deserialized_map.getNoEntryValue() ); + assertEquals( original_hash._loadFactor, deserialized_hash._loadFactor ); + } + + + // test all the way up the chain to THash + public void testTPrimitiveObjectHashMapSerialize() throws Exception { + int[] keys = {1138, 42, 86, 99, 101, 727, 117}; + String[] vals = new String[keys.length]; + + TIntObjectMap<String> original_map = + new TIntObjectHashMap<String>( 200, 0.75f, Integer.MIN_VALUE ); + for ( int i = 0; i < keys.length; i++ ) { + vals[i] = String.valueOf( keys[i] * 2 ); + original_map.put( keys[i], vals[i] ); + } + + THash original_hash = ( THash ) original_map; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream( baos ); + oos.writeObject( original_map ); + + ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() ); + ObjectInputStream ois = new ObjectInputStream( bias ); + + TIntObjectMap deserialized_map = ( TIntObjectMap ) ois.readObject(); + THash deserialized_hash = ( THash ) deserialized_map; + + assertEquals( original_map, deserialized_map ); + assertEquals( original_map.getNoEntryKey(), deserialized_map.getNoEntryKey() ); + assertEquals( original_hash._loadFactor, deserialized_hash._loadFactor ); + } + + + // test all the way up the chain to THash + public void testTObjectPrimitiveHashMapSerialize() throws Exception { + int[] vals = {1138, 42, 86, 99, 101, 727, 117}; + String[] keys = new String[vals.length]; + + + TObjectIntMap<String> original_map = + new TObjectIntHashMap<String>( 200, 0.75f, Integer.MIN_VALUE ); + for ( int i = 0; i < keys.length; i++ ) { + keys[i] = String.valueOf( vals[i] * 2 ); + original_map.put( keys[i], vals[i] ); + } + + THash original_hash = ( THash ) original_map; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream( baos ); + oos.writeObject( original_map ); + + ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() ); + ObjectInputStream ois = new ObjectInputStream( bias ); + + TObjectIntMap deserialized_map = ( TObjectIntMap ) ois.readObject(); + THash deserialized_hash = ( THash ) deserialized_map; + + assertEquals( original_map, deserialized_map ); + assertEquals( original_map.getNoEntryValue(), deserialized_map.getNoEntryValue() ); + assertEquals( original_hash._loadFactor, deserialized_hash._loadFactor ); + } + } |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:10
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/test/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING TPrimitivePrimitiveHashMapTest.java Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: TPrimitivePrimitiveHashMapTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/map/hash/Attic/TPrimitivePrimitiveHashMapTest.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 *** TPrimitivePrimitiveHashMapTest.java 11 Sep 2009 22:20:48 -0000 1.1.2.3 --- TPrimitivePrimitiveHashMapTest.java 15 Sep 2009 18:40:57 -0000 1.1.2.4 *************** *** 1292,1316 **** assertEquals( map.size(), values.size() ); assertFalse( values.isEmpty() ); ! TLongCollection other = new TLongHashSet(); ! other.addAll( vals ); - assertTrue( "collections incorrectly not equal: " + values + ", " + other, - values.equals( other ) ); long[] mismatched = {72, 49, 53, 1024, 999}; ! TLongCollection unequal = new TLongHashSet(); unequal.addAll( mismatched ); ! assertFalse( "collections incorrectly equal: " + values + ", " + unequal, ! values.equals( unequal ) ); // Change length, different code branch unequal.add( 1 ); ! assertFalse( "collections incorrectly equal: " + values + ", " + unequal, ! values.equals( unequal ) ); assertFalse( "values incorrectly equals a random object", ! values.equals( new Object() ) ); } --- 1292,1340 ---- assertEquals( map.size(), values.size() ); assertFalse( values.isEmpty() ); + assertEquals( values, values ); + TLongList values_list = new TLongArrayList( values ); + assertFalse( "collections should not be equal: " + values + ", " + values_list, + values.equals( values_list ) ); ! TLongList list = new TLongArrayList( vals ); ! values_list.sort(); ! list.sort(); ! assertTrue( "collections incorrectly not equal: " + values_list + ", " + list, ! values_list.equals( list ) ); ! assertTrue( "collections incorrectly not equal: " + values_list + ", " + list, ! values_list.equals( list ) ); long[] mismatched = {72, 49, 53, 1024, 999}; ! TLongCollection unequal = new TLongArrayList(); unequal.addAll( mismatched ); ! assertFalse( "collections incorrectly equal: " + values_list + ", " + unequal, ! values_list.equals( unequal ) ); // Change length, different code branch unequal.add( 1 ); ! assertFalse( "collections incorrectly equal: " + values_list + ", " + unequal, ! values_list.equals( unequal ) ); assertFalse( "values incorrectly equals a random object", ! values_list.equals( new Object() ) ); ! ! // value in map twice, in list twice. ! list = new TLongArrayList( vals ); ! map.put( 1, vals[0] ); ! values_list = new TLongArrayList( map.valueCollection() ); ! list.add( vals[0] ); ! values_list.sort(); ! list.sort(); ! assertTrue( "collections incorrectly not equal: " + values_list + ", " + list, ! values_list.equals( list ) ); ! ! // value in the map twice, same length list, but value only in list once. ! list = new TLongArrayList( vals ); ! list.add( -1 ); ! list.sort(); ! assertFalse( "collections incorrectly equal: " + values_list + ", " + list, ! values_list.equals( list ) ); } *************** *** 1329,1346 **** assertEquals( map.size(), values.size() ); assertFalse( values.isEmpty() ); ! ! ! TLongCollection other = new TLongHashSet(); ! other.addAll( vals ); ! ! assertTrue( "hashcodes incorrectly not equal: " + values + ", " + other, ! values.hashCode() == other.hashCode() ); ! ! long[] mismatched = {72, 49, 53, 1024, 999}; ! TLongCollection unequal = new TLongHashSet(); ! unequal.addAll( mismatched ); ! ! assertFalse( "hashcodes unlikely equal: " + values + ", " + unequal, ! values.hashCode() == unequal.hashCode() ); } --- 1353,1360 ---- assertEquals( map.size(), values.size() ); assertFalse( values.isEmpty() ); ! assertEquals( "hashcodes incorrectly not equal: " + map + ", " + values, ! values.hashCode(), values.hashCode() ); ! assertFalse( "hashcodes incorrectly equal: " + map + ", " + values, ! map.hashCode() == values.hashCode() ); } |
From: Jeff R. <uph...@us...> - 2009-09-15 18:41:08
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9798/src/gnu/trove/impl/hash Modified Files: Tag: TROVE_3_WORKING TObjectHash.java Log Message: Harmonize equals()/hashcode() for the collections and views. Call super for externalization for classes that extend other classes. Copy consutrctors copy more internals (load factor, no_entry value/key, etc) and add System properties to set default no_entry_value/key to be used. Index: TObjectHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/impl/hash/Attic/TObjectHash.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 *** TObjectHash.java 9 Sep 2009 06:24:06 -0000 1.1.2.3 --- TObjectHash.java 15 Sep 2009 18:40:57 -0000 1.1.2.4 *************** *** 286,294 **** @Override public void writeExternal( ObjectOutput out ) throws IOException { - super.writeExternal( out ); // VERSION out.writeByte( 0 ); } --- 286,295 ---- @Override public void writeExternal( ObjectOutput out ) throws IOException { // VERSION out.writeByte( 0 ); + // SUPER + super.writeExternal( out ); } *************** *** 298,306 **** throws IOException, ClassNotFoundException { - super.readExternal( in ); - // VERSION in.readByte(); } } // TObjectHash --- 299,307 ---- throws IOException, ClassNotFoundException { // VERSION in.readByte(); + // SUPER + super.readExternal( in ); } } // TObjectHash |
From: Rob E. <ro...@us...> - 2009-09-15 04:01:43
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/benchmark In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14781/trove/test/gnu/trove/benchmark Added Files: Tag: TROVE_3_WORKING BenchmarkSet.java Benchmark.java BenchmarkRunner.java Log Message: Beginnings of new benchmarks --- NEW FILE: BenchmarkSet.java --- /* * /////////////////////////////////////////////////////////////////////////////// * // Copyright (c) 2009, Rob Eden All Rights Reserved. * // * // This library is free software; you can redistribute it and/or * // modify it under the terms of the GNU Lesser General Public * // License as published by the Free Software Foundation; either * // version 2.1 of the License, or (at your option) any later version. * // * // This library is distributed in the hope that it will be useful, * // but WITHOUT ANY WARRANTY; without even the implied warranty of * // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * // GNU General Public License for more details. * // * // You should have received a copy of the GNU Lesser General Public * // License along with this program; if not, write to the Free Software * // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * /////////////////////////////////////////////////////////////////////////////// */ package gnu.trove.benchmark; /** * */ abstract class BenchmarkSet implements Benchmark { private final String name; private final Benchmark[] cases; BenchmarkSet( String name, Benchmark... cases ) { this.name = name; this.cases = cases; } public void setUp() { //noinspection ForLoopReplaceableByForEach for( int i = 0; i < cases.length; i++ ) { cases[ i ].setUp(); } } public void tearDown() { //noinspection ForLoopReplaceableByForEach for( int i = 0; i < cases.length; i++ ) { cases[ i ].tearDown(); } } public String getName() { return name; } public void run() { // TODO: implement } } --- NEW FILE: Benchmark.java --- /* * /////////////////////////////////////////////////////////////////////////////// * // Copyright (c) 2009, Rob Eden All Rights Reserved. * // * // This library is free software; you can redistribute it and/or * // modify it under the terms of the GNU Lesser General Public * // License as published by the Free Software Foundation; either * // version 2.1 of the License, or (at your option) any later version. * // * // This library is distributed in the hope that it will be useful, * // but WITHOUT ANY WARRANTY; without even the implied warranty of * // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * // GNU General Public License for more details. * // * // You should have received a copy of the GNU Lesser General Public * // License along with this program; if not, write to the Free Software * // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * /////////////////////////////////////////////////////////////////////////////// */ package gnu.trove.benchmark; /** * */ interface Benchmark extends Runnable { public void setUp(); public void tearDown(); public String getName(); } --- NEW FILE: BenchmarkRunner.java --- /* * /////////////////////////////////////////////////////////////////////////////// * // Copyright (c) 2009, Rob Eden All Rights Reserved. * // * // This library is free software; you can redistribute it and/or * // modify it under the terms of the GNU Lesser General Public * // License as published by the Free Software Foundation; either * // version 2.1 of the License, or (at your option) any later version. * // * // This library is distributed in the hope that it will be useful, * // but WITHOUT ANY WARRANTY; without even the implied warranty of * // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * // GNU General Public License for more details. * // * // You should have received a copy of the GNU Lesser General Public * // License along with this program; if not, write to the Free Software * // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * /////////////////////////////////////////////////////////////////////////////// */ package gnu.trove.benchmark; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.util.List; /** * */ class BenchmarkRunner { private static final Benchmark[] CASES = {}; public static void main( String[] args ) { List<GarbageCollectorMXBean> collectors = ManagementFactory.getGarbageCollectorMXBeans(); } private static CollectionInfo getGCTime( List<GarbageCollectorMXBean> collectors, CollectionInfo since_info ) { long count = 0; long time = 0; //noinspection ForLoopReplaceableByForEach for( int i = 0; i < collectors.size(); i++ ) { GarbageCollectorMXBean bean = collectors.get( i ); count += bean.getCollectionCount(); time += bean.getCollectionTime(); } if ( since_info == null ) return new CollectionInfo( count, time ); else return new CollectionInfo( since_info, count, time ); } private static class CollectionInfo { private long count; private long time; CollectionInfo( long count, long time ) { this.count = count; this.time = time; } CollectionInfo( CollectionInfo start, long end_count, long end_time ) { this.count = end_count - start.count; this.time = end_time - start.time; } } } |
From: Rob E. <ro...@us...> - 2009-09-15 03:08:18
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/benchmark In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5433/trove/test/gnu/trove/benchmark Log Message: Directory /cvsroot/trove4j/trove/test/gnu/trove/benchmark added to the repository |
From: Jeff R. <uph...@us...> - 2009-09-15 02:39:43
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/impl In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32760/src/gnu/trove/impl Added Files: Tag: TROVE_3_WORKING DualPivotQuicksort.java Log Message: DualPivotQuicksort implementation -- faster array sorting --- NEW FILE: DualPivotQuicksort.java --- package gnu.trove.impl; /* * @author Vladimir Yaroslavskiy * @version 2009.09.10 m765 */ public class DualPivotQuicksort { public static void sort(int[] a) { sort(a, 0, a.length); } public static void sort(int[] a, int fromIndex, int toIndex) { rangeCheck(a.length, fromIndex, toIndex); dualPivotQuicksort(a, fromIndex, toIndex - 1, 3); } private static void rangeCheck(int length, int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); } if (fromIndex < 0) { throw new ArrayIndexOutOfBoundsException(fromIndex); } if (toIndex > length) { throw new ArrayIndexOutOfBoundsException(toIndex); } } private static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } private static void dualPivotQuicksort(int[] a, int left, int right, int div) { int len = right - left; if (len < 27) { // insertion sort for tiny array for (int i = left + 1; i <= right; i++) { for (int j = i; j > left && a[j] < a[j - 1]; j--) { swap(a, j, j - 1); } } return; } int third = len / div; // "medians" int m1 = left + third; int m2 = right - third; if (m1 <= left) { m1 = left + 1; } if (m2 >= right) { m2 = right - 1; } if (a[m1] < a[m2]) { swap(a, m1, left); swap(a, m2, right); } else { swap(a, m1, right); swap(a, m2, left); } // pivots int pivot1 = a[left]; int pivot2 = a[right]; // pointers int less = left + 1; int great = right - 1; // sorting for (int k = less; k <= great; k++) { if (a[k] < pivot1) { swap(a, k, less++); } else if (a[k] > pivot2) { while (k < great && a[great] > pivot2) { great--; } swap(a, k, great--); if (a[k] < pivot1) { swap(a, k, less++); } } } // swaps int dist = great - less; if (dist < 13) { div++; } swap(a, less - 1, left); swap(a, great + 1, right); // subarrays dualPivotQuicksort(a, left, less - 2, div); dualPivotQuicksort(a, great + 2, right, div); // equal elements if (dist > len - 13 && pivot1 != pivot2) { for (int k = less; k <= great; k++) { if (a[k] == pivot1) { swap(a, k, less++); } else if (a[k] == pivot2) { swap(a, k, great--); if (a[k] == pivot1) { swap(a, k, less++); } } } } // subarray if (pivot1 < pivot2) { dualPivotQuicksort(a, less, great, div); } } } |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:49
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/test/gnu/trove/map/hash Added Files: Tag: TROVE_3_WORKING TPrimitiveObjectHashMapTest.java Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet --- NEW FILE: TPrimitiveObjectHashMapTest.java --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001-2006, Eric D. Friedman All Rights Reserved. // Copyright (c) 2009, Rob Eden All Rights Reserved. // Copyright (c) 2009, Jeff Randall All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// [...1337 lines suppressed...] // // Map<String,Integer> decorator = new TObjectIntHashMapDecorator<String>( map ); // // assertEquals( 2, decorator.size() ); // assertEquals( Integer.valueOf( 1 ), decorator.get( "one" ) ); // assertEquals( Integer.valueOf( 2 ), decorator.get( "two" ) ); // // Set<String> decorator_keys = decorator.keySet(); // assertEquals( 2, decorator_keys.size() ); // Iterator<String> it = decorator_keys.iterator(); // int count = 0; // while( it.hasNext() ) { // count++; // System.out.println(it.next()); // } // assertEquals( 2, count ); // // assertSame(map, ( ( TObjectIntHashMapDecorator ) decorator ).getMap() ); } } |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:44
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove/map Added Files: Tag: TROVE_3_WORKING _E_ObjectMap.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet --- NEW FILE: _E_ObjectMap.template --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // Copyright (c) 2009, Rob Eden All Rights Reserved. // Copyright (c) 2009, Jeff Randall All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove.map; import gnu.trove.iterator.T#E#ObjectIterator; import gnu.trove.procedure.T#E#Procedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.procedure.T#E#ObjectProcedure; import gnu.trove.function.TObjectFunction; import gnu.trove.set.T#E#Set; import java.util.Collection; import java.util.Map; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * Interface for a primitive map of #e# keys and Object values. */ public interface T#E#ObjectMap<V> { // Query Operations /** * Returns the value that represents null in the {@link keySet()}. * The default value is generally zero, but can be changed during * construction of the collection. * * @return the value that represents a null value in this collection. */ #e# getNoEntryKey(); /** * Returns the number of key-value mappings in this map. If the * map contains more than <tt>Integer.MAX_VALUE</tt> elements, returns * <tt>Integer.MAX_VALUE</tt>. * * @return the number of key-value mappings in this map */ int size(); /** * Returns <tt>true</tt> if this map contains no key-value mappings. * * @return <tt>true</tt> if this map contains no key-value mappings */ boolean isEmpty(); /** * Returns <tt>true</tt> if this map contains a mapping for the specified * key. More formally, returns <tt>true</tt> if and only if * this map contains a mapping for a key <tt>k</tt> such that * <tt>key.equals(k)</tt>. (There can be at most one such mapping.) * * @param key key whose presence in this map is to be tested * @return <tt>true</tt> if this map contains a mapping for the specified * key * @throws ClassCastException if the key is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified key is null and this map * does not permit null keys (optional) */ boolean containsKey( #e# key ); /** * Returns <tt>true</tt> if this map maps one or more keys to the * specified value. More formally, returns <tt>true</tt> if and only if * this map contains at least one mapping to a value <tt>v</tt> such that * <tt>(value==null ? v==null : value.equals(v))</tt>. This operation * will probably require time linear in the map size for most * implementations of the <tt>Map</tt> interface. * * @param value value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the * specified value * @throws ClassCastException if the value is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified value is null and this * map does not permit null values (optional) */ boolean containsValue( Object value ); /** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * * <p>More formally, if this map contains a mapping from a key * {@code k} to a value {@code v} such that {@code (key==null ? k==null : * key.equals(k))}, then this method returns {@code v}; otherwise * it returns {@code null}. (There can be at most one such mapping.) * * <p>If this map permits null values, then a return value of * {@code null} does not <i>necessarily</i> indicate that the map * contains no mapping for the key; it's also possible that the map * explicitly maps the key to {@code null}. The {@link #containsKey * containsKey} operation may be used to distinguish these two cases. * * @param key the key whose associated value is to be returned * @return the <tt>#e#</tt> value to which the specified key is mapped, or * {@code null} if this map contains no mapping for the key * @throws ClassCastException if the key is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified key is null and this map * does not permit null keys (optional) */ V get( #e# key ); // Modification Operations /** * Associates the specified value with the specified key in this map * (optional operation). If the map previously contained a mapping for * the key, the old value is replaced by the specified value. (A map * <tt>m</tt> is said to contain a mapping for a key <tt>k</tt> if and only * if {@link #containsKey(Object) m.containsKey(k)} would return * <tt>true</tt>.) * * @param key key with which the specified value is to be associated * @param value an <tt>#e#</tt> value value to be associated with the specified key * @return the previous value associated with <tt>key</tt>, or * <tt>no_entry_value</tt> if there was no mapping for <tt>key</tt>. * (A <tt>no_entry_value</tt> return can also indicate that the map * previously associated <tt>null</tt> with <tt>key</tt>, * if the implementation supports <tt>null</tt> values.) * @throws UnsupportedOperationException if the <tt>put</tt> operation * is not supported by this map * @throws ClassCastException if the class of the specified key or value * prevents it from being stored in this map * @throws NullPointerException if the specified key or value is null * and this map does not permit null keys or values * @throws IllegalArgumentException if some property of the specified key * or value prevents it from being stored in this map * @see #getNoEntryValue(); */ V put( #e# key, V value); /** * Inserts a key/value pair into the map if the specified key is not already * associated with a value. * * @param key key with which the specified value is to be associated * @param value an <tt>#e#</tt> value to be associated with the specified key * * @return the previous value associated with <tt>key</tt>, or the "no entry" value * if none was found (see {@link #getNoEntryValue}). */ V putIfAbsent( #e# key, V value ); /** * Removes the mapping for a key from this map if it is present * (optional operation). More formally, if this map contains a mapping * from key <tt>k</tt> to value <tt>v</tt> such that * <code>key.equals(k)</code>, that mapping * is removed. (The map can contain at most one such mapping.) * * <p>Returns the value to which this map previously associated the key, * or <tt>null</tt> if the map contained no mapping for the key. * * <p>If this map permits null values, then a return value of * <tt>null</tt> does not <i>necessarily</i> indicate that the map * contained no mapping for the key; it's also possible that the map * explicitly mapped the key to <tt>null</tt>. * * <p>The map will not contain a mapping for the specified key once the * call returns. * * @param key key whose mapping is to be removed from the map * @return the previous <tt>#e#</tt> value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt>. * @throws UnsupportedOperationException if the <tt>remove</tt> operation * is not supported by this map * @throws ClassCastException if the key is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified key is null and this * map does not permit null keys (optional) */ V remove( #e# key ); // Bulk Operations /** * Copies all of the mappings from the specified map to this map * (optional operation). The effect of this call is equivalent to that * of calling {@link #put(Object,Object) put(k, v)} on this map once * for each mapping from key <tt>k</tt> to value <tt>v</tt> in the * specified map. The behavior of this operation is undefined if the * specified map is modified while the operation is in progress. * * @param m mappings to be stored in this map * @throws UnsupportedOperationException if the <tt>putAll</tt> operation * is not supported by this map * @throws ClassCastException if the class of a key or value in the * specified map prevents it from being stored in this map * @throws NullPointerException if the specified map is null, or if * this map does not permit null keys or values, and the * specified map contains null keys or values * @throws IllegalArgumentException if some property of a key or value in * the specified map prevents it from being stored in this map */ void putAll( Map<? extends #ET#, ? extends V> m); /** * Put all the entries from the given map into this map. * * @param map The map from which entries will be obtained to put into this map. */ void putAll( T#E#ObjectMap<V> map ); /** * Removes all of the mappings from this map (optional operation). * The map will be empty after this call returns. * * @throws UnsupportedOperationException if the <tt>clear</tt> operation * is not supported by this map */ void clear(); // Views /** * Returns a {@link Set} view of the keys contained in this map. * The set is backed by the map, so changes to the map are * reflected in the set, and vice-versa. If the map is modified * while an iteration over the set is in progress (except through * the iterator's own <tt>remove</tt> operation), the results of * the iteration are undefined. The set supports element removal, * which removes the corresponding mapping from the map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> * operations. It does not support the <tt>add</tt> or <tt>addAll</tt> * operations. * * @return a set view of the keys contained in this map */ T#E#Set keySet(); /** * Returns a copy of the keys of the map as an array. * Changes to the array of keys will not be reflected in the map * nor vice-versa. * * @return a copy of the keys of the map as an array. */ #e#[] keys(); /** * Returns a copy of the keys of the map as an array. * Changes to the array of keys will not be reflected in the map * nor vice-versa. * * @param array the array into which the elements of the list are to be stored, * if it is big enough; otherwise, a new array of the same type is * allocated for this purpose. * @return the keys of the map as an array. */ #e#[] keys( #e#[] array ); /** * Returns a {@link Collection} view of the values contained in this map. * The collection is backed by the map, so changes to the map are * reflected in the collection, and vice-versa. If the map is * modified while an iteration over the collection is in progress * (except through the iterator's own <tt>remove</tt> operation), * the results of the iteration are undefined. The collection * supports element removal, which removes the corresponding * mapping from the map, via the <tt>Iterator.remove</tt>, * <tt>Collection.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt> and <tt>clear</tt> operations. It does not * support the <tt>add</tt> or <tt>addAll</tt> operations. * * @return a collection view of the values contained in this map */ Collection<V> valueCollection(); /** * Returns the values of the map as an array of <tt>#e#</tt> values. * Changes to the array of values will not be reflected in the map * nor vice-versa. * * @return the values of the map as an array of <tt>#e#</tt> values. */ V[] values(); /** * Returns the values of the map using an existing array. * Changes to the array of values will not be reflected in the map * nor vice-versa. * * @param array the array into which the elements of the list are to be stored, * if it is big enough; otherwise, a new array of the same type is * allocated for this purpose. * @return the values of the map as an array of <tt>#e#</tt> values. */ <T> T[] values( T[] array ); /** * Returns a <tt>T#E#ObjectIterator</tt> with access to this map's keys and values. * * @return a <tt>T#E#ObjectIterator</tt> with access to this map's keys and values. */ public T#E#ObjectIterator iterator(); /** * Executes <tt>procedure</tt> for each key in the map. * * @param procedure a <code>TObjectProcedure</code> value * @return false if the loop over the keys terminated because * the procedure returned false for some key. */ public boolean forEachKey( T#E#Procedure procedure ); /** * Executes <tt>procedure</tt> for each value in the map. * * @param procedure a <code>TObjectProcedure</code> value * @return false if the loop over the values terminated because * the procedure returned false for some value. */ public boolean forEachValue( TObjectProcedure<V> procedure ); /** * Executes <tt>procedure</tt> for each key/value entry in the * map. * * @param procedure a <code>T#E#ObjectProcedure</code> value * @return false if the loop over the entries terminated because * the procedure returned false for some entry. */ public boolean forEachEntry( T#E#ObjectProcedure<V> procedure ); /** * Transform the values in this map using <tt>function</tt>. * * @param function a <code>TObjectFunction</code> value */ public void transformValues( TObjectFunction<V,V> function ); /** * Retains only those entries in the map for which the procedure * returns a true value. * * @param procedure determines which entries to keep * @return true if the map was modified. */ public boolean retainEntries( T#E#ObjectProcedure<V> procedure ); // Comparison and hashing /** * Compares the specified object with this map for equality. Returns * <tt>true</tt> if the given object is also a map and the two maps * represent the same mappings. More formally, two maps <tt>m1</tt> and * <tt>m2</tt> represent the same mappings if * <tt>m1.entrySet().equals(m2.entrySet())</tt>. This ensures that the * <tt>equals</tt> method works properly across different implementations * of the <tt>Map</tt> interface. * * @param o object to be compared for equality with this map * @return <tt>true</tt> if the specified object is equal to this map */ boolean equals( Object o ); /** * Returns the hash code value for this map. The hash code of a map is * defined to be the sum of the hash codes of each entry in the map's * <tt>entrySet()</tt> view. This ensures that <tt>m1.equals(m2)</tt> * implies that <tt>m1.hashCode()==m2.hashCode()</tt> for any two maps * <tt>m1</tt> and <tt>m2</tt>, as required by the general contract of * {@link Object#hashCode}. * * @return the hash code value for this map * @see TObject#E#Map.Entry#hashCode() * @see Object#equals(Object) * @see #equals(Object) */ int hashCode(); } |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:42
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove/map/hash Added Files: Tag: TROVE_3_WORKING _E_ObjectHashMap.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet --- NEW FILE: _E_ObjectHashMap.template --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // Copyright (c) 2009, Rob Eden All Rights Reserved. // Copyright (c) 2009, Jeff Randall All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove.map.hash; import gnu.trove.map.T#E#ObjectMap; import gnu.trove.impl.Constants; import gnu.trove.impl.HashFunctions; import gnu.trove.impl.hash.T#E#Hash; import gnu.trove.procedure.T#E#ObjectProcedure; import gnu.trove.procedure.T#E#Procedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.iterator.T#E#Iterator; import gnu.trove.iterator.T#E#ObjectIterator; import gnu.trove.iterator.hash.TPrimitiveIterator; import gnu.trove.function.TObjectFunction; import gnu.trove.set.T#E#Set; import gnu.trove.T#E#Collection; import java.io.*; import java.util.*; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * An open addressed Map implementation for #e# keys and Object values. * * Created: Sun Nov 4 08:52:45 2001 * * @author Eric D. Friedman * @author Rob Eden * @author Jeff Randall */ public class T#E#ObjectHashMap<V> extends T#E#Hash implements T#E#ObjectMap<V>, Externalizable { static final long serialVersionUID = 1L; private final T#E#ObjectProcedure<V> PUT_ALL_PROC = new T#E#ObjectProcedure<V>() { public boolean execute( #e# key, V value) { put( key, value ); return true; } }; /** the values of the map */ protected transient V[] _values; /** the value that represents null in the key set. */ protected #e# no_entry_key; /** * Creates a new <code>T#E#ObjectHashMap</code> instance with the default * capacity and load factor. */ public T#E#ObjectHashMap() { super(); } /** * Creates a new <code>T#E#ObjectHashMap</code> instance with a prime * capacity equal to or greater than <tt>initialCapacity</tt> and * with the default load factor. * * @param initialCapacity an <code>int</code> value */ public T#E#ObjectHashMap( int initialCapacity ) { super( initialCapacity ); no_entry_key = Constants.DEFAULT_#EC#_NO_ENTRY_VALUE; } /** * Creates a new <code>T#E#ObjectHashMap</code> instance with a prime * capacity equal to or greater than <tt>initialCapacity</tt> and * with the specified load factor. * * @param initialCapacity an <code>int</code> value * @param loadFactor a <code>float</code> value */ public T#E#ObjectHashMap( int initialCapacity, float loadFactor ) { super( initialCapacity, loadFactor ); no_entry_key = Constants.DEFAULT_#EC#_NO_ENTRY_VALUE; } /** * Creates a new <code>T#E#ObjectHashMap</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 noEntryKey the value used to represent null in the key set. */ public T#E#ObjectHashMap( int initialCapacity, float loadFactor, #e# noEntryKey ) { super( initialCapacity, loadFactor ); this.no_entry_value = noEntryKey; } /** * Creates a new <code>T#E#ObjectHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>T#E#ObjectMap</tt> to be copied. */ public T#E#ObjectHashMap( T#E#ObjectMap<V> map ) { this( map.size(), 0.5f, map.getNoEntryKey() ); putAll( map ); } // TODO: review and see if we can make this at least protected. /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public int setUp( int initialCapacity ) { int capacity; capacity = super.setUp( initialCapacity ); _values = ( V[] ) new Object[capacity]; return capacity; } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) protected void rehash( int newCapacity ) { int oldCapacity = _set.length; #e# oldKeys[] = _set; V oldVals[] = _values; byte oldStates[] = _states; _set = new #e#[newCapacity]; _values = (V[]) new Object[newCapacity]; _states = new byte[newCapacity]; for ( int i = oldCapacity; i-- > 0; ) { if( oldStates[i] == FULL ) { #e# o = oldKeys[i]; int index = insertionIndex(o); _set[index] = o; _values[index] = oldVals[i]; _states[index] = FULL; } } } // Query Operations /** {@inheritDoc} */ public #e# getNoEntryKey() { return no_entry_key; } /** {@inheritDoc} */ public boolean containsKey( #e# key ) { return contains( key ); } /** {@inheritDoc} */ public boolean containsValue( Object val ) { byte[] states = _states; V[] vals = _values; // special case null values so that we don't have to // perform null checks before every call to equals() if ( null == val ) { for ( int i = vals.length; i-- > 0; ) { if ( states[i] == FULL && val == vals[i] ) { return true; } } } else { for ( int i = vals.length; i-- > 0; ) { if ( states[i] == FULL && ( val == vals[i] || val.equals( vals[i] ) ) ) { return true; } } } // end of else return false; } /** {@inheritDoc} */ public V get( #e# key ) { int index = index( key ); return index < 0 ? null : _values[index]; } // Modification Operations /** {@inheritDoc} */ public V put( #e# key, V value ) { int index = insertionIndex( key ); return doPut( key, value, index ); } /** {@inheritDoc} */ public V putIfAbsent( #e# key, V value ) { int index = insertionIndex( key ); if ( index < 0 ) return _values[-index - 1]; return doPut( key, value, index ); } @SuppressWarnings({"unchecked"}) private V doPut( #e# key, V value, int index ) { byte previousState; V previous = null; boolean isNewMapping = true; if ( index < 0 ) { index = -index -1; previous = _values[index]; isNewMapping = false; } previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { postInsertHook( previousState == FREE ); } return previous; } /** {@inheritDoc} */ public V remove( #e# key ) { V prev = null; int index = index( key ); if ( index >= 0 ) { prev = _values[index]; removeAt( index ); // clear key,state; adjust size } return prev; } // TODO: review and see if we can make this at least protected. /** {@inheritDoc} */ public void removeAt( int index ) { _values[index] = null; super.removeAt( index ); // clear key, state; adjust size } // Bulk Operations /** {@inheritDoc} */ public void putAll( Map<? extends #ET#, ? extends V> map ) { Set<? extends Map.Entry<? extends #ET#,? extends V>> set = map.entrySet(); for ( Map.Entry<? extends #ET#,? extends V> entry : set ) { put( entry.getKey(), entry.getValue() ); } } /** {@inheritDoc} */ public void putAll( T#E#ObjectMap<V> map ){ map.forEachEntry( PUT_ALL_PROC ); } /** {@inheritDoc} */ public void clear() { super.clear(); Arrays.fill( _set, 0, _set.length, no_entry_key ); Arrays.fill( _states, 0, _states.length, FREE ); Arrays.fill( _values, 0, _values.length, null ); } // Views /** {@inheritDoc} */ public T#E#Set keySet() { return new KeyView(); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public #e#[] keys() { #e#[] keys = new #e#[size()]; #e#[] k = _set; byte[] states = _states; for ( int i = k.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { keys[j++] = k[i]; } } return keys; } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public #e#[] keys( #e#[] dest ) { if ( dest.length < _size ) { dest = new #e#[_size]; } #e#[] k = _set; byte[] states = _states; for ( int i = k.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { dest[j++] = k[i]; } } return dest; } /** {@inheritDoc} */ public Collection<V> valueCollection() { return new ValueView(); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public V[] values() { V[] vals = ( V[] ) new Object[size()]; V[] v = _values; byte[] states = _states; for ( int i = v.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { vals[j++] = v[i]; } } return vals; } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public <T> T[] values( T[] dest ) { if ( dest.length < _size ) { dest = ( T[] ) java.lang.reflect.Array.newInstance( dest.getClass().getComponentType(), _size); } V[] v = _values; byte[] states = _states; for ( int i = v.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { dest[j++] = ( T ) v[i]; } } return dest; } /** {@inheritDoc} */ public T#E#ObjectIterator<V> iterator() { return new T#E#ObjectHashIterator<V>( this ); } /** {@inheritDoc} */ public boolean forEachKey( T#E#Procedure procedure ) { return forEach( procedure ); } /** {@inheritDoc} */ public boolean forEachValue( TObjectProcedure<V> procedure ) { byte[] states = _states; V[] values = _values; for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL && ! procedure.execute( values[i] ) ) { return false; } } return true; } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public boolean forEachEntry( T#E#ObjectProcedure<V> procedure ) { byte[] states = _states; #e#[] keys = _set; V[] values = _values; for (int i = keys.length; i-- > 0;) { if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { return false; } } return true; } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public boolean retainEntries( T#E#ObjectProcedure<V> procedure ) { boolean modified = false; byte[] states = _states; #e#[] keys = _set; V[] values = _values; // Temporarily disable compaction. This is a fix for bug #1738760 tempDisableAutoCompaction(); try { for ( int i = keys.length; i-- > 0; ) { if ( states[i] == FULL && ! procedure.execute( keys[i], values[i] ) ) { removeAt( i ); modified = true; } } } finally { reenableAutoCompaction( true ); } return modified; } /** {@inheritDoc} */ public void transformValues( TObjectFunction<V,V> function ) { byte[] states = _states; V[] values = _values; for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { values[i] = function.execute( values[i] ); } } } // Comparison and hashing /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) public boolean equals( Object other ) { if ( ! ( other instanceof T#E#ObjectHashMap ) ) { return false; } T#E#ObjectHashMap<V> that = ( T#E#ObjectHashMap<V> ) other; if ( that.size() != this.size() ) { return false; } V[] values = _values; byte[] states = _states; for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { #e# key = _set[i]; int index = that.index( key ); if ( index < 0 ) { V this_value = values[i]; V that_value = that.get( key ); if ( ( this_value != that_value ) || ( this_value == null ) || ! this_value.equals( that_value ) ) { return false; } } } } return true; } class KeyView implements T#E#Set { /** {@inheritDoc} */ public #e# getNoEntryValue() { return no_entry_key; } /** {@inheritDoc} */ public int size() { return _size; } /** {@inheritDoc} */ public boolean isEmpty() { return _size == 0; } /** {@inheritDoc} */ public boolean contains( #e# entry ) { return T#E#ObjectHashMap.this.containsKey( entry ); } /** {@inheritDoc} */ public T#E#Iterator iterator() { return new T#E#HashIterator( T#E#ObjectHashMap.this ); } /** {@inheritDoc} */ public #e#[] toArray() { return keys(); } /** {@inheritDoc} */ public #e#[] toArray( #e#[] dest ) { return keys( dest ); } /** {@inheritDoc} */ public boolean add( #e# entry ) { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ public boolean remove( #e# entry ) { return null != T#E#ObjectHashMap.this.remove( entry ); } /** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( ! T#E#ObjectHashMap.this.containsKey( ( ( #ET# ) element ).#e#Value() ) ) { return false; } } return true; } /** {@inheritDoc} */ public boolean containsAll( T#E#Collection collection ) { if ( collection == this ) { return true; } T#E#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! T#E#ObjectHashMap.this.containsKey( iter.next() ) ) { return false; } } return true; } /** {@inheritDoc} */ public boolean containsAll( #e#[] array ) { for ( #e# element : array ) { if ( ! T#E#ObjectHashMap.this.containsKey( element ) ) { return false; } } return true; } /** {@inheritDoc} */ public boolean addAll( Collection<? extends #ET#> collection ) { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ public boolean addAll( T#E#Collection collection ) { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ public boolean addAll( #e#[] array ) { throw new UnsupportedOperationException(); } /** {@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#[] set = _set; byte[] states = _states; for ( int i = set.length; i-- > 0; ) { if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) { removeAt( i ); changed = true; } } return changed; } /** {@inheritDoc} */ public boolean removeAll( Collection<?> collection ) { boolean changed = false; for ( Object element : collection ) { if ( element instanceof #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; } /** {@inheritDoc} */ public void clear() { T#E#ObjectHashMap.this.clear(); } /** {@inheritDoc} */ public boolean forEach( T#E#Procedure procedure ) { return T#E#ObjectHashMap.this.forEachKey( procedure ); } class T#E#HashIterator extends TPrimitiveIterator implements T#E#Iterator { /** the collection on which the iterator operates */ private final T#E#Hash _hash; /** {@inheritDoc} */ public T#E#HashIterator( T#E#Hash hash ) { super( hash ); this._hash = hash; } /** {@inheritDoc} */ public #e# next() { moveToNextIndex(); return _hash._set[_index]; } } } /** a view onto the values of the map. */ protected class ValueView extends MapBackedView<V> { @SuppressWarnings({"unchecked"}) public Iterator<V> iterator() { return new T#E#ObjectValueHashIterator( T#E#ObjectHashMap.this ) { protected V objectAtIndex( int index ) { return _values[index]; } }; } public boolean containsElement( V value ) { return containsValue( value ); } public boolean removeElement( V value ) { V[] values = _values; byte[] states = _states; for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { if ( value == values[i] || ( null != values[i] && values[i].equals( value ) ) ) { removeAt( i ); return true; } } } return false; } class T#E#ObjectValueHashIterator extends TPrimitiveIterator implements Iterator<V> { protected final T#E#ObjectHashMap _map; public T#E#ObjectValueHashIterator( T#E#ObjectHashMap map ) { super( map ); _map = map; } @SuppressWarnings("unchecked") protected V objectAtIndex( int index ) { byte[] states = _states; Object value = _map._values[index]; if ( states[index] != FULL ) { return null; } return ( V ) value; } /** {@inheritDoc} */ @SuppressWarnings("unchecked") public V next() { moveToNextIndex(); return ( V ) _map._values[_index]; } } } private abstract class MapBackedView<E> extends AbstractSet<E> implements Set<E>, Iterable<E> { public abstract Iterator<E> iterator(); public abstract boolean removeElement( E key ); public abstract boolean containsElement( E key ); @SuppressWarnings({"unchecked"}) public boolean contains( Object key ) { return containsElement( (E) key ); } @SuppressWarnings({"unchecked"}) public boolean remove( Object o ) { return removeElement( (E) o ); } public void clear() { T#E#ObjectHashMap.this.clear(); } public boolean add( E obj ) { throw new UnsupportedOperationException(); } public int size() { return T#E#ObjectHashMap.this.size(); } public Object[] toArray() { Object[] result = new Object[size()]; Iterator<E> e = iterator(); for ( int i = 0; e.hasNext(); i++ ) { result[i] = e.next(); } return result; } @SuppressWarnings({"unchecked"}) public <T> T[] toArray( T[] a ) { int size = size(); if ( a.length < size ) { a = (T[]) java.lang.reflect.Array.newInstance( a.getClass().getComponentType(), size ); } Iterator<E> it = iterator(); Object[] result = a; for ( int i = 0; i < size; i++ ) { result[i] = it.next(); } if ( a.length > size ) { a[size] = null; } return a; } public boolean isEmpty() { return T#E#ObjectHashMap.this.isEmpty(); } public boolean addAll( Collection<? extends E> collection ) { throw new UnsupportedOperationException(); } @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { boolean changed = false; Iterator<E> i = iterator(); while ( i.hasNext() ) { if ( !collection.contains( i.next() ) ) { i.remove(); changed = true; } } return changed; } } class T#E#ObjectHashIterator<V> extends TPrimitiveIterator implements T#E#ObjectIterator<V> { /** the collection being iterated over */ private final T#E#ObjectHashMap<V> _map; /** * Creates an iterator over the specified map * * @param map map to iterate over. */ public T#E#ObjectHashIterator( T#E#ObjectHashMap<V> map ) { super( map ); this._map = map; } /** {@inheritDoc} */ public void advance() { moveToNextIndex(); } /** {@inheritDoc} */ public #e# key() { return _map._set[_index]; } /** {@inheritDoc} */ public V value() { return _map._values[_index]; } /** {@inheritDoc} */ public V setValue( V val ) { V old = value(); _map._values[_index] = val; return old; } } /** {@inheritDoc} */ public int hashCode() { int hashcode = 0; V[] values = _values; byte[] states = _states; for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { hashcode += HashFunctions.hash( _set[i] ) ^ values[i].hashCode(); } } return hashcode; } public void writeExternal( ObjectOutput out ) throws IOException { // VERSION out.writeByte( 0 ); // NUMBER OF ENTRIES out.writeInt( _size ); // ENTRIES for ( int i = _states.length; i-- > 0; ) { if ( _states[i] == FULL ) { out.write#E#( _set[i] ); out.writeObject( _values[i] ); } } } @SuppressWarnings({"unchecked"}) public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { #e# key = in.read#E#(); V val = (V) in.readObject(); put(key, val); } } public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry(new T#E#ObjectProcedure<V>() { private boolean first = true; public boolean execute(#e# key, Object value) { if ( first ) first = false; else buf.append( "," ); buf.append(key); buf.append("="); buf.append(value); return true; } }); buf.append("}"); return buf.toString(); } } // T#E#ObjectHashMap |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:41
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/iterator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove/iterator Added Files: Tag: TROVE_3_WORKING _E_ObjectIterator.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet --- NEW FILE: _E_ObjectIterator.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.iterator; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * Iterator for maps of type #e# and Object. * <p/> * The iterator semantics for Trove's primitive maps is slightly different * from those defined in <tt>java.util.Iterator</tt>, but still well within * the scope of the pattern, as defined by Gamma, et al. * <p/> * This iterator does <b>not</b> implicitly advance to the next entry when * the value at the current position is retrieved. Rather, you must explicitly * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>, * the <tt>value()</tt> or both. This is done so that you have the option, but not * the obligation, to retrieve keys and/or values as your application requires, and * without introducing wrapper objects that would carry both. As the iteration is * stateful, access to the key/value parts of the current map entry happens in * constant time. * <p/> * In practice, the iterator is akin to a "search finger" that you move from * position to position. Read or write operations affect the current entry only and * do not assume responsibility for moving the finger. * <p/> * Here are some sample scenarios for this class of iterator: * <p/> * <pre> * // accessing keys/values through an iterator: * for ( T#E#ObjectIterator it = map.iterator(); it.hasNext(); ) { * it.advance(); * if ( satisfiesCondition( it.key() ) ) { * doSomethingWithValue( it.value() ); * } * } * </pre> * <p/> * <pre> * // modifying values in-place through iteration: * for ( T#E#ObjectIterator it = map.iterator(); it.hasNext(); ) { * it.advance(); * if ( satisfiesCondition( it.key() ) ) { * it.setValue( newValueForKey( it.key() ) ); * } * } * </pre> * <p/> * <pre> * // deleting entries during iteration: * for ( T#E#ObjectIterator it = map.iterator(); it.hasNext(); ) { * it.advance(); * if ( satisfiesCondition( it.key() ) ) { * it.remove(); * } * } * </pre> * <p/> * <pre> * // faster iteration by avoiding hasNext(): * T#E#ObjectIterator iterator = map.iterator(); * for ( int i = map.size(); i-- > 0; ) { * iterator.advance(); * doSomethingWithKeyAndValue( iterator.key(), iterator.value() ); * } * </pre> * * @author Eric D. Friedman * @author Rob Eden * @author Jeff Randall * @version $Id: _E_ObjectIterator.template,v 1.1.2.1 2009/09/15 02:38:31 upholderoftruth Exp $ */ public interface T#E#ObjectIterator<V> extends TAdvancingIterator { /** * Provides access to the key of the mapping at the iterator's position. * Note that you must <tt>advance()</tt> the iterator at least once * before invoking this method. * * @return the key of the entry at the iterator's current position. */ public #e# key(); /** * Provides access to the value of the mapping at the iterator's position. * Note that you must <tt>advance()</tt> the iterator at least once * before invoking this method. * * @return the value of the entry at the iterator's current position. */ public V value(); /** * Replace the value of the mapping at the iterator's position with the * specified value. Note that you must <tt>advance()</tt> the iterator at * least once before invoking this method. * * @param val the value to set in the current entry * @return the old value of the entry. */ public V setValue( V val ); } |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:41
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove Modified Files: Tag: TROVE_3_WORKING _E_Collection.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet Index: _E_Collection.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/Attic/_E_Collection.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 *** _E_Collection.template 9 Sep 2009 01:15:54 -0000 1.1.2.1 --- _E_Collection.template 15 Sep 2009 02:38:30 -0000 1.1.2.2 *************** *** 43,47 **** public interface T#E#Collection extends Serializable { - /** * Returns the value that is used to represent null. The default --- 43,46 ---- *************** *** 51,55 **** * @return the value that represents null */ ! public #e# getNoEntryValue(); --- 50,54 ---- * @return the value that represents null */ ! #e# getNoEntryValue(); *************** *** 78,82 **** * @return true if the collection contains the specified element. */ ! public boolean contains( #e# entry ); --- 77,81 ---- * @return true if the collection contains the specified element. */ ! boolean contains( #e# entry ); *************** *** 87,91 **** * @return an <code>T#E#Iterator</code> value */ ! public T#E#Iterator iterator(); --- 86,90 ---- * @return an <code>T#E#Iterator</code> value */ ! T#E#Iterator iterator(); *************** *** 106,110 **** * @return an array containing all the elements in this collection */ ! public #e#[] toArray(); --- 105,109 ---- * @return an array containing all the elements in this collection */ ! #e#[] toArray(); *************** *** 132,136 **** * @throws NullPointerException if the specified array is null */ ! public #e#[] toArray( #e#[] dest ); --- 131,135 ---- * @throws NullPointerException if the specified array is null */ ! #e#[] toArray( #e#[] dest ); *************** *** 141,145 **** * @return true if the collection was modified by the add operation */ ! public boolean add( #e# entry ); --- 140,144 ---- * @return true if the collection was modified by the add operation */ ! boolean add( #e# entry ); *************** *** 150,154 **** * @return true if the collection was modified by the remove operation. */ ! public boolean remove( #e# entry ); --- 149,153 ---- * @return true if the collection was modified by the remove operation. */ ! boolean remove( #e# entry ); *************** *** 160,164 **** * @return true if all elements were present in the collection. */ ! public boolean containsAll( Collection<?> collection ); --- 159,163 ---- * @return true if all elements were present in the collection. */ ! boolean containsAll( Collection<?> collection ); *************** *** 170,174 **** * @return true if all elements were present in the collection. */ ! public boolean containsAll( T#E#Collection collection ); --- 169,173 ---- * @return true if all elements were present in the collection. */ ! boolean containsAll( T#E#Collection collection ); *************** *** 180,184 **** * @return true if all elements were present in the collection. */ ! public boolean containsAll( #e#[] array ); --- 179,183 ---- * @return true if all elements were present in the collection. */ ! boolean containsAll( #e#[] array ); *************** *** 189,193 **** * @return true if the collection was modified by the add all operation. */ ! public boolean addAll( Collection<? extends #ET#> collection ); --- 188,192 ---- * @return true if the collection was modified by the add all operation. */ ! boolean addAll( Collection<? extends #ET#> collection ); *************** *** 198,202 **** * @return true if the collection was modified by the add all operation. */ ! public boolean addAll( T#E#Collection collection ); --- 197,201 ---- * @return true if the collection was modified by the add all operation. */ ! boolean addAll( T#E#Collection collection ); *************** *** 207,211 **** * @return true if the collection was modified by the add all operation. */ ! public boolean addAll( #e#[] array ); --- 206,210 ---- * @return true if the collection was modified by the add all operation. */ ! boolean addAll( #e#[] array ); *************** *** 217,221 **** * @return true if the collection was modified by the retain all operation */ ! public boolean retainAll( Collection<?> collection ); --- 216,220 ---- * @return true if the collection was modified by the retain all operation */ ! boolean retainAll( Collection<?> collection ); *************** *** 227,231 **** * @return true if the collection was modified by the retain all operation */ ! public boolean retainAll( T#E#Collection collection ); --- 226,230 ---- * @return true if the collection was modified by the retain all operation */ ! boolean retainAll( T#E#Collection collection ); *************** *** 237,241 **** * @return true if the collection was modified by the retain all operation */ ! public boolean retainAll( #e#[] array ); --- 236,240 ---- * @return true if the collection was modified by the retain all operation */ ! boolean retainAll( #e#[] array ); *************** *** 246,250 **** * @return true if the collection was modified by the remove all operation. */ ! public boolean removeAll( Collection<?> collection ); --- 245,249 ---- * @return true if the collection was modified by the remove all operation. */ ! boolean removeAll( Collection<?> collection ); *************** *** 255,259 **** * @return true if the collection was modified by the remove all operation. */ ! public boolean removeAll( T#E#Collection collection ); --- 254,258 ---- * @return true if the collection was modified by the remove all operation. */ ! boolean removeAll( T#E#Collection collection ); *************** *** 264,268 **** * @return true if the collection was modified by the remove all operation. */ ! public boolean removeAll( #e#[] array ); --- 263,267 ---- * @return true if the collection was modified by the remove all operation. */ ! boolean removeAll( #e#[] array ); *************** *** 270,274 **** * Empties the collection. */ ! public void clear(); --- 269,273 ---- * Empties the collection. */ ! void clear(); *************** *** 280,284 **** * the procedure returned false for some value. */ ! public boolean forEach( T#E#Procedure procedure ); --- 279,283 ---- * the procedure returned false for some value. */ ! boolean forEach( T#E#Procedure procedure ); |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:41
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/iterator/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove/iterator/hash Removed Files: Tag: TROVE_3_WORKING _E_HashIterator.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet --- _E_HashIterator.template DELETED --- |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:41
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove/set/hash Modified Files: Tag: TROVE_3_WORKING _E_HashSet.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet Index: _E_HashSet.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/set/hash/Attic/_E_HashSet.template,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** _E_HashSet.template 11 Sep 2009 22:20:48 -0000 1.1.2.4 --- _E_HashSet.template 15 Sep 2009 02:38:30 -0000 1.1.2.5 *************** *** 23,28 **** import gnu.trove.set.T#E#Set; import gnu.trove.iterator.T#E#Iterator; ! import gnu.trove.iterator.hash.T#E#HashIterator; ! import gnu.trove.procedure.T#E#Procedure; import gnu.trove.impl.*; import gnu.trove.impl.hash.T#E#Hash; --- 23,27 ---- import gnu.trove.set.T#E#Set; import gnu.trove.iterator.T#E#Iterator; ! import gnu.trove.iterator.hash.TPrimitiveIterator; import gnu.trove.impl.*; import gnu.trove.impl.hash.T#E#Hash; *************** *** 164,190 **** ! /** ! * Returns an array containing elements in this set. ! * ! * <p>If this set fits in the specified array with room to spare ! * (i.e., the array has more elements than this set), the element in ! * the array immediately following the end of the set is set to ! * <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining ! * the length of this set <i>only</i> if the caller knows that this ! * set does not contain any elements representing null.) ! * ! * <p>If the native array is smaller than the set size, ! * the array will be filled with elements in Iterator order ! * until it is full and exclude the remainder. ! * ! * <p>If this set makes any guarantees as to what order its elements ! * are returned by its iterator, this method must return the elements ! * in the same order. ! * ! * @param dest the array into which the elements of this set are to be ! * stored. ! * @return an <tt>#e#[]</tt> containing all the elements in this set ! * @throws NullPointerException if the specified array is null ! */ public #e#[] toArray( #e#[] dest ) { #e#[] set = _set; --- 163,167 ---- ! /** {@inheritDoc} */ public #e#[] toArray( #e#[] dest ) { #e#[] set = _set; *************** *** 200,214 **** dest[_size] = no_entry_value; } - return dest; } ! /** ! * Inserts a value into the set. ! * ! * @param val an <code>#e#</code> value ! * @return true if the set was modified by the add operation ! */ public boolean add( #e# val ) { int index = insertionIndex(val); --- 177,185 ---- dest[_size] = no_entry_value; } return dest; } ! /** {@inheritDoc} */ public boolean add( #e# val ) { int index = insertionIndex(val); *************** *** 227,236 **** ! /** ! * Removes <tt>val</tt> from the set. ! * ! * @param val an <code>#e#</code> value ! * @return true if the set was modified by the remove operation. ! */ public boolean remove( #e# val ) { int index = index(val); --- 198,202 ---- ! /** {@inheritDoc} */ public boolean remove( #e# val ) { int index = index(val); *************** *** 243,253 **** ! /** ! * Tests the set to determine if all of the elements in ! * <tt>collection</tt> are present. ! * ! * @param collection a <code>Collection</code> of Objects. ! * @return true if all elements were Characters and present in the set. ! */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { --- 209,213 ---- ! /** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { *************** *** 266,276 **** ! /** ! * 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(); --- 226,230 ---- ! /** {@inheritDoc} */ public boolean containsAll( T#E#Collection collection ) { T#E#Iterator iter = collection.iterator(); *************** *** 285,295 **** ! /** ! * Tests the set to determine if all of the elements in ! * <tt>array</tt> are present. ! * ! * @param array an <code>array</code> of #e# primitives. ! * @return true if all elements were present in the set. ! */ public boolean containsAll( #e#[] array ) { for ( int i = array.length; i-- > 0; ) { --- 239,243 ---- ! /** {@inheritDoc} */ public boolean containsAll( #e#[] array ) { for ( int i = array.length; i-- > 0; ) { *************** *** 302,311 **** ! /** ! * Adds all of the elements in <tt>collection</tt> to the set. ! * ! * @param collection an <code>Collection</code> to be added. ! * @return true if the set was modified by the add all operation. ! */ public boolean addAll( Collection<? extends #ET#> collection ) { boolean changed = false; --- 250,254 ---- ! /** {@inheritDoc} */ public boolean addAll( Collection<? extends #ET#> collection ) { boolean changed = false; *************** *** 320,329 **** ! /** ! * 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; --- 263,267 ---- ! /** {@inheritDoc} */ public boolean addAll( T#E#Collection collection ) { boolean changed = false; *************** *** 339,348 **** ! /** ! * Adds all of the elements in <tt>array</tt> to the set. ! * ! * @param array an <code>array</code> of #e# primitives. ! * @return true if the set was modified by the add all operation. ! */ public boolean addAll( #e#[] array ) { boolean changed = false; --- 277,281 ---- ! /** {@inheritDoc} */ public boolean addAll( #e#[] array ) { boolean changed = false; *************** *** 356,366 **** ! /** ! * Removes any values in the set which are not contained in ! * <tt>collection</tt>. ! * ! * @param collection a <code>Collection</code> of Objects. ! * @return true if the set was modified by the retain all operation ! */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { --- 289,293 ---- ! /** {@inheritDoc} */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { *************** *** 377,387 **** ! /** ! * Removes any values in the set which are not contained in ! * <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 ) { --- 304,308 ---- ! /** {@inheritDoc} */ public boolean retainAll( T#E#Collection collection ) { if ( this == collection ) { *************** *** 400,410 **** ! /** ! * Removes any values in the set which are not contained in ! * <tt>array</tt>. ! * ! * @param array an <code>array</code> of #e# primitives. ! * @return true if the set was modified by the retain all operation ! */ public boolean retainAll( #e#[] array ) { boolean changed = false; --- 321,325 ---- ! /** {@inheritDoc} */ public boolean retainAll( #e#[] array ) { boolean changed = false; *************** *** 423,432 **** ! /** ! * Removes all of the elements in <tt>collection</tt> from the set. ! * ! * @param collection an <code>Collection</code> of Objects. ! * @return true if the set was modified by the remove all operation. ! */ public boolean removeAll( Collection<?> collection ) { boolean changed = false; --- 338,342 ---- ! /** {@inheritDoc} */ public boolean removeAll( Collection<?> collection ) { boolean changed = false; *************** *** 442,451 **** } ! /** ! * 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; --- 352,357 ---- } ! ! /** {@inheritDoc} */ public boolean removeAll( T#E#Collection collection ) { boolean changed = false; *************** *** 461,470 **** ! /** ! * Removes all of the elements in <tt>array</tt> from the set. ! * ! * @param array an <code>array</code> of #e# primitives. ! * @return true if the set was modified by the remove all operation. ! */ public boolean removeAll( #e#[] array ) { boolean changed = false; --- 367,371 ---- ! /** {@inheritDoc} */ public boolean removeAll( #e#[] array ) { boolean changed = false; *************** *** 478,484 **** ! /** ! * Empties the set. ! */ public void clear() { super.clear(); --- 379,383 ---- ! /** {@inheritDoc} */ public void clear() { super.clear(); *************** *** 493,501 **** ! /** ! * Expands the set to accommodate new values. ! * ! * @param newCapacity an <code>int</code> value ! */ protected void rehash( int newCapacity ) { int oldCapacity = _set.length; --- 392,396 ---- ! /** {@inheritDoc} */ protected void rehash( int newCapacity ) { int oldCapacity = _set.length; *************** *** 517,527 **** ! /** ! * Compares this set with another set for equality of their stored ! * entries. ! * ! * @param other an <code>Object</code> value ! * @return a <code>boolean</code> value ! */ public boolean equals( Object other ) { if (! (other instanceof T#E#HashSet)) { --- 412,416 ---- ! /** {@inheritDoc} */ public boolean equals( Object other ) { if (! (other instanceof T#E#HashSet)) { *************** *** 532,564 **** return false; } ! return forEach( new T#E#Procedure() { ! public final boolean execute( #e# value ) { ! return that.contains( value ); } ! }); } public int hashCode() { ! HashProcedure p = new HashProcedure(); ! forEach(p); ! return p.getHashCode(); ! } ! ! ! private final class HashProcedure implements T#E#Procedure { ! private int h = 0; ! ! public int getHashCode() { ! return h; ! } ! ! public final boolean execute( #e# key ) { ! h += HashFunctions.hash( key ); ! return true; } } public String toString() { StringBuilder buffy = new StringBuilder( _size * 2 + 2 ); --- 421,448 ---- return false; } ! for ( int i = _states.length; i-- > 0; ) { ! if ( _states[i] == FULL ) { ! if ( ! that.contains( _set[i] ) ) { ! return false; ! } } ! } ! return true; } + /** {@inheritDoc} */ public int hashCode() { ! int hashcode = 0; ! for ( int i = _states.length; i-- > 0; ) { ! if ( _states[i] == FULL ) { ! hashcode += HashFunctions.hash( _set[i] ); ! } } + return hashcode; } + /** {@inheritDoc} */ public String toString() { StringBuilder buffy = new StringBuilder( _size * 2 + 2 ); *************** *** 577,580 **** --- 461,484 ---- + class T#E#HashIterator extends TPrimitiveIterator implements T#E#Iterator { + + /** the collection on which the iterator operates */ + private final T#E#Hash _hash; + + /** {@inheritDoc} */ + public T#E#HashIterator( T#E#Hash hash ) { + super( hash ); + this._hash = hash; + } + + /** {@inheritDoc} */ + public #e# next() { + moveToNextIndex(); + return _hash._set[_index]; + } + } + + + /** {@inheritDoc} */ public void writeExternal( ObjectOutput out ) throws IOException { *************** *** 582,585 **** --- 486,492 ---- out.writeByte( 1 ); + // SUPER + super.writeExternal( out ); + // NUMBER OF ENTRIES out.writeInt( _size ); *************** *** 600,603 **** --- 507,511 ---- + /** {@inheritDoc} */ @SuppressWarnings({"RedundantCast"}) public void readExternal( ObjectInput in ) *************** *** 607,610 **** --- 515,521 ---- int version = in.readByte(); + // SUPER + super.readExternal( in ); + // NUMBER OF ENTRIES int size = in.readInt(); |
From: Jeff R. <uph...@us...> - 2009-09-15 02:38:41
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32382/templates/gnu/trove/set Modified Files: Tag: TROVE_3_WORKING _E_Set.template Log Message: Interface and Implementation for TPrimitiveObjectHashMaps, associated tests, and related changes. Move TPrimitiveHashIterator into TPrimitiveHashSet Index: _E_Set.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/set/Attic/_E_Set.template,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** _E_Set.template 9 Sep 2009 01:15:54 -0000 1.1.2.4 --- _E_Set.template 15 Sep 2009 02:38:31 -0000 1.1.2.5 *************** *** 54,58 **** * @return the value that represents null */ ! public #e# getNoEntryValue(); --- 54,58 ---- * @return the value that represents null */ ! #e# getNoEntryValue(); *************** *** 81,85 **** * @return true if the set contains the specified element. */ ! public boolean contains( #e# entry ); --- 81,85 ---- * @return true if the set contains the specified element. */ ! boolean contains( #e# entry ); *************** *** 90,94 **** * @return an <code>T#E#Iterator</code> value */ ! public T#E#Iterator iterator(); --- 90,94 ---- * @return an <code>T#E#Iterator</code> value */ ! T#E#Iterator iterator(); *************** *** 109,113 **** * @return an array containing all the elements in this set */ ! public #e#[] toArray(); --- 109,113 ---- * @return an array containing all the elements in this set */ ! #e#[] toArray(); *************** *** 135,139 **** * @throws NullPointerException if the specified array is null */ ! public #e#[] toArray( #e#[] dest ); --- 135,139 ---- * @throws NullPointerException if the specified array is null */ ! #e#[] toArray( #e#[] dest ); *************** *** 144,148 **** * @return true if the set was modified by the add operation */ ! public boolean add( #e# entry ); --- 144,148 ---- * @return true if the set was modified by the add operation */ ! boolean add( #e# entry ); *************** *** 153,157 **** * @return true if the set was modified by the remove operation. */ ! public boolean remove( #e# entry ); --- 153,157 ---- * @return true if the set was modified by the remove operation. */ ! boolean remove( #e# entry ); *************** *** 163,167 **** * @return true if all elements were present in the set. */ ! public boolean containsAll( Collection<?> collection ); --- 163,167 ---- * @return true if all elements were present in the set. */ ! boolean containsAll( Collection<?> collection ); *************** *** 173,177 **** * @return true if all elements were present in the set. */ ! public boolean containsAll( T#E#Collection collection ); --- 173,177 ---- * @return true if all elements were present in the set. */ ! boolean containsAll( T#E#Collection collection ); *************** *** 183,187 **** * @return true if all elements were present in the set. */ ! public boolean containsAll( #e#[] array ); --- 183,187 ---- * @return true if all elements were present in the set. */ ! boolean containsAll( #e#[] array ); *************** *** 192,196 **** * @return true if the set was modified by the add all operation. */ ! public boolean addAll( Collection<? extends #ET#> collection ); --- 192,196 ---- * @return true if the set was modified by the add all operation. */ ! boolean addAll( Collection<? extends #ET#> collection ); *************** *** 201,205 **** * @return true if the set was modified by the add all operation. */ ! public boolean addAll( T#E#Collection collection ); --- 201,205 ---- * @return true if the set was modified by the add all operation. */ ! boolean addAll( T#E#Collection collection ); *************** *** 210,214 **** * @return true if the set was modified by the add all operation. */ ! public boolean addAll( #e#[] array ); --- 210,214 ---- * @return true if the set was modified by the add all operation. */ ! boolean addAll( #e#[] array ); *************** *** 220,224 **** * @return true if the set was modified by the retain all operation */ ! public boolean retainAll( Collection<?> collection ); --- 220,224 ---- * @return true if the set was modified by the retain all operation */ ! boolean retainAll( Collection<?> collection ); *************** *** 230,234 **** * @return true if the set was modified by the retain all operation */ ! public boolean retainAll( T#E#Collection collection ); --- 230,234 ---- * @return true if the set was modified by the retain all operation */ ! boolean retainAll( T#E#Collection collection ); *************** *** 240,244 **** * @return true if the set was modified by the retain all operation */ ! public boolean retainAll( #e#[] array ); --- 240,244 ---- * @return true if the set was modified by the retain all operation */ ! boolean retainAll( #e#[] array ); *************** *** 249,253 **** * @return true if the set was modified by the remove all operation. */ ! public boolean removeAll( Collection<?> collection ); --- 249,253 ---- * @return true if the set was modified by the remove all operation. */ ! boolean removeAll( Collection<?> collection ); *************** *** 258,262 **** * @return true if the set was modified by the remove all operation. */ ! public boolean removeAll( T#E#Collection collection ); --- 258,262 ---- * @return true if the set was modified by the remove all operation. */ ! boolean removeAll( T#E#Collection collection ); *************** *** 273,277 **** * Empties the set. */ ! public void clear(); --- 273,277 ---- * Empties the set. */ ! void clear(); *************** *** 283,287 **** * the procedure returned false for some value. */ ! public boolean forEach( T#E#Procedure procedure ); --- 283,287 ---- * the procedure returned false for some value. */ ! boolean forEach( T#E#Procedure procedure ); |
From: Rob E. <ro...@us...> - 2009-09-15 01:57:53
|
Update of /cvsroot/trove4j/trove/generator_src/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26722/generator_src/gnu/trove/generator Modified Files: Tag: TROVE_3_WORKING Generator.java Log Message: Always use "\n" rather than the "line.separator" system property. Index: Generator.java =================================================================== RCS file: /cvsroot/trove4j/trove/generator_src/gnu/trove/generator/Attic/Generator.java,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -C2 -d -r1.1.2.7 -r1.1.2.8 *** Generator.java 14 Sep 2009 19:02:19 -0000 1.1.2.7 --- Generator.java 15 Sep 2009 01:57:42 -0000 1.1.2.8 *************** *** 331,336 **** if ( first_loop ) first_loop = false; else { ! entry_buffer.append( System.getProperty( "line.separator" ) ); ! entry_buffer.append( System.getProperty( "line.separator" ) ); } --- 331,335 ---- if ( first_loop ) first_loop = false; else { ! entry_buffer.append( "\n\n" ); } *************** *** 521,527 **** } else { ! if ( need_newline ) { ! buffer.append( System.getProperty( "line.separator" ) ); ! } else need_newline = true; --- 520,524 ---- } else { ! if ( need_newline ) buffer.append( "\n" ); else need_newline = true; |
From: Rob E. <ro...@us...> - 2009-09-15 01:57:51
|
Update of /cvsroot/trove4j/trove/generator_test/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26722/generator_test/gnu/trove/generator Modified Files: Tag: TROVE_3_WORKING GeneratorTest.java Log Message: Always use "\n" rather than the "line.separator" system property. Index: GeneratorTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/generator_test/gnu/trove/generator/Attic/GeneratorTest.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 *** GeneratorTest.java 14 Sep 2009 04:10:32 -0000 1.1.2.1 --- GeneratorTest.java 15 Sep 2009 01:57:42 -0000 1.1.2.2 *************** *** 64,76 **** String output = Generator.processReplication( test, map ); - - // new WrapperInfo( "double", "Double", "POSITIVE_INFINITY", "NEGATIVE_INFINITY" ), - // new WrapperInfo( "float", "Float", "POSITIVE_INFINITY", "NEGATIVE_INFINITY" ), - // new WrapperInfo( "int", "Integer", "MAX_VALUE", "MIN_VALUE" ), - // new WrapperInfo( "long", "Long", "MAX_VALUE", "MIN_VALUE" ), - // new WrapperInfo( "byte", "Byte", "MAX_VALUE", "MIN_VALUE" ), - // new WrapperInfo( "short", "Short", "MAX_VALUE", "MIN_VALUE" ), - // new WrapperInfo( "char", "Character", "MAX_VALUE", "MIN_VALUE" ) }; - String goal = "Line 1\n" + --- 64,67 ---- |
From: Jeff R. <uph...@us...> - 2009-09-14 19:02:36
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/iterator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6715/templates/gnu/trove/iterator Added Files: Tag: TROVE_3_WORKING Object_E_Iterator.template Log Message: Interface and Implementation for TObjectPrimitiveHashMaps, associated tests, and related changes --- NEW FILE: Object_E_Iterator.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.iterator; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * Iterator for maps of type Object and #e#. * <p/> * The iterator semantics for Trove's primitive maps is slightly different * from those defined in <tt>java.util.Iterator</tt>, but still well within * the scope of the pattern, as defined by Gamma, et al. * <p/> * This iterator does <b>not</b> implicitly advance to the next entry when * the value at the current position is retrieved. Rather, you must explicitly * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>, * the <tt>value()</tt> or both. This is done so that you have the option, but not * the obligation, to retrieve keys and/or values as your application requires, and * without introducing wrapper objects that would carry both. As the iteration is * stateful, access to the key/value parts of the current map entry happens in * constant time. * <p/> * In practice, the iterator is akin to a "search finger" that you move from * position to position. Read or write operations affect the current entry only and * do not assume responsibility for moving the finger. * <p/> * Here are some sample scenarios for this class of iterator: * <p/> * <pre> * // accessing keys/values through an iterator: * for ( TObject#E#Iterator it = map.iterator(); it.hasNext(); ) { * it.advance(); * if ( satisfiesCondition( it.key() ) ) { * doSomethingWithValue( it.value() ); * } * } * </pre> * <p/> * <pre> * // modifying values in-place through iteration: * for ( TObject#E#Iterator it = map.iterator(); it.hasNext(); ) { * it.advance(); * if ( satisfiesCondition( it.key() ) ) { * it.setValue( newValueForKey( it.key() ) ); * } * } * </pre> * <p/> * <pre> * // deleting entries during iteration: * for ( TObject#E#Iterator it = map.iterator(); it.hasNext(); ) { * it.advance(); * if ( satisfiesCondition( it.key() ) ) { * it.remove(); * } * } * </pre> * <p/> * <pre> * // faster iteration by avoiding hasNext(): * TObject#E#Iterator iterator = map.iterator(); * for ( int i = map.size(); i-- > 0; ) { * iterator.advance(); * doSomethingWithKeyAndValue( iterator.key(), iterator.value() ); * } * </pre> * * @author Eric D. Friedman * @author Rob Eden * @author Jeff Randall * @version $Id: Object_E_Iterator.template,v 1.1.2.1 2009/09/14 19:02:20 upholderoftruth Exp $ */ public interface TObject#E#Iterator<K> extends TAdvancingIterator { /** * Provides access to the key of the mapping at the iterator's position. * Note that you must <tt>advance()</tt> the iterator at least once * before invoking this method. * * @return the key of the entry at the iterator's current position. */ public K key(); /** * Provides access to the value of the mapping at the iterator's position. * Note that you must <tt>advance()</tt> the iterator at least once * before invoking this method. * * @return the value of the entry at the iterator's current position. */ public #e# value(); /** * Replace the value of the mapping at the iterator's position with the * specified value. Note that you must <tt>advance()</tt> the iterator at * least once before invoking this method. * * @param val the value to set in the current entry * @return the old value of the entry. */ public #e# setValue( #e# val ); } |
From: Jeff R. <uph...@us...> - 2009-09-14 19:02:34
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6715/templates/gnu/trove/map Modified Files: Tag: TROVE_3_WORKING _K__V_Map.template Added Files: Tag: TROVE_3_WORKING Object_E_Map.template Log Message: Interface and Implementation for TObjectPrimitiveHashMaps, associated tests, and related changes --- NEW FILE: Object_E_Map.template --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // Copyright (c) 2009, Rob Eden All Rights Reserved. // Copyright (c) 2009, Jeff Randall All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove.map; import gnu.trove.T#E#Collection; import gnu.trove.set.hash.THashSet; import gnu.trove.function.T#E#Function; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.procedure.T#E#Procedure; import gnu.trove.procedure.TObject#E#Procedure; import gnu.trove.iterator.TObject#E#Iterator; import java.util.Map; import java.util.Set; ////////////////////////////////////////////////// // THIS IS A GENERATED CLASS. DO NOT HAND EDIT! // ////////////////////////////////////////////////// /** * Interface for a primitive map of Object keys and #e# values. */ public interface TObject#E#Map<K> { // Query Operations /** * 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. * * @return the value that represents a null value in this collection. */ #e# getNoEntryValue(); /** * Returns the number of key-value mappings in this map. If the * map contains more than <tt>Integer.MAX_VALUE</tt> elements, returns * <tt>Integer.MAX_VALUE</tt>. * * @return the number of key-value mappings in this map */ int size(); /** * Returns <tt>true</tt> if this map contains no key-value mappings. * * @return <tt>true</tt> if this map contains no key-value mappings */ boolean isEmpty(); /** * Returns <tt>true</tt> if this map contains a mapping for the specified * key. More formally, returns <tt>true</tt> if and only if * this map contains a mapping for a key <tt>k</tt> such that * <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be * at most one such mapping.) * * @param key key whose presence in this map is to be tested * @return <tt>true</tt> if this map contains a mapping for the specified * key * @throws ClassCastException if the key is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified key is null and this map * does not permit null keys (optional) */ boolean containsKey( Object key ); /** * Returns <tt>true</tt> if this map maps one or more keys to the * specified value. More formally, returns <tt>true</tt> if and only if * this map contains at least one mapping to a value <tt>v</tt> such that * <tt>(value==no_entry_value ? v==no_entry_value : value.equals(v))</tt>. This operation * will probably require time linear in the map size for most * implementations of the <tt>Map</tt> interface. *<p/> * Note that no_entry_value is the result of {@link getNoEntryValue()} and represents * null for this map instance. * * @param value <tt>#e#</tt> value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the * specified value * @throws ClassCastException if the value is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified value is null and this * map does not permit null values (optional) */ boolean containsValue( #e# value ); /** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * * <p>More formally, if this map contains a mapping from a key * {@code k} to a value {@code v} such that {@code (key==null ? k==null : * key.equals(k))}, then this method returns {@code v}; otherwise * it returns {@code null}. (There can be at most one such mapping.) * * <p>If this map permits null values, then a return value of * {@code null} does not <i>necessarily</i> indicate that the map * contains no mapping for the key; it's also possible that the map * explicitly maps the key to {@code null}. The {@link #containsKey * containsKey} operation may be used to distinguish these two cases. * * @param key the key whose associated value is to be returned * @return the <tt>#e#</tt> value to which the specified key is mapped, or * {@code null} if this map contains no mapping for the key * @throws ClassCastException if the key is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified key is null and this map * does not permit null keys (optional) */ #e# get( Object key ); // Modification Operations /** * Associates the specified value with the specified key in this map * (optional operation). If the map previously contained a mapping for * the key, the old value is replaced by the specified value. (A map * <tt>m</tt> is said to contain a mapping for a key <tt>k</tt> if and only * if {@link #containsKey(Object) m.containsKey(k)} would return * <tt>true</tt>.) * * @param key key with which the specified value is to be associated * @param value an <tt>#e#</tt> value value to be associated with the specified key * @return the previous value associated with <tt>key</tt>, or * <tt>no_entry_value</tt> if there was no mapping for <tt>key</tt>. * (A <tt>no_entry_value</tt> return can also indicate that the map * previously associated <tt>null</tt> with <tt>key</tt>, * if the implementation supports <tt>null</tt> values.) * @throws UnsupportedOperationException if the <tt>put</tt> operation * is not supported by this map * @throws ClassCastException if the class of the specified key or value * prevents it from being stored in this map * @throws NullPointerException if the specified key or value is null * and this map does not permit null keys or values * @throws IllegalArgumentException if some property of the specified key * or value prevents it from being stored in this map * @see #getNoEntryValue(); */ #e# put( K key, #e# value); /** * Inserts a key/value pair into the map if the specified key is not already * associated with a value. * * @param key key with which the specified value is to be associated * @param value an <tt>#e#</tt> value to be associated with the specified key * * @return the previous value associated with <tt>key</tt>, or the "no entry" value * if none was found (see {@link #getNoEntryValue}). */ #e# putIfAbsent( K key, #e# value ); /** * Removes the mapping for a key from this map if it is present * (optional operation). More formally, if this map contains a mapping * from key <tt>k</tt> to value <tt>v</tt> such that * <code>(key==null ? k==null : key.equals(k))</code>, that mapping * is removed. (The map can contain at most one such mapping.) * * <p>Returns the value to which this map previously associated the key, * or <tt>null</tt> if the map contained no mapping for the key. * * <p>If this map permits null values, then a return value of * <tt>null</tt> does not <i>necessarily</i> indicate that the map * contained no mapping for the key; it's also possible that the map * explicitly mapped the key to <tt>null</tt>. * * <p>The map will not contain a mapping for the specified key once the * call returns. * * @param key key whose mapping is to be removed from the map * @return the previous <tt>#e#</tt> value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt>. * @throws UnsupportedOperationException if the <tt>remove</tt> operation * is not supported by this map * @throws ClassCastException if the key is of an inappropriate type for * this map (optional) * @throws NullPointerException if the specified key is null and this * map does not permit null keys (optional) */ #e# remove( Object key ); // Bulk Operations /** * Copies all of the mappings from the specified map to this map * (optional operation). The effect of this call is equivalent to that * of calling {@link #put(Object,Object) put(k, v)} on this map once * for each mapping from key <tt>k</tt> to value <tt>v</tt> in the * specified map. The behavior of this operation is undefined if the * specified map is modified while the operation is in progress. * * @param m mappings to be stored in this map * @throws UnsupportedOperationException if the <tt>putAll</tt> operation * is not supported by this map * @throws ClassCastException if the class of a key or value in the * specified map prevents it from being stored in this map * @throws NullPointerException if the specified map is null, or if * this map does not permit null keys or values, and the * specified map contains null keys or values * @throws IllegalArgumentException if some property of a key or value in * the specified map prevents it from being stored in this map */ void putAll( Map<? extends K, ? extends #ET#> m); /** * Put all the entries from the given map into this map. * * @param map The map from which entries will be obtained to put into this map. */ void putAll( TObject#E#Map<K> map ); /** * Removes all of the mappings from this map (optional operation). * The map will be empty after this call returns. * * @throws UnsupportedOperationException if the <tt>clear</tt> operation * is not supported by this map */ void clear(); // Views /** * Returns a {@link Set} view of the keys contained in this map. * The set is backed by the map, so changes to the map are * reflected in the set, and vice-versa. If the map is modified * while an iteration over the set is in progress (except through * the iterator's own <tt>remove</tt> operation), the results of * the iteration are undefined. The set supports element removal, * which removes the corresponding mapping from the map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> * operations. It does not support the <tt>add</tt> or <tt>addAll</tt> * operations. * * @return a set view of the keys contained in this map */ Set<K> keySet(); /** * Returns a copy of the keys of the map as an array. * Changes to the array of keys will not be reflected in the map * nor vice-versa. * * @return a copy of the keys of the map as an array. */ Object[] keys(); /** * Returns a copy of the keys of the map as an array. * Changes to the array of keys will not be reflected in the map * nor vice-versa. * * @param array the array into which the elements of the list are to be stored, * if it is big enough; otherwise, a new array of the same type is * allocated for this purpose. * @return the keys of the map as an array. */ K[] keys( K[] array ); /** * Returns a {@link T#E#Collection} view of the values contained in this map. * The collection is backed by the map, so changes to the map are * reflected in the collection, and vice-versa. If the map is * modified while an iteration over the collection is in progress * (except through the iterator's own <tt>remove</tt> operation), * the results of the iteration are undefined. The collection * supports element removal, which removes the corresponding * mapping from the map, via the <tt>T#E#Iterator.remove</tt>, * <tt>T#E#Collection.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt> and <tt>clear</tt> operations. It does not * support the <tt>add</tt> or <tt>addAll</tt> operations. * * @return a collection view of the values contained in this map */ T#E#Collection valueCollection(); /** * Returns the values of the map as an array of <tt>#e#</tt> values. * Changes to the array of values will not be reflected in the map * nor vice-versa. * * @return the values of the map as an array of <tt>#e#</tt> values. */ #e#[] values(); /** * Returns the values of the map using an existing array. * Changes to the array of values will not be reflected in the map * nor vice-versa. * * @param array the array into which the elements of the list are to be stored, * if it is big enough; otherwise, a new array of the same type is * allocated for this purpose. * @return the values of the map as an array of <tt>#e#</tt> values. */ #e#[] values( #e#[] array ); /** * Returns a <tt>TObject#E#Iterator</tt> with access to this map's keys and values. * * @return a <tt>TObject#E#Iterator</tt> with access to this map's keys and values. */ public TObject#E#Iterator iterator(); /** * Increments the primitive value mapped to key by 1 * * @param key the key of the value to increment * @return true if a mapping was found and modified. */ public boolean increment( K key ); /** * Adjusts the primitive value mapped to key. * * @param key the key of the value to increment * @param amount the amount to adjust the value by. * @return true if a mapping was found and modified. */ public boolean adjustValue( K key, #e# amount ); /** * Adjusts the primitive value mapped to the key if the key is present in the map. * Otherwise, the <tt>initial_value</tt> is put in the map. * * @param key the key of the value to increment * @param adjust_amount the amount to adjust the value by * @param put_amount the value put into the map if the key is not initial present * * @return the value present in the map after the adjustment or put operation */ public #e# adjustOrPutValue( K key, #e# adjust_amount, #e# put_amount ); /** * Executes <tt>procedure</tt> for each key in the map. * * @param procedure a <code>TObjectProcedure</code> value * @return false if the loop over the keys terminated because * the procedure returned false for some key. */ public boolean forEachKey( TObjectProcedure<K> procedure ); /** * Executes <tt>procedure</tt> for each value in the map. * * @param procedure a <code>T#E#Procedure</code> value * @return false if the loop over the values terminated because * the procedure returned false for some value. */ public boolean forEachValue( T#E#Procedure procedure ); /** * Executes <tt>procedure</tt> for each key/value entry in the * map. * * @param procedure a <code>TOObject#E#Procedure</code> value * @return false if the loop over the entries terminated because * the procedure returned false for some entry. */ public boolean forEachEntry( TObject#E#Procedure<K> procedure ); /** * Transform the values in this map using <tt>function</tt>. * * @param function a <code>T#E#Function</code> value */ public void transformValues( T#E#Function function ); /** * Retains only those entries in the map for which the procedure * returns a true value. * * @param procedure determines which entries to keep * @return true if the map was modified. */ public boolean retainEntries( TObject#E#Procedure<K> procedure ); // Comparison and hashing /** * Compares the specified object with this map for equality. Returns * <tt>true</tt> if the given object is also a map and the two maps * represent the same mappings. More formally, two maps <tt>m1</tt> and * <tt>m2</tt> represent the same mappings if * <tt>m1.entrySet().equals(m2.entrySet())</tt>. This ensures that the * <tt>equals</tt> method works properly across different implementations * of the <tt>Map</tt> interface. * * @param o object to be compared for equality with this map * @return <tt>true</tt> if the specified object is equal to this map */ boolean equals( Object o ); /** * Returns the hash code value for this map. The hash code of a map is * defined to be the sum of the hash codes of each entry in the map's * <tt>entrySet()</tt> view. This ensures that <tt>m1.equals(m2)</tt> * implies that <tt>m1.hashCode()==m2.hashCode()</tt> for any two maps * <tt>m1</tt> and <tt>m2</tt>, as required by the general contract of * {@link Object#hashCode}. * * @return the hash code value for this map * @see TObject#E#Map.Entry#hashCode() * @see Object#equals(Object) * @see #equals(Object) */ int hashCode(); } 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.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** _K__V_Map.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 --- _K__V_Map.template 14 Sep 2009 19:02:20 -0000 1.1.2.4 *************** *** 43,53 **** --- 43,58 ---- * entry exists for a given key. The default value is generally zero, but can be * changed during construction of the collection. + * + * @return the value that represents a null key in this collection. */ public #k# getNoEntryKey(); + /** * 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. + * + * @return the value that represents a null value in this collection. */ public #v# getNoEntryValue(); *************** *** 108,112 **** /** * Empties the map. - * */ public void clear(); --- 113,116 ---- *************** *** 116,120 **** * 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(); --- 120,124 ---- * Returns <tt>true</tt> if this map contains no key-value mappings. * ! * @return <tt>true</tt> if this map contains no key-value mappings */ public boolean isEmpty(); *************** *** 134,137 **** --- 138,143 ---- /** * Returns an <tt>int</tt> value that is the number of elements in the map. + * + * @return an <tt>int</tt> value that is the number of elements in the map. */ public int size(); *************** *** 140,143 **** --- 146,151 ---- /** * Returns the keys of the map as a <tt>T#K#Set</tt> + * + * @return the keys of the map as a <tt>T#K#Set</tt> */ public T#K#Set keySet(); *************** *** 145,149 **** /** ! * Returns the keys of the map. */ public #k#[] keys(); --- 153,159 ---- /** ! * Returns the keys of the map as an array of <tt>#k#</tt> values. ! * ! * @return the keys of the map as an array of <tt>#k#</tt> values. */ public #k#[] keys(); *************** *** 156,159 **** --- 166,170 ---- * if it is big enough; otherwise, a new array of the same type is * allocated for this purpose. + * @return the keys of the map as an array. */ public #k#[] keys( #k#[] array ); *************** *** 162,165 **** --- 173,178 ---- /** * Returns the values of the map as a <tt>T#V#Collection</tt> + * + * @return the values of the map as a <tt>T#V#Collection</tt> */ public T#V#Collection valueCollection(); *************** *** 167,171 **** /** ! * Returns the values of the map. */ public #v#[] values(); --- 180,186 ---- /** ! * Returns the values of the map as an array of <tt>#e#</tt> values. ! * ! * @return the values of the map as an array of <tt>#e#</tt> values. */ public #v#[] values(); *************** *** 178,181 **** --- 193,197 ---- * if it is big enough; otherwise, a new array of the same type is * allocated for this purpose. + * @return the values of the map as an array of <tt>#e#</tt> values. */ public #v#[] values( #v#[] array ); *************** *** 211,215 **** * @param procedure a <code>T#K#Procedure</code> value * @return false if the loop over the keys terminated because ! * the procedure returned false for some key. */ public boolean forEachKey( T#K#Procedure procedure ); --- 227,231 ---- * @param procedure a <code>T#K#Procedure</code> value * @return false if the loop over the keys terminated because ! * the procedure returned false for some key. */ public boolean forEachKey( T#K#Procedure procedure ); *************** *** 221,225 **** * @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. */ public boolean forEachValue( T#V#Procedure procedure ); --- 237,241 ---- * @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. */ public boolean forEachValue( T#V#Procedure procedure ); *************** *** 232,236 **** * @param procedure a <code>TO#K##V#Procedure</code> value * @return false if the loop over the entries terminated because ! * the procedure returned false for some entry. */ public boolean forEachEntry( T#K##V#Procedure procedure ); --- 248,252 ---- * @param procedure a <code>TO#K##V#Procedure</code> value * @return false if the loop over the entries terminated because ! * the procedure returned false for some entry. */ public boolean forEachEntry( T#K##V#Procedure procedure ); |