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: Eric F. <er...@us...> - 2002-07-08 23:54:16
|
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv9682 Modified Files: SerializationProcedure.java Log Message: formatting foo Index: SerializationProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/SerializationProcedure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SerializationProcedure.java 8 Jul 2002 23:52:57 -0000 1.2 --- SerializationProcedure.java 8 Jul 2002 23:54:13 -0000 1.3 *************** *** 74,128 **** SerializationProcedure (ObjectOutputStream stream) { ! this.stream = stream; } public boolean execute(int val) { ! try { ! stream.writeInt(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(double val) { ! try { ! stream.writeDouble(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(long val) { ! try { ! stream.writeLong(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(float val) { ! try { ! stream.writeFloat(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(Object val) { ! try { ! stream.writeObject(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } --- 74,128 ---- SerializationProcedure (ObjectOutputStream stream) { ! this.stream = stream; } public boolean execute(int val) { ! try { ! stream.writeInt(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(double val) { ! try { ! stream.writeDouble(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(long val) { ! try { ! stream.writeLong(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(float val) { ! try { ! stream.writeFloat(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } public boolean execute(Object val) { ! try { ! stream.writeObject(val); ! } catch (IOException e) { ! this.exception = e; ! return false; ! } ! return true; } |
From: Eric F. <er...@us...> - 2002-07-08 23:53:00
|
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv9377 Modified Files: SerializationProcedure.java Log Message: formatting foo Index: SerializationProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/SerializationProcedure.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SerializationProcedure.java 8 Jul 2002 00:51:20 -0000 1.1 --- SerializationProcedure.java 8 Jul 2002 23:52:57 -0000 1.2 *************** *** 40,73 **** class SerializationProcedure implements TDoubleDoubleProcedure, ! TDoubleFloatProcedure, ! TDoubleIntProcedure, ! TDoubleLongProcedure, ! TDoubleObjectProcedure, ! TDoubleProcedure, ! TFloatDoubleProcedure, ! TFloatFloatProcedure, ! TFloatIntProcedure, ! TFloatLongProcedure, ! TFloatObjectProcedure, ! TFloatProcedure, ! TIntDoubleProcedure, ! TIntFloatProcedure, ! TIntIntProcedure, ! TIntLongProcedure, ! TIntObjectProcedure, ! TIntProcedure, ! TLongDoubleProcedure, ! TLongFloatProcedure, ! TLongIntProcedure, ! TLongLongProcedure, ! TLongObjectProcedure, ! TLongProcedure, ! TObjectDoubleProcedure, ! TObjectFloatProcedure, ! TObjectIntProcedure, ! TObjectLongProcedure, ! TObjectObjectProcedure, ! TObjectProcedure { ! ObjectOutputStream stream; IOException exception; --- 40,74 ---- class SerializationProcedure implements TDoubleDoubleProcedure, ! TDoubleFloatProcedure, ! TDoubleIntProcedure, ! TDoubleLongProcedure, ! TDoubleObjectProcedure, ! TDoubleProcedure, ! TFloatDoubleProcedure, ! TFloatFloatProcedure, ! TFloatIntProcedure, ! TFloatLongProcedure, ! TFloatObjectProcedure, ! TFloatProcedure, ! TIntDoubleProcedure, ! TIntFloatProcedure, ! TIntIntProcedure, ! TIntLongProcedure, ! TIntObjectProcedure, ! TIntProcedure, ! TLongDoubleProcedure, ! TLongFloatProcedure, ! TLongIntProcedure, ! TLongLongProcedure, ! TLongObjectProcedure, ! TLongProcedure, ! TObjectDoubleProcedure, ! TObjectFloatProcedure, ! TObjectIntProcedure, ! TObjectLongProcedure, ! TObjectObjectProcedure, ! TObjectProcedure { ! ! private final ObjectOutputStream stream; IOException exception; |
From: Eric F. <er...@us...> - 2002-07-08 00:51:22
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv32467 Modified Files: build.xml Log Message: bug fixes for TIntArrayList: clone is now a correct deep clone. toNativeArray no longer raises an arrayindexoutofboundsexception when used to copy an array slice into a small native array. enhancements: TIntArrayList now serializes only the data in the list, not the extra capacity. Added package private SerializationProcedure class that replaces the various WriteProcedure inner classes that were used in a bunch of places. This eliminates several class files from the trove jar, since SerializationProcedure does the job of writing data on an ObjectOutputStream for all of the collection types. Index: build.xml =================================================================== RCS file: /cvsroot/trove4j/trove/build.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** build.xml 19 Apr 2002 03:31:58 -0000 1.19 --- build.xml 8 Jul 2002 00:51:20 -0000 1.20 *************** *** 10,14 **** <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.5"/> <property name="year" value="2001-2002"/> --- 10,14 ---- <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.6"/> <property name="year" value="2001-2002"/> |
From: Eric F. <er...@us...> - 2002-06-18 05:06:00
|
Update of /cvsroot/trove4j/trove_web/images In directory usw-pr-cvs1:/tmp/cvs-serv21035/images Added Files: trove.gif Log Message: added gif from ORA article --- NEW FILE: trove.gif --- GIF89ao öõôW. |pgîìëÿÿÿ, ´¡EaÄXâdØeÍÿ.lòôbóàMElÙ0¢;Ù(@?@rêÝ!6 z¤Y_ÙIØqC¡©È¢k-ÈÝ-bÎ%~ñ]\ §}Bçc?@uÙïñv¹ádW2iÖMÑ¢~×A\Wå9B8!câUEpu9)¸&P|#×f`{þ Ãll®¨åZ1aXdÁ0 dây_(;~1%ïÕµ¤"9aèÇ\¾iJJ"ÀðÉ28 T>5Õeª¸@R8uÀ.ÒB °ÞtéRJjUB¤Ã*M7[,(eº4˲Ñ4ÊM99Ì\F´<ÇR²´¬i:Ü:ÖB`1ÿµ°Q©áô ÁE©Q]t°Ð»íÞô^¶cæè¨fgN¨ÃIV'W /Ĩ·4RNL ØÇÛYßÁÝW/HÍ}uQ7ÂY³fi9`ÓZ>DZVLehs».Ôf¡Oe# oL 9B½/ÐÀ±PUÖJ#ì²³Îaiµ\ïÒ¨\É ¨r¥#iåÞË'EÆrÕ¿ î]¬ÕñHiÕÅWsàÁÞõg°Ñio *XöÇ»ã°D¶À³BòþDàÂö]pVÄðF5JHßùÒ'ö¡ 6¨ OKÒ \0wH¸°&0ÍòG0-â+Y× HÆ```TØ@UNgn#]ÊÐÂ)9o<ûÊß(ðä/#èÃyH L ÖX nN!Å[ÈFÒÅ´I5°QqB&Ê<Cc¡IÛÒxê4¸|¨B¸¡>Ш´É ®&ëA}i»Hv8m x¶4ãPuy]ØREgwï^m·²Hµ@Ú|ËN º$8o"UxÑÁÌ ¯~×qVøÄÞDhB9kË¢S{ &E~ÅûK@>q7ÌbÎQ4ÐfCì཰Úc $A R¥É=þµg÷nyËPt¨s0æeë»7Áóä´[<$ÐCÕ- Ø#¶·üæ×ÛÞ9Ð÷ V¾èâyÅ3îÈ ×MÖÀDZzVÃ_þ"¨ïo¯<ßGz Ð~x-À>`Xvphz(ø§t5 |
From: Eric F. <er...@us...> - 2002-06-18 05:05:37
|
Update of /cvsroot/trove4j/trove_web/images In directory usw-pr-cvs1:/tmp/cvs-serv20955/images Log Message: Directory /cvsroot/trove4j/trove_web/images added to the repository |
From: Eric F. <er...@us...> - 2002-06-15 15:47:38
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv12315 Modified Files: index.shtml Log Message: added pointer to ORA article Index: index.shtml =================================================================== RCS file: /cvsroot/trove4j/trove_web/index.shtml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.shtml 19 Jan 2002 20:07:48 -0000 1.3 --- index.shtml 15 Jun 2002 15:47:34 -0000 1.4 *************** *** 32,35 **** --- 32,46 ---- <p> + O'Reilly's On Java service published an article devoted to Trove: + <a href="http://www.onjava.com/pub/a/onjava/2002/06/12/trove.html">Enhance + Collection Performance with this Treasure Trove</a>. One factual + quibble: the author reports that Map.keySet(), Map.valueSet(), and + Map.entrySet() all trigger creation of Map.Entry instances that + Trove otherwise avoids. In fact, this is only true of Map.entrySet(), + whose API requires that the implementation return instances of + Map.Entry. So, <b>use Map.keySet() and Map.valueSet() without fear.</b> + </p> + + <p> Download the <a href="http://sourceforge.net/project/showfiles.php?group_id=39235">latest release</a>. </p> |
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv13180/src/gnu/trove Modified Files: TDoubleDoubleHashMap.java TDoubleFloatHashMap.java TDoubleIntHashMap.java TDoubleLongHashMap.java TDoubleObjectHashMap.java TFloatDoubleHashMap.java TFloatFloatHashMap.java TFloatIntHashMap.java TFloatLongHashMap.java TFloatObjectHashMap.java THashMap.java THashMapTests.java TIntDoubleHashMap.java TIntFloatHashMap.java TIntIntHashMap.java TIntIntHashMapTests.java TIntLongHashMap.java TIntObjectHashMap.java TLongDoubleHashMap.java TLongFloatHashMap.java TLongIntHashMap.java TLongLongHashMap.java TLongObjectHashMap.java TObjectDoubleHashMap.java TObjectFloatHashMap.java TObjectIntHashMap.java TObjectLongHashMap.java gen_obj_primitive_map.pl gen_primitive_map.pl Log Message: release 0.1.5 added retainEntries methods to all Map classes. These methods accept procedure objects of the appropriate sort and use the return value of those procedures to determine whether or not a particular entry in the map should be retained. This is useful for applying a cutoff in a map without copying data: TIntIntHashMap map = new TIntIntHashMap(); // load up map map.retainEntries(new TIntIntProcedure() { public boolean execute(int key, int val) { return val > 3; // retain only those mappings with val > 3 } }); It can also be used if you want to reduce one map to the intersection between it and another map: THashMap map1 = new THashMap(); THashMap map2 = new THashMap(); // load up both maps map1.retainEntries(new TObjectObjectProcedure() { public boolean execute(Object key, Object val) { return map2.containsKey(key); // retain the intersection with map2 } }); Index: TDoubleDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleDoubleHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TDoubleDoubleHashMap.java 9 Apr 2002 04:00:28 -0000 1.8 --- TDoubleDoubleHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TDoubleDoubleProcedure procedure) { + boolean modified = false; + byte[] states = _states; + double[] keys = _set; + double[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TDoubleFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleFloatHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TDoubleFloatHashMap.java 9 Apr 2002 04:00:28 -0000 1.8 --- TDoubleFloatHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TDoubleFloatProcedure procedure) { + boolean modified = false; + byte[] states = _states; + double[] keys = _set; + float[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TDoubleIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleIntHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TDoubleIntHashMap.java 9 Apr 2002 04:00:28 -0000 1.8 --- TDoubleIntHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TDoubleIntProcedure procedure) { + boolean modified = false; + byte[] states = _states; + double[] keys = _set; + int[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TDoubleLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleLongHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TDoubleLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TDoubleLongHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TDoubleLongProcedure procedure) { + boolean modified = false; + byte[] states = _states; + double[] keys = _set; + long[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TDoubleObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleObjectHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TDoubleObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TDoubleObjectHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 361,364 **** --- 361,385 ---- /** + * 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(TDoubleObjectProcedure procedure) { + boolean modified = false; + byte[] states = _states; + double[] keys = _set; + Object[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TFloatDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatDoubleHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TFloatDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TFloatDoubleHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TFloatDoubleProcedure procedure) { + boolean modified = false; + byte[] states = _states; + float[] keys = _set; + double[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TFloatFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatFloatHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TFloatFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TFloatFloatHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TFloatFloatProcedure procedure) { + boolean modified = false; + byte[] states = _states; + float[] keys = _set; + float[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TFloatIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatIntHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TFloatIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TFloatIntHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TFloatIntProcedure procedure) { + boolean modified = false; + byte[] states = _states; + float[] keys = _set; + int[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TFloatLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatLongHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TFloatLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TFloatLongHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TFloatLongProcedure procedure) { + boolean modified = false; + byte[] states = _states; + float[] keys = _set; + long[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TFloatObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatObjectHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TFloatObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TFloatObjectHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 361,364 **** --- 361,385 ---- /** + * Retains only those entries in the map for which the procedure + * returns a true value. + * + * @param procedure determines which entries to keep + * @return true if the map was modified. + */ + public boolean retainEntries(TFloatObjectProcedure procedure) { + boolean modified = false; + byte[] states = _states; + float[] keys = _set; + Object[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: THashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** THashMap.java 19 Jan 2002 19:40:10 -0000 1.8 --- THashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 196,214 **** /** - * Transform the values in this map using <tt>function</tt>. - * - * @param function a <code>TObjectFunction</code> value - */ - public void transformValues(TObjectFunction function) { - Object[] values = _values; - Object[] set = _set; - for (int i = values.length; i-- > 0;) { - if (set[i] != null && set[i] != REMOVED) { - values[i] = function.execute(values[i]); - } - } - } - - /** * Executes <tt>procedure</tt> for each key/value entry in the * map. --- 196,199 ---- *************** *** 229,232 **** --- 214,254 ---- } return true; + } + + /** + * 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(TObjectObjectProcedure procedure) { + boolean modified = false; + Object[] keys = _set; + Object[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (keys[i] != null + && keys[i] != REMOVED + && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** + * Transform the values in this map using <tt>function</tt>. + * + * @param function a <code>TObjectFunction</code> value + */ + public void transformValues(TObjectFunction function) { + Object[] values = _values; + Object[] set = _set; + for (int i = values.length; i-- > 0;) { + if (set[i] != null && set[i] != REMOVED) { + values[i] = function.execute(values[i]); + } + } } Index: THashMapTests.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashMapTests.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** THashMapTests.java 28 Dec 2001 20:04:39 -0000 1.7 --- THashMapTests.java 19 Apr 2002 03:31:58 -0000 1.8 *************** *** 291,293 **** --- 291,310 ---- assertEquals(mm, mm2); } + + public void testRetainEntries() throws Exception { + THashMap mm = new THashMap(); + mm.put("a", "b"); + mm.put("c", "b"); + mm.put("d", "b"); + + mm.retainEntries(new TObjectObjectProcedure() { + public boolean execute(Object key, Object val) { + return key.equals("c"); + } + }); + + assertEquals(1, mm.size()); + assertTrue(mm.containsKey("c")); + assertEquals("b", mm.get("c")); + } } // THashMapTests Index: TIntDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntDoubleHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TIntDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TIntDoubleHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TIntDoubleProcedure procedure) { + boolean modified = false; + byte[] states = _states; + int[] keys = _set; + double[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TIntFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntFloatHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TIntFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TIntFloatHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TIntFloatProcedure procedure) { + boolean modified = false; + byte[] states = _states; + int[] keys = _set; + float[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TIntIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntIntHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TIntIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TIntIntHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TIntIntProcedure procedure) { + boolean modified = false; + byte[] states = _states; + int[] keys = _set; + int[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TIntIntHashMapTests.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntIntHashMapTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TIntIntHashMapTests.java 9 Apr 2002 04:00:29 -0000 1.2 --- TIntIntHashMapTests.java 19 Apr 2002 03:31:58 -0000 1.3 *************** *** 73,75 **** --- 73,97 ---- assertEquals(57, mm.get(1)); } + + public void testRetainEntries() throws Exception { + TIntIntHashMap mm = new TIntIntHashMap(); + mm.put(1,2); + mm.put(3,4); + mm.put(99,12); + mm.put(-362, 9); + mm.put(-99999,387); + + mm.retainEntries(new TIntIntProcedure() { + public boolean execute(int key, int val) { + return key > 0; + } + }); + + assertEquals(3, mm.size()); + assertEquals(2, mm.get(1)); + assertEquals(4, mm.get(3)); + assertEquals(12, mm.get(99)); + assertTrue(! mm.containsKey(-362)); + assertTrue(! mm.containsKey(-99999)); + } } // TIntIntHashMapTests Index: TIntLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntLongHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TIntLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TIntLongHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TIntLongProcedure procedure) { + boolean modified = false; + byte[] states = _states; + int[] keys = _set; + long[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TIntObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntObjectHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TIntObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TIntObjectHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 361,364 **** --- 361,385 ---- /** + * 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(TIntObjectProcedure procedure) { + boolean modified = false; + byte[] states = _states; + int[] keys = _set; + Object[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TLongDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongDoubleHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TLongDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TLongDoubleHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TLongDoubleProcedure procedure) { + boolean modified = false; + byte[] states = _states; + long[] keys = _set; + double[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TLongFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongFloatHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TLongFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TLongFloatHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TLongFloatProcedure procedure) { + boolean modified = false; + byte[] states = _states; + long[] keys = _set; + float[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TLongIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongIntHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TLongIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TLongIntHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TLongIntProcedure procedure) { + boolean modified = false; + byte[] states = _states; + long[] keys = _set; + int[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TLongLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongLongHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TLongLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TLongLongHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 349,352 **** --- 349,373 ---- /** + * 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(TLongLongProcedure procedure) { + boolean modified = false; + byte[] states = _states; + long[] keys = _set; + long[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TLongObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongObjectHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TLongObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TLongObjectHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 361,364 **** --- 361,385 ---- /** + * 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(TLongObjectProcedure procedure) { + boolean modified = false; + byte[] states = _states; + long[] keys = _set; + Object[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TObjectDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectDoubleHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TObjectDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TObjectDoubleHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 343,346 **** --- 343,368 ---- /** + * 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(TObjectDoubleProcedure procedure) { + boolean modified = false; + Object[] keys = _set; + double[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (keys[i] != null + && keys[i] != REMOVED + && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TObjectFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectFloatHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TObjectFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TObjectFloatHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 343,346 **** --- 343,368 ---- /** + * 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(TObjectFloatProcedure procedure) { + boolean modified = false; + Object[] keys = _set; + float[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (keys[i] != null + && keys[i] != REMOVED + && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TObjectIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectIntHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TObjectIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TObjectIntHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 343,346 **** --- 343,368 ---- /** + * 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(TObjectIntProcedure procedure) { + boolean modified = false; + Object[] keys = _set; + int[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (keys[i] != null + && keys[i] != REMOVED + && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: TObjectLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectLongHashMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TObjectLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 --- TObjectLongHashMap.java 19 Apr 2002 03:31:58 -0000 1.9 *************** *** 343,346 **** --- 343,368 ---- /** + * 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(TObjectLongProcedure procedure) { + boolean modified = false; + Object[] keys = _set; + long[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (keys[i] != null + && keys[i] != REMOVED + && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: gen_obj_primitive_map.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_obj_primitive_map.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gen_obj_primitive_map.pl 9 Apr 2002 04:00:29 -0000 1.2 --- gen_obj_primitive_map.pl 19 Apr 2002 03:31:59 -0000 1.3 *************** *** 415,418 **** --- 415,440 ---- /** + * 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<ValueType>Procedure procedure) { + boolean modified = false; + Object[] keys = _set; + <valueType>[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (keys[i] != null + && keys[i] != REMOVED + && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * Index: gen_primitive_map.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_primitive_map.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gen_primitive_map.pl 9 Apr 2002 04:00:29 -0000 1.8 --- gen_primitive_map.pl 19 Apr 2002 03:31:59 -0000 1.9 *************** *** 474,477 **** --- 474,498 ---- /** + * 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<KeyType><ValueType>Procedure procedure) { + boolean modified = false; + byte[] states = _states; + <keyType>[] keys = _set; + <valueType>[] values = _values; + for (int i = keys.length; i-- > 0;) { + if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) { + removeAt(i); + modified = true; + } + } + return modified; + } + + /** * Transform the values in this map using <tt>function</tt>. * |
From: Eric F. <er...@us...> - 2002-04-19 03:32:02
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv13180 Modified Files: ChangeLog build.xml Log Message: release 0.1.5 added retainEntries methods to all Map classes. These methods accept procedure objects of the appropriate sort and use the return value of those procedures to determine whether or not a particular entry in the map should be retained. This is useful for applying a cutoff in a map without copying data: TIntIntHashMap map = new TIntIntHashMap(); // load up map map.retainEntries(new TIntIntProcedure() { public boolean execute(int key, int val) { return val > 3; // retain only those mappings with val > 3 } }); It can also be used if you want to reduce one map to the intersection between it and another map: THashMap map1 = new THashMap(); THashMap map2 = new THashMap(); // load up both maps map1.retainEntries(new TObjectObjectProcedure() { public boolean execute(Object key, Object val) { return map2.containsKey(key); // retain the intersection with map2 } }); Index: ChangeLog =================================================================== RCS file: /cvsroot/trove4j/trove/ChangeLog,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ChangeLog 9 Apr 2002 04:00:28 -0000 1.14 --- ChangeLog 19 Apr 2002 03:31:58 -0000 1.15 *************** *** 1,2 **** --- 1,31 ---- + v 0.1.5 + + added retainEntries methods to all Map classes. These methods accept + procedure objects of the appropriate sort and use the return value of + those procedures to determine whether or not a particular entry in the + map should be retained. + + This is useful for applying a cutoff in a map without copying data: + + TIntIntHashMap map = new TIntIntHashMap(); + // load up map + map.retainEntries(new TIntIntProcedure() { + public boolean execute(int key, int val) { + return val > 3; // retain only those mappings with val > 3 + } + }); + + It can also be used if you want to reduce one map to the intersection + between it and another map: + + THashMap map1 = new THashMap(); + THashMap map2 = new THashMap(); + // load up both maps + map1.retainEntries(new TObjectObjectProcedure() { + public boolean execute(Object key, Object val) { + return map2.containsKey(key); // retain the intersection with map2 + } + }); + v 0.1.4 Index: build.xml =================================================================== RCS file: /cvsroot/trove4j/trove/build.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** build.xml 9 Apr 2002 04:00:28 -0000 1.18 --- build.xml 19 Apr 2002 03:31:58 -0000 1.19 *************** *** 10,14 **** <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.4"/> <property name="year" value="2001-2002"/> --- 10,14 ---- <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.5"/> <property name="year" value="2001-2002"/> |
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv25832/src/gnu/trove Modified Files: TDoubleDoubleHashMap.java TDoubleFloatHashMap.java TDoubleIntHashMap.java TDoubleLongHashMap.java TDoubleObjectHashMap.java TFloatDoubleHashMap.java TFloatFloatHashMap.java TFloatIntHashMap.java TFloatLongHashMap.java TFloatObjectHashMap.java TIntDoubleHashMap.java TIntFloatHashMap.java TIntIntHashMap.java TIntIntHashMapTests.java TIntLongHashMap.java TIntObjectHashMap.java TLongDoubleHashMap.java TLongFloatHashMap.java TLongIntHashMap.java TLongLongHashMap.java TLongObjectHashMap.java TObjectDoubleHashMap.java TObjectFloatHashMap.java TObjectIntHashMap.java TObjectLongHashMap.java gen_obj_primitive_map.pl gen_primitive_map.pl Log Message: added increment, adjustValue methods to maps with primitive values. Thanks to Jason for the idea. Index: TDoubleDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleDoubleHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TDoubleDoubleHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TDoubleDoubleHashMap.java 9 Apr 2002 04:00:28 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(double key) { + return adjustValue(key, (double)1); + } + + /** + * 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(double key, double amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TDoubleFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleFloatHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TDoubleFloatHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TDoubleFloatHashMap.java 9 Apr 2002 04:00:28 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(double key) { + return adjustValue(key, (float)1); + } + + /** + * 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(double key, float amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TDoubleIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleIntHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TDoubleIntHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TDoubleIntHashMap.java 9 Apr 2002 04:00:28 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(double key) { + return adjustValue(key, (int)1); + } + + /** + * 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(double key, int amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TDoubleLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleLongHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TDoubleLongHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TDoubleLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(double key) { + return adjustValue(key, (long)1); + } + + /** + * 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(double key, long amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TDoubleObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleObjectHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TDoubleObjectHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TDoubleObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 375,378 **** --- 375,380 ---- } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TFloatDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatDoubleHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TFloatDoubleHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TFloatDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(float key) { + return adjustValue(key, (double)1); + } + + /** + * 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(float key, double amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TFloatFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatFloatHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TFloatFloatHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TFloatFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(float key) { + return adjustValue(key, (float)1); + } + + /** + * 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(float key, float amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TFloatIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatIntHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TFloatIntHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TFloatIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(float key) { + return adjustValue(key, (int)1); + } + + /** + * 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(float key, int amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TFloatLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatLongHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TFloatLongHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TFloatLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(float key) { + return adjustValue(key, (long)1); + } + + /** + * 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(float key, long amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TFloatObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatObjectHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TFloatObjectHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TFloatObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 375,378 **** --- 375,380 ---- } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TIntDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntDoubleHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TIntDoubleHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TIntDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(int key) { + return adjustValue(key, (double)1); + } + + /** + * 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(int key, double amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TIntFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntFloatHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TIntFloatHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TIntFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(int key) { + return adjustValue(key, (float)1); + } + + /** + * 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(int key, float amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TIntIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntIntHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TIntIntHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TIntIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(int key) { + return adjustValue(key, (int)1); + } + + /** + * 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(int key, int amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TIntIntHashMapTests.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntIntHashMapTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TIntIntHashMapTests.java 3 Dec 2001 00:16:25 -0000 1.1 --- TIntIntHashMapTests.java 9 Apr 2002 04:00:29 -0000 1.2 *************** *** 52,54 **** --- 52,75 ---- assertEquals(mm, mm2); } + + public void testIncrement() throws Exception { + TIntIntHashMap mm = new TIntIntHashMap(); + mm.put(1,2); + mm.increment(1); + assertEquals(3, mm.get(1)); + } + + public void testAdjustValueNegative() throws Exception { + TIntIntHashMap mm = new TIntIntHashMap(); + mm.put(1,2); + mm.adjustValue(1, -2); + assertEquals(0, mm.get(1)); + } + + public void testAdjustValuePositive() throws Exception { + TIntIntHashMap mm = new TIntIntHashMap(); + mm.put(1,2); + mm.adjustValue(1, 55); + assertEquals(57, mm.get(1)); + } } // TIntIntHashMapTests Index: TIntLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntLongHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TIntLongHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TIntLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(int key) { + return adjustValue(key, (long)1); + } + + /** + * 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(int key, long amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TIntObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntObjectHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TIntObjectHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TIntObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 375,378 **** --- 375,380 ---- } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TLongDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongDoubleHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TLongDoubleHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TLongDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(long key) { + return adjustValue(key, (double)1); + } + + /** + * 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(long key, double amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TLongFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongFloatHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TLongFloatHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TLongFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(long key) { + return adjustValue(key, (float)1); + } + + /** + * 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(long key, float amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TLongIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongIntHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TLongIntHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TLongIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(long key) { + return adjustValue(key, (int)1); + } + + /** + * 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(long key, int amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TLongLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongLongHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TLongLongHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TLongLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 363,366 **** --- 363,394 ---- } + /** + * 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(long key) { + return adjustValue(key, (long)1); + } + + /** + * 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(long key, long amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TLongObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongObjectHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TLongObjectHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TLongObjectHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 375,378 **** --- 375,380 ---- } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TObjectDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectDoubleHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TObjectDoubleHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TObjectDoubleHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 357,360 **** --- 357,388 ---- } + /** + * 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(Object key) { + return adjustValue(key, (double)1); + } + + /** + * 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(Object key, double amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TObjectFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectFloatHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TObjectFloatHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TObjectFloatHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 357,360 **** --- 357,388 ---- } + /** + * 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(Object key) { + return adjustValue(key, (float)1); + } + + /** + * 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(Object key, float amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TObjectIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectIntHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TObjectIntHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TObjectIntHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 357,360 **** --- 357,388 ---- } + /** + * 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(Object key) { + return adjustValue(key, (int)1); + } + + /** + * 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(Object key, int amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: TObjectLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectLongHashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TObjectLongHashMap.java 14 Jan 2002 05:59:43 -0000 1.7 --- TObjectLongHashMap.java 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 357,360 **** --- 357,388 ---- } + /** + * 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(Object key) { + return adjustValue(key, (long)1); + } + + /** + * 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(Object key, long amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + + private void writeObject(final ObjectOutputStream stream) throws IOException { Index: gen_obj_primitive_map.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_obj_primitive_map.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gen_obj_primitive_map.pl 14 Jan 2002 05:59:43 -0000 1.1 --- gen_obj_primitive_map.pl 9 Apr 2002 04:00:29 -0000 1.2 *************** *** 3,7 **** use strict; use vars qw($code $containsPrimitiveValue ! $primitiveValueEQ); my @types = qw(int long double float); --- 3,7 ---- use strict; use vars qw($code $containsPrimitiveValue ! $incrementPrimitiveValue $primitiveValueEQ); my @types = qw(int long double float); *************** *** 11,14 **** --- 11,15 ---- my $c = $code; my $ValueType = ucfirst $valueType; + my $adjustValue; my $valueImpl = undef; *************** *** 18,21 **** --- 19,26 ---- $valueEQ = $primitiveValueEQ; $valueEQ =~ s/<valueType>/$valueType/g; + $adjustValue = $incrementPrimitiveValue; + $adjustValue =~ s/<valueType>/$valueType/g; + $adjustValue =~ s/<keyType>/Object/g; + $c =~ s/<valueType>/$valueType/g; $c =~ s/<ValueType>/$ValueType/g; *************** *** 23,26 **** --- 28,33 ---- $c =~ s/<containsValue>/$valueImpl/g; $c =~ s/<valueEQ>/$valueEQ/g; + $c =~ s/<adjustValue>/$adjustValue/g; + open FH, ">TObject${ValueType}HashMap.java" || die $!; print FH $c; *************** *** 38,41 **** --- 45,77 ---- EOF + $incrementPrimitiveValue = <<'EOF'; + /** + * 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(<keyType> key) { + return adjustValue(key, (<valueType>)1); + } + + /** + * 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(<keyType> key, <valueType> amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + EOF + $containsPrimitiveValue = <<'EOF'; /** *************** *** 392,395 **** --- 428,433 ---- } } + + <adjustValue> private void writeObject(final ObjectOutputStream stream) Index: gen_primitive_map.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_primitive_map.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gen_primitive_map.pl 14 Jan 2002 05:59:43 -0000 1.7 --- gen_primitive_map.pl 9 Apr 2002 04:00:29 -0000 1.8 *************** *** 3,7 **** use strict; use vars qw($code $containsObjectValue $containsPrimitiveValue ! $objectValueEQ $primitiveValueEQ); my @types = qw(Object int long double float); --- 3,7 ---- use strict; use vars qw($code $containsObjectValue $containsPrimitiveValue ! $incrementPrimitiveValue $objectValueEQ $primitiveValueEQ); my @types = qw(Object int long double float); *************** *** 16,19 **** --- 16,20 ---- my $c = $code; my $ValueType = ucfirst $valueType; + my $adjustValue; my $valueImpl = undef; *************** *** 22,25 **** --- 23,27 ---- $valueImpl = $containsObjectValue; $valueEQ = $objectValueEQ; + $adjustValue = ''; } else { $valueImpl = $containsPrimitiveValue; *************** *** 27,30 **** --- 29,35 ---- $valueEQ = $primitiveValueEQ; $valueEQ =~ s/<valueType>/$valueType/g; + $adjustValue = $incrementPrimitiveValue; + $adjustValue =~ s/<valueType>/$valueType/g; + $adjustValue =~ s/<keyType>/$keyType/g; } $c =~ s/<keyType>/$keyType/g; *************** *** 36,39 **** --- 41,45 ---- $c =~ s/<containsValue>/$valueImpl/g; $c =~ s/<valueEQ>/$valueEQ/g; + $c =~ s/<adjustValue>/$adjustValue/g; open FH, ">T${KeyType}${ValueType}HashMap.java" || die $!; print FH $c; *************** *** 61,64 **** --- 67,99 ---- EOF + $incrementPrimitiveValue = <<'EOF'; + /** + * 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(<keyType> key) { + return adjustValue(key, (<valueType>)1); + } + + /** + * 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(<keyType> key, <valueType> amount) { + int index = index(key); + if (index < 0) { + return false; + } else { + _values[index] += amount; + return true; + } + } + EOF + $containsObjectValue = <<'EOF'; /** *************** *** 452,455 **** --- 487,492 ---- } } + + <adjustValue> private void writeObject(final ObjectOutputStream stream) |
From: Eric F. <er...@us...> - 2002-04-09 04:00:33
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv25832 Modified Files: ChangeLog build.xml Log Message: added increment, adjustValue methods to maps with primitive values. Thanks to Jason for the idea. Index: ChangeLog =================================================================== RCS file: /cvsroot/trove4j/trove/ChangeLog,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ChangeLog 8 Apr 2002 03:33:52 -0000 1.13 --- ChangeLog 9 Apr 2002 04:00:28 -0000 1.14 *************** *** 1,2 **** --- 1,24 ---- + v 0.1.4 + + added increment() and adjustValue() methods to maps with primitive values. + These are useful in the all-too-common case where you need a map for the + purposes of counting the number of times a key is seen. These methods + are handy because you don't have to do a "containsKey" test prior to + every increment() call. Instead, you can check the return status (true + if an existing mapping was modified) and if it is false, then insert the + mapping with the initial value: + + TIntIntHashMap map = TIntIntHashMap(); + int key, val; + key = keyFromSomeWhere(); + val = valFromSomeWhere(); + if (! map.increment(key)) map.put(key, 0); + + increment is implemented in terms of adjustValue, which allows you + to specify the amount by which the primitive value associated with a + particular key should be adjusted. + + Thanks to Jason Baldridge for the idea. + v 0.1.3 Index: build.xml =================================================================== RCS file: /cvsroot/trove4j/trove/build.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** build.xml 8 Apr 2002 03:33:52 -0000 1.17 --- build.xml 9 Apr 2002 04:00:28 -0000 1.18 *************** *** 10,15 **** <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.3"/> ! <property name="year" value="2001"/> <echo message="----------- ${Name} ${version} [${year}] ------------"/> --- 10,15 ---- <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.4"/> ! <property name="year" value="2001-2002"/> <echo message="----------- ${Name} ${version} [${year}] ------------"/> |
From: Eric F. <er...@us...> - 2002-04-08 16:44:36
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv6638 Modified Files: ChangeLog build.xml Log Message: changes for the 0.1.3 release Index: ChangeLog =================================================================== RCS file: /cvsroot/trove4j/trove/ChangeLog,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ChangeLog 18 Jan 2002 16:40:08 -0000 1.12 --- ChangeLog 8 Apr 2002 03:33:52 -0000 1.13 *************** *** 1,2 **** --- 1,10 ---- + v 0.1.3 + + bug fix in TLinkedList ListIterator implementation: fixed remove() + behavior so that it correctly removes the last element returned by + either next() or previous(). Added several tests to suite to verify + that list iterator does what it's supposed to do in accordance with the + collections API docs. + v 0.1.2 Index: build.xml =================================================================== RCS file: /cvsroot/trove4j/trove/build.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** build.xml 14 Jan 2002 06:17:16 -0000 1.16 --- build.xml 8 Apr 2002 03:33:52 -0000 1.17 *************** *** 10,14 **** <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.2"/> <property name="year" value="2001"/> --- 10,14 ---- <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.3"/> <property name="year" value="2001"/> |
From: Eric F. <er...@us...> - 2002-04-08 15:43:53
|
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv21300/src/gnu/trove Modified Files: TLinkedList.java TLinkedListTests.java Log Message: fix for bug in TLinkedList reported by Sudhir Gupta Iterators returned by the linked list did not correctly implement ListIterator.remove() This has been fixed, and several unit tests have been added to guarantee that the new implementation is consistent with the contract specified in the ListIterator javadoc. Index: TLinkedList.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLinkedList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TLinkedList.java 3 Dec 2001 00:16:25 -0000 1.3 --- TLinkedList.java 8 Apr 2002 02:02:28 -0000 1.4 *************** *** 39,42 **** --- 39,51 ---- * interface.</p> * + * <p>The limitations are that you cannot put the same object into + * more than one list or more than once in the same list. You must + * also ensure that you only remove objects that are actually in the + * list. That is, if you have an object A and lists l1 and l2, you + * must ensure that you invoke List.remove(A) on the correct list. It + * is also forbidden to invoke List.remove() with an unaffiliated + * TLinkable (one that belongs to no list): this will destroy the list + * you invoke it on.</p> + * * <p> * Created: Sat Nov 10 15:25:10 2001 *************** *** 322,331 **** /** * A ListIterator that supports additions and deletions. * */ protected final class IteratorImpl implements ListIterator { ! private int _pos = 0; ! private TLinkable _cur; /** --- 331,408 ---- /** + * Removes the specified element from the list. Note that + * it is the caller's responsibility to ensure that the + * element does, in fact, belong to this list and not another + * instance of TLinkedList. + * + * @param o a TLinkable element already inserted in this list. + * @return true if the element was a TLinkable and removed + */ + public boolean remove(Object o) { + if (o instanceof TLinkable) { + TLinkable p, n; + TLinkable link = (TLinkable)o; + + p = link.getPrevious(); + n = link.getNext(); + + if (n == null && p == null) { // emptying the list + _head = _tail = null; + } else if (n == null) { // this is the tail + // make previous the new tail + link.setPrevious(null); + p.setNext(null); + _tail = p; + } else if (p == null) { // this is the head + // make next the new head + link.setNext(null); + n.setPrevious(null); + _head = n; + } else { // somewhere in the middle + p.setNext(n); + n.setPrevious(p); + link.setNext(null); + link.setPrevious(null); + } + + _size--; // reduce size of list + return true; + } else { + return false; + } + } + + /** + * Inserts newElement into the list immediately before current. + * All elements to the right of and including current are shifted + * over. + * + * @param current a <code>TLinkable</code> value currently in the list. + * @param newElement a <code>TLinkable</code> value to be added to + * the list. + */ + public void addBefore(TLinkable current, TLinkable newElement) { + if (current == _head) { + addFirst(newElement); + } else if (current == null) { + addLast(newElement); + } else { + TLinkable p = current.getPrevious(); + newElement.setNext(current); + p.setNext(newElement); + newElement.setPrevious(p); + current.setPrevious(newElement); + _size++; + } + } + + /** * A ListIterator that supports additions and deletions. * */ protected final class IteratorImpl implements ListIterator { ! private int _nextIndex = 0; ! private TLinkable _next; ! private TLinkable _lastReturned; /** *************** *** 336,353 **** */ IteratorImpl(int position) { ! _pos = position; if (position == 0) { ! _cur = _head; } else if (position == _size) { ! _cur = null; } else if (position < (_size >> 1)) { int pos = 0; ! for (_cur = _head; pos < position; pos++) { ! _cur = _cur.getNext(); } } else { int pos = _size - 1; ! for (_cur = _tail; pos > position; pos--) { ! _cur = _cur.getPrevious(); } } --- 413,434 ---- */ IteratorImpl(int position) { ! if (position < 0 || position > _size) { ! throw new IndexOutOfBoundsException(); ! } ! ! _nextIndex = position; if (position == 0) { ! _next = _head; } else if (position == _size) { ! _next = null; } else if (position < (_size >> 1)) { int pos = 0; ! for (_next = _head; pos < position; pos++) { ! _next = _next.getNext(); } } else { int pos = _size - 1; ! for (_next = _tail; pos > position; pos--) { ! _next = _next.getPrevious(); } } *************** *** 360,365 **** * @param linkable an object of type TLinkable */ ! public void add(Object linkable) { ! insert(_pos,linkable); } --- 441,453 ---- * @param linkable an object of type TLinkable */ ! public final void add(Object linkable) { ! _lastReturned = null; ! _nextIndex++; ! ! if (_size == 0) { ! TLinkedList.this.add(linkable); ! } else { ! TLinkedList.this.addBefore(_next, (TLinkable)linkable); ! } } *************** *** 369,374 **** * @return a <code>boolean</code> value */ ! public boolean hasNext() { ! return _pos < _size; } --- 457,462 ---- * @return a <code>boolean</code> value */ ! public final boolean hasNext() { ! return _nextIndex != _size; } *************** *** 378,383 **** * @return a <code>boolean</code> value */ ! public boolean hasPrevious() { ! return _pos > 0; } --- 466,471 ---- * @return a <code>boolean</code> value */ ! public final boolean hasPrevious() { ! return _nextIndex != 0; } *************** *** 389,411 **** * @exception NoSuchElementException if there is no next element */ ! public Object next() { ! Object o; ! ++_pos; ! o = _cur; ! _cur = _cur.getNext(); ! if (null == o) { throw new NoSuchElementException(); - } else { - return o; } } /** ! * returns the index of the next node. * * @return an <code>int</code> value */ ! public int nextIndex() { ! return _pos + 1; } --- 477,499 ---- * @exception NoSuchElementException if there is no next element */ ! public final Object next() { ! if (_nextIndex == _size) { throw new NoSuchElementException(); } + + _lastReturned = _next; + _next = _next.getNext(); + _nextIndex++; + return _lastReturned; } /** ! * returns the index of the next node in the list (the ! * one that would be returned by a call to next()). * * @return an <code>int</code> value */ ! public final int nextIndex() { ! return _nextIndex; } *************** *** 417,431 **** * @exception NoSuchElementException if there is no previous element. */ ! public Object previous() { ! --_pos; ! if (null == _cur) { ! _cur = _tail; } else { ! _cur = _cur.getPrevious(); ! if (null == _cur) { ! throw new NoSuchElementException(); ! } } ! return _cur; } --- 505,521 ---- * @exception NoSuchElementException if there is no previous element. */ ! public final Object previous() { ! if (_nextIndex == 0) { ! throw new NoSuchElementException(); ! } ! ! if (_nextIndex == _size) { ! _lastReturned = _next = _tail; } else { ! _lastReturned = _next = _next.getPrevious(); } ! ! _nextIndex--; ! return _lastReturned; } *************** *** 435,440 **** * @return an <code>int</code> value */ ! public int previousIndex() { ! return _pos - 1; } --- 525,530 ---- * @return an <code>int</code> value */ ! public final int previousIndex() { ! return _nextIndex - 1; } *************** *** 443,461 **** * size accordingly. * */ ! public void remove() { ! TLinkable p = _cur.getPrevious(); ! TLinkable n = _cur.getNext(); ! ! if (null != p) { ! p.setNext(n); } ! if (null != n) { ! n.setPrevious(p); } ! ! _cur = n; ! _size--; } --- 533,551 ---- * size accordingly. * + * @exception IllegalStateException neither next nor previous + * have been invoked, or remove or add have been invoked after + * the last invocation of next or previous. */ ! public final void remove() { ! if (_lastReturned == null) { ! throw new IllegalStateException("must invoke next or previous before invoking remove"); } ! if (_lastReturned != _next) { ! _nextIndex--; } ! _next = _lastReturned.getNext(); ! TLinkedList.this.remove(_lastReturned); ! _lastReturned = null; } *************** *** 466,487 **** * @param linkable an object of type TLinkable */ ! public void set(Object linkable) { TLinkable l = (TLinkable)linkable; - TLinkable p = _cur.getPrevious(); - TLinkable n = _cur.getNext(); ! if (null != p) { ! l.setPrevious(p); ! p.setNext(l); } ! if (null != n) { ! l.setNext(n); ! n.setPrevious(l); } ! _cur.setNext(null); ! _cur.setPrevious(null); ! _cur = l; } } --- 556,599 ---- * @param linkable an object of type TLinkable */ ! public final void set(Object linkable) { ! if (_lastReturned == null) { ! throw new IllegalStateException(); ! } TLinkable l = (TLinkable)linkable; ! // need to check both, since this could be the only ! // element in the list. ! if (_lastReturned == _head) { ! _head = l; } ! if (_lastReturned == _tail) { ! _tail = l; } ! swap(_lastReturned, l); ! _lastReturned = l; ! } ! ! /** ! * Replace from with to in the list. ! * ! * @param from a <code>TLinkable</code> value ! * @param to a <code>TLinkable</code> value ! */ ! private void swap(TLinkable from, TLinkable to) { ! TLinkable p = from.getPrevious(); ! TLinkable n = from.getNext(); ! ! if (null != p) { ! to.setPrevious(p); ! p.setNext(to); ! } ! if (null != n) { ! to.setNext(n); ! n.setPrevious(to); ! } ! from.setNext(null); ! from.setPrevious(null); } } Index: TLinkedListTests.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLinkedListTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TLinkedListTests.java 3 Dec 2001 00:16:25 -0000 1.2 --- TLinkedListTests.java 8 Apr 2002 02:02:28 -0000 1.3 *************** *** 105,108 **** --- 105,109 ---- i = list.listIterator(5); + i.next(); Data d = new Data(999); i.set(d); *************** *** 110,114 **** } ! public void testIteratorRemove() throws Exception { Data[] data = new Data[100]; for (int i = 0; i < data.length; i++) { --- 111,319 ---- } ! public void testRemoveOnlyElementInList() throws Exception { ! Data d = new Data(0); ! list.add(d); ! ListIterator i = list.listIterator(); ! assertTrue(i.hasNext()); ! assertEquals(d, i.next()); ! i.remove(); ! assertTrue(! i.hasNext()); ! assertTrue(! i.hasPrevious()); ! assertEquals(0, list.size()); ! } ! ! public void testRemovePrevious() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(list.size()); ! i.previous(); ! i.previous(); ! i.remove(); ! assertEquals(2, list.size()); ! assertTrue(i.hasPrevious()); ! assertEquals(d[0], i.previous()); ! assertTrue(! i.hasPrevious()); ! assertTrue(i.hasNext()); ! assertEquals(d[0], i.next()); ! assertTrue(i.hasNext()); ! assertEquals(d[2], i.next()); ! assertTrue(! i.hasNext()); ! assertTrue(i.hasPrevious()); ! assertEquals(2, list.size()); ! } ! ! public void testRemoveLast() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(list.size()); ! i.previous(); ! i.remove(); ! assertEquals(2, list.size()); ! assertTrue(i.hasPrevious()); ! assertTrue(! i.hasNext()); ! } ! ! public void testRemoveFirst() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(0); ! i.next(); ! i.remove(); ! assertEquals(2, list.size()); ! assertTrue(! i.hasPrevious()); ! assertTrue(i.hasNext()); ! } ! ! public void testRemoveNext() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(); ! assertTrue(i.hasNext()); ! i.next(); ! assertTrue(i.hasNext()); ! assertTrue(i.hasPrevious()); ! i.remove(); ! assertEquals(2, list.size()); ! assertTrue(! i.hasPrevious()); ! assertTrue(i.hasNext()); ! assertEquals(d[1], i.next()); ! assertTrue(i.hasNext()); ! assertEquals(d[2], i.next()); ! assertTrue(i.hasPrevious()); ! assertTrue(! i.hasNext()); ! } ! ! public void testRemoveThrowsAfterAdd() throws Exception { ! Data d = new Data(0); ! list.add(d); ! ListIterator i = list.listIterator(); ! boolean didThrow = false; ! ! try { ! i.remove(); ! } catch (IllegalStateException e) { ! didThrow = true; ! } // end of try-catch ! assertTrue(didThrow); ! } ! ! public void testRemoveThrowsWithoutPrevious() throws Exception { ! Data d = new Data(0); ! list.add(d); ! ListIterator i = list.listIterator(list.size()); ! boolean didThrow = false; ! ! assertTrue(i.hasPrevious()); ! try { ! i.remove(); ! } catch (IllegalStateException e) { ! didThrow = true; ! } // end of try-catch ! assertTrue(didThrow); ! } ! ! public void testRemoveThrowsWithoutNext() throws Exception { ! Data d = new Data(0); ! list.add(d); ! ListIterator i = list.listIterator(); ! boolean didThrow = false; ! ! assertTrue(i.hasNext()); ! try { ! i.remove(); ! } catch (IllegalStateException e) { ! didThrow = true; ! } // end of try-catch ! assertTrue(didThrow); ! } ! ! public void testIteratorAddFront() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(); ! Data d1 = new Data(5); ! assertTrue(! i.hasPrevious()); ! i.add(d1); ! assertTrue(i.hasPrevious()); ! assertEquals(d1, i.previous()); ! assertEquals(d1, i.next()); ! assertEquals(d[0], i.next()); ! assertEquals(d1, list.get(0)); ! } ! ! public void testIteratorAddBack() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(list.size()); ! Data d1 = new Data(5); ! assertEquals(3, list.size()); ! assertTrue(i.hasPrevious()); ! assertTrue(! i.hasNext()); ! i.add(d1); ! assertTrue(i.hasPrevious()); ! assertTrue(! i.hasNext()); ! assertEquals(4, list.size()); ! ! assertEquals(d1, i.previous()); ! assertEquals(d1, i.next()); ! assertEquals(d1, list.get(3)); ! } ! ! public void testIteratorAddMiddle() throws Exception { ! Data[] d = { new Data(0), new Data(1), new Data(2) }; ! list.addAll(Arrays.asList(d)); ! ! ListIterator i = list.listIterator(1); ! Data d1 = new Data(5); ! assertEquals(3, list.size()); ! assertTrue(i.hasPrevious()); ! assertTrue(i.hasNext()); ! i.add(d1); ! assertTrue(i.hasPrevious()); ! assertTrue(i.hasNext()); ! assertEquals(4, list.size()); ! ! assertEquals(d1, i.previous()); ! assertEquals(d1, i.next()); ! assertEquals(d1, list.get(1)); ! } ! ! public void testIteratorSetSingleElementList() throws Exception { ! Data d1 = new Data(5); ! Data d2 = new Data(4); ! list.add(d1); ! ! ListIterator i = list.listIterator(0); ! i.next(); ! i.set(d2); ! assertEquals(1, list.size()); ! assertTrue(! i.hasNext()); ! assertTrue(i.hasPrevious()); ! assertEquals(d2, i.previous()); ! assertTrue(i.hasNext()); ! assertTrue(! i.hasPrevious()); ! assertEquals(d2, i.next()); ! } ! ! public void testIteratorAddEmptyList() throws Exception { ! ListIterator i = list.listIterator(); ! Data d1 = new Data(5); ! assertTrue(! i.hasPrevious()); ! assertTrue(! i.hasNext()); ! i.add(d1); ! assertTrue(i.hasPrevious()); ! assertTrue(! i.hasNext()); ! assertEquals(d1, i.previous()); ! assertEquals(d1, i.next()); ! assertEquals(d1, list.get(0)); ! } ! ! public void testIteratorRemoveOnNext() throws Exception { Data[] data = new Data[100]; for (int i = 0; i < data.length; i++) { *************** *** 120,123 **** --- 325,329 ---- i = list.listIterator(5); + i.next(); i.remove(); Data d = new Data(6); |
From: Eric F. <er...@us...> - 2002-01-19 20:07:52
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv29007 Modified Files: index.shtml Log Message: html foo Index: index.shtml =================================================================== RCS file: /cvsroot/trove4j/trove_web/index.shtml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** index.shtml 2002/01/19 19:03:08 1.2 --- index.shtml 2002/01/19 20:07:48 1.3 *************** *** 14,18 **** <li>Provide "free" (as in "free speech" ! <i>and</i> "free beer"), fast, lightweight implementations of the <tt>java.util</tt> Collections API. These implementations are designed to be pluggable --- 14,19 ---- <li>Provide "free" (as in "free speech" ! <i>and</i> "free beer"), <a href="./benchmarks.shtml"> ! fast, lightweight</a> implementations of the <tt>java.util</tt> Collections API. These implementations are designed to be pluggable |
From: Eric F. <er...@us...> - 2002-01-19 19:48:18
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv25010 Modified Files: docs.shtml Log Message: html foo Index: docs.shtml =================================================================== RCS file: /cvsroot/trove4j/trove_web/docs.shtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** docs.shtml 2002/01/19 18:50:55 1.1.1.1 --- docs.shtml 2002/01/19 19:48:15 1.2 *************** *** 13,17 **** <p>Documentation is included in the release bundles. It is also ! <a href="javadocs">available here</a>.</p> <!--#include virtual="./navbar.html" --> --- 13,17 ---- <p>Documentation is included in the release bundles. It is also ! <a href="./javadocs/">available here</a>.</p> <!--#include virtual="./navbar.html" --> |
From: Eric F. <er...@us...> - 2002-01-19 19:40:13
|
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv23463 Modified Files: THashMap.java THashSet.java TPrimitiveHash.java Log Message: javadoc fixes Index: THashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** THashMap.java 2002/01/14 05:59:43 1.7 --- THashMap.java 2002/01/19 19:40:10 1.8 *************** *** 32,36 **** /** ! * An open addressed Map implementation. * * Created: Sun Nov 4 08:52:45 2001 --- 32,37 ---- /** ! * An implementation of the Map interface which uses an open addressed ! * hash table to store its contents. * * Created: Sun Nov 4 08:52:45 2001 Index: THashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashSet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** THashSet.java 2002/01/14 05:59:43 1.6 --- THashSet.java 2002/01/19 19:40:10 1.7 *************** *** 29,32 **** --- 29,34 ---- /** + * An implementation of the <tt>Set</tt> interface that uses an + * open-addressed hash table to store its contents. * * Created: Sat Nov 3 10:38:17 2001 Index: TPrimitiveHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TPrimitiveHash.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TPrimitiveHash.java 2002/01/14 05:59:43 1.1 --- TPrimitiveHash.java 2002/01/19 19:40:10 1.2 *************** *** 17,25 **** /////////////////////////////////////////////////////////////////////////////// - package gnu.trove; - /** * * Created: Fri Jan 11 18:55:16 2002 --- 17,29 ---- /////////////////////////////////////////////////////////////////////////////// package gnu.trove; /** + * The base class for hashtables of primitive values. Since there is + * no notion of object equality for primitives, it isn't possible to + * use a `REMOVED' object to track deletions in an open-addressed table. + * So, we have to resort to using a parallel `bookkeeping' array of bytes, + * in which flags can be set to indicate that a particular slot in the + * hash table is FREE, FULL, or REMOVED. * * Created: Fri Jan 11 18:55:16 2002 *************** *** 34,40 **** protected transient byte[] _states; ! /** constants used for state flags */ protected static final byte FREE = 0; protected static final byte FULL = 1; protected static final byte REMOVED = 2; --- 38,51 ---- protected transient byte[] _states; ! /* constants used for state flags */ ! ! /** flag indicating that a slot in the hashtable is available */ protected static final byte FREE = 0; + + /** flag indicating that a slot in the hashtable is occupied */ protected static final byte FULL = 1; + + /** flag indicating that the value of a slot in the hashtable + * was deleted */ protected static final byte REMOVED = 2; *************** *** 73,76 **** --- 84,93 ---- } + /** + * Returns the capacity of the hash table. This is the true + * physical capacity, without adjusting for the load factor. + * + * @return the physical capacity of the hash table. + */ protected int capacity() { return _states.length; |
From: Eric F. <er...@us...> - 2002-01-19 19:12:45
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv18333 Modified Files: navbar.html Log Message: html foo Index: navbar.html =================================================================== RCS file: /cvsroot/trove4j/trove_web/navbar.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** navbar.html 2002/01/19 19:09:21 1.4 --- navbar.html 2002/01/19 19:12:43 1.5 *************** *** 1,25 **** <p> [ ! <a href="index.shtml">Home</a> | ! <a href="overview.shtml">Overview</a> | ! <a href="http://sourceforge.net/project/showfiles.php?group_id=39235">Releases</a> | ! <a href="http://sourceforge.net/cvs/?group_id=39235">CVS</a> | ! <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/trove4j/">Browse Source</a> | ! <a href="status.shtml">Status</a> | ! <a href="docs.shtml">Documentation</a> | ! <a href="license.shtml">License</a> | ! <a href="contacts.shtml">Contacts</a> | ! <a href="benchmarks.shtml">Benchmarks</a> | ! <a href="tools.shtml">Developers' Corner</a> ] </p> --- 1,25 ---- <p> [ ! <a href="index.shtml"><b>Home</b></a> | ! <a href="overview.shtml"><b>Overview</b></a> | ! <a href="http://sourceforge.net/project/showfiles.php?group_id=39235"><b>Releases</b></a> | ! <a href="http://sourceforge.net/cvs/?group_id=39235"><b>CVS</b></a> | ! <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/trove4j/"><b>Browse Source</b></a> | ! <a href="status.shtml"><b>Status</b></a> | ! <a href="docs.shtml"><b>API Documentation</b></a> | ! <a href="license.shtml"><b>License</b></a> | ! <a href="contacts.shtml"><b>Contacts</b></a> | ! <a href="benchmarks.shtml"><b>Benchmarks</b></a> | ! <a href="tools.shtml"><b>Developers' Corner</b></a> ] </p> |
From: Eric F. <er...@us...> - 2002-01-19 19:09:23
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv17643 Modified Files: navbar.html Log Message: url tweak Index: navbar.html =================================================================== RCS file: /cvsroot/trove4j/trove_web/navbar.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** navbar.html 2002/01/19 19:03:08 1.3 --- navbar.html 2002/01/19 19:09:21 1.4 *************** *** 9,13 **** <a href="http://sourceforge.net/cvs/?group_id=39235">CVS</a> | ! <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/trove4j">Browse Source</a> | <a href="status.shtml">Status</a> --- 9,13 ---- <a href="http://sourceforge.net/cvs/?group_id=39235">CVS</a> | ! <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/trove4j/">Browse Source</a> | <a href="status.shtml">Status</a> |
From: Eric F. <er...@us...> - 2002-01-19 19:08:38
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv17448 Modified Files: .cvsignore Log Message: make cvs stop whining about semantic/JDE files Index: .cvsignore =================================================================== RCS file: /cvsroot/trove4j/trove/.cvsignore,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** .cvsignore 2001/11/06 06:42:22 1.1.1.1 --- .cvsignore 2002/01/19 19:08:36 1.2 *************** *** 1 **** --- 1,3 ---- output + semantic.cache + prj.el |
From: Eric F. <er...@us...> - 2002-01-19 19:03:10
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv16342 Modified Files: index.shtml navbar.html Log Message: added links Index: index.shtml =================================================================== RCS file: /cvsroot/trove4j/trove_web/index.shtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** index.shtml 2002/01/19 18:50:55 1.1.1.1 --- index.shtml 2002/01/19 19:03:08 1.2 *************** *** 30,33 **** --- 30,37 ---- </p> + <p> + Download the <a href="http://sourceforge.net/project/showfiles.php?group_id=39235">latest release</a>. + </p> + <!--#include virtual="./navbar.html" --> <hr> Index: navbar.html =================================================================== RCS file: /cvsroot/trove4j/trove_web/navbar.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** navbar.html 2002/01/19 18:55:23 1.2 --- navbar.html 2002/01/19 19:03:08 1.3 *************** *** 5,8 **** --- 5,14 ---- <a href="overview.shtml">Overview</a> | + <a href="http://sourceforge.net/project/showfiles.php?group_id=39235">Releases</a> + | + <a href="http://sourceforge.net/cvs/?group_id=39235">CVS</a> + | + <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/trove4j">Browse Source</a> + | <a href="status.shtml">Status</a> | |
From: Eric F. <er...@us...> - 2002-01-19 18:55:26
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv14154 Modified Files: navbar.html Log Message: shuffled order of items in nav bar in html Index: navbar.html =================================================================== RCS file: /cvsroot/trove4j/trove_web/navbar.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** navbar.html 2002/01/19 18:50:55 1.1.1.1 --- navbar.html 2002/01/19 18:55:23 1.2 *************** *** 3,19 **** <a href="index.shtml">Home</a> | ! <a href="benchmarks.shtml">Benchmarks</a> | <a href="status.shtml">Status</a> | - <a href="tools.shtml">Developers' Corner</a> - | <a href="docs.shtml">Documentation</a> | <a href="contacts.shtml">Contacts</a> | ! <a href="overview.shtml">Overview</a> | ! <a href="license.shtml">License</a> ] </p> --- 3,19 ---- <a href="index.shtml">Home</a> | ! <a href="overview.shtml">Overview</a> | <a href="status.shtml">Status</a> | <a href="docs.shtml">Documentation</a> | + <a href="license.shtml">License</a> + | <a href="contacts.shtml">Contacts</a> | ! <a href="benchmarks.shtml">Benchmarks</a> | ! <a href="tools.shtml">Developers' Corner</a> ] </p> |
From: Eric F. <er...@us...> - 2002-01-19 18:50:58
|
Update of /cvsroot/trove4j/trove_web In directory usw-pr-cvs1:/tmp/cvs-serv13103 Log Message: initial import of html stuff for project web site Status: Vendor Tag: trove4j Release Tags: base N trove_web/benchmarks.shtml N trove_web/contacts.shtml N trove_web/docs.shtml N trove_web/index.shtml N trove_web/license.shtml N trove_web/memory.shtml N trove_web/overview.shtml N trove_web/performance.shtml N trove_web/status.shtml N trove_web/tools.shtml N trove_web/navbar.html No conflicts created by this import ***** Bogus filespec: - Imported sources |
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv27835/src/gnu/trove Modified Files: TDoubleHashSet.java TFloatHashSet.java TIntHashSet.java TLongHashSet.java gen_primitive_set.pl Added Files: TIntHashSetTests.java Log Message: bug fix in primitive hash sets: toArray now produces a correct return value of size set.size(). Previously it generated an ArrayIndexOutOfBoundsException. Thanks to Tobias Henle for finding this. added unit tests which demonstrate that the fix for this bug does, in fact, work. --- NEW FILE: TIntHashSetTests.java --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove; import java.util.*; import junit.framework.*; /** * * Created: Fri Jan 18 08:25:29 2002 * * @author Eric D. Friedman * @version $Id: TIntHashSetTests.java,v 1.1 2002/01/18 16:40:09 ericdf Exp $ */ public class TIntHashSetTests extends TestCase { public TIntHashSetTests(String name) { super(name); } public void testToArray() { int[] vals = { -9, -327, 87, 0, 42 }; TIntHashSet set = new TIntHashSet(vals); assertEquals(vals.length, set.size()); int[] out = set.toArray(); assertEquals(vals.length, out.length); Arrays.sort(vals); Arrays.sort(out); assertTrue(Arrays.equals(vals, out)); } } // TIntHashSetTests Index: TDoubleHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleHashSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TDoubleHashSet.java 2002/01/14 05:59:43 1.5 --- TDoubleHashSet.java 2002/01/18 16:40:09 1.6 *************** *** 133,138 **** byte[] states = _states; ! for (int i = states.length; i-- > 0;) { ! result[i] = set[i]; } return result; --- 133,140 ---- byte[] states = _states; ! for (int i = states.length, j = 0; i-- > 0;) { ! if (states[i] == FULL) { ! result[j++] = set[i]; ! } } return result; Index: TFloatHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatHashSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TFloatHashSet.java 2002/01/14 05:59:43 1.5 --- TFloatHashSet.java 2002/01/18 16:40:09 1.6 *************** *** 133,138 **** byte[] states = _states; ! for (int i = states.length; i-- > 0;) { ! result[i] = set[i]; } return result; --- 133,140 ---- byte[] states = _states; ! for (int i = states.length, j = 0; i-- > 0;) { ! if (states[i] == FULL) { ! result[j++] = set[i]; ! } } return result; Index: TIntHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntHashSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TIntHashSet.java 2002/01/14 05:59:43 1.5 --- TIntHashSet.java 2002/01/18 16:40:09 1.6 *************** *** 133,138 **** byte[] states = _states; ! for (int i = states.length; i-- > 0;) { ! result[i] = set[i]; } return result; --- 133,140 ---- byte[] states = _states; ! for (int i = states.length, j = 0; i-- > 0;) { ! if (states[i] == FULL) { ! result[j++] = set[i]; ! } } return result; Index: TLongHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongHashSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TLongHashSet.java 2002/01/14 05:59:43 1.5 --- TLongHashSet.java 2002/01/18 16:40:09 1.6 *************** *** 133,138 **** byte[] states = _states; ! for (int i = states.length; i-- > 0;) { ! result[i] = set[i]; } return result; --- 133,140 ---- byte[] states = _states; ! for (int i = states.length, j = 0; i-- > 0;) { ! if (states[i] == FULL) { ! result[j++] = set[i]; ! } } return result; Index: gen_primitive_set.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_primitive_set.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gen_primitive_set.pl 2002/01/14 05:59:43 1.6 --- gen_primitive_set.pl 2002/01/18 16:40:09 1.7 *************** *** 154,159 **** byte[] states = _states; ! for (int i = states.length; i-- > 0;) { ! result[i] = set[i]; } return result; --- 154,161 ---- byte[] states = _states; ! for (int i = states.length, j = 0; i-- > 0;) { ! if (states[i] == FULL) { ! result[j++] = set[i]; ! } } return result; |
From: Eric F. <er...@us...> - 2002-01-18 16:40:12
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv27835 Modified Files: ChangeLog Log Message: bug fix in primitive hash sets: toArray now produces a correct return value of size set.size(). Previously it generated an ArrayIndexOutOfBoundsException. Thanks to Tobias Henle for finding this. added unit tests which demonstrate that the fix for this bug does, in fact, work. Index: ChangeLog =================================================================== RCS file: /cvsroot/trove4j/trove/ChangeLog,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ChangeLog 2002/01/14 05:59:42 1.11 --- ChangeLog 2002/01/18 16:40:08 1.12 *************** *** 1,4 **** --- 1,8 ---- v 0.1.2 + bug fix in primitive hash sets: toArray now produces a correct return + value of size set.size(). Previously it generated an + ArrayIndexOutOfBoundsException. Thanks to Tobias Henle for finding this. + revised class hierarchy so that all primitive hashing collections are derived from TPrimitiveHash, which extends THash. Object hashing collections |
From: Eric F. <er...@us...> - 2002-01-14 06:17:18
|
Update of /cvsroot/trove4j/trove In directory usw-pr-cvs1:/tmp/cvs-serv5845 Modified Files: build.xml Log Message: incremented version in build file Index: build.xml =================================================================== RCS file: /cvsroot/trove4j/trove/build.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** build.xml 2002/01/02 19:07:44 1.15 --- build.xml 2002/01/14 06:17:16 1.16 *************** *** 10,14 **** <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.1"/> <property name="year" value="2001"/> --- 10,14 ---- <property name="Name" value="Trove for Java"/> <property name="name" value="trove"/> ! <property name="version" value="0.1.2"/> <property name="year" value="2001"/> |
Update of /cvsroot/trove4j/trove/src/gnu/trove In directory usw-pr-cvs1:/tmp/cvs-serv3043/src/gnu/trove Modified Files: TDoubleArrayList.java TDoubleDoubleHashMap.java TDoubleDoubleProcedure.java TDoubleFloatHashMap.java TDoubleFloatProcedure.java TDoubleFunction.java TDoubleHash.java TDoubleHashSet.java TDoubleIntHashMap.java TDoubleIntProcedure.java TDoubleLongHashMap.java TDoubleLongProcedure.java TDoubleObjectHashMap.java TDoubleObjectProcedure.java TDoubleProcedure.java TFloatArrayList.java TFloatDoubleHashMap.java TFloatDoubleProcedure.java TFloatFloatHashMap.java TFloatFloatProcedure.java TFloatFunction.java TFloatHash.java TFloatHashSet.java TFloatIntHashMap.java TFloatIntProcedure.java TFloatLongHashMap.java TFloatLongProcedure.java TFloatObjectHashMap.java TFloatObjectProcedure.java TFloatProcedure.java THash.java THashIterator.java THashMap.java THashSet.java THashSetTests.java TIntDoubleHashMap.java TIntDoubleProcedure.java TIntFloatHashMap.java TIntFloatProcedure.java TIntFunction.java TIntHash.java TIntHashSet.java TIntIntHashMap.java TIntIntProcedure.java TIntLongHashMap.java TIntLongProcedure.java TIntObjectHashMap.java TIntObjectProcedure.java TIntProcedure.java TLongArrayList.java TLongDoubleHashMap.java TLongDoubleProcedure.java TLongFloatHashMap.java TLongFloatProcedure.java TLongFunction.java TLongHash.java TLongHashSet.java TLongIntHashMap.java TLongIntProcedure.java TLongLongHashMap.java TLongLongProcedure.java TLongObjectHashMap.java TLongObjectProcedure.java TLongProcedure.java TObjectDoubleHashMap.java TObjectDoubleProcedure.java TObjectFloatHashMap.java TObjectFloatProcedure.java TObjectHash.java TObjectIntHashMap.java TObjectIntProcedure.java TObjectLongHashMap.java TObjectLongProcedure.java gen_primitive_base.pl gen_primitive_map.pl gen_primitive_set.pl Added Files: TPrimitiveHash.java ToObjectArrayProcedure.java gen_obj_primitive_map.pl Log Message: revised class hierarchy so that all primitive hashing collections are derived from TPrimitiveHash, which extends THash. Object hashing collections are derived from TObjectHash. As part of this change, the byte[] flags were pushed down to TPrimitiveHash, and TObjectHash was revised so that it no longer needs a byte[] array to track the state of the table. This has an appreciable impact on the total size of Object hashing collections: a set of 1,000 Integers used to take 69% of the memory needed for a JDK set; it now takes only 62%. removed slots can now be re-used in all hashing collections. If the search for an insertion index does not find that the key is already present in the map, insertionIndex implementations will now return the index of the first REMOVED or FREE slot. This means that tables which undergo a pattern of insertions/deletions without radical changes in size will not trigger as many rehashes as before. revised hashing algorithm so that the second hash function is only executed when necessary and so that FREE or FULL w/identical content slots can be found with a minimum of effort. --- NEW FILE: TPrimitiveHash.java --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove; /** * * Created: Fri Jan 11 18:55:16 2002 * * @author Eric D. Friedman * @version $Id: TPrimitiveHash.java,v 1.1 2002/01/14 05:59:43 ericdf Exp $ */ abstract public class TPrimitiveHash extends THash { /** flags indicating whether each position in the hash is * FREE, FULL, or REMOVED */ protected transient byte[] _states; /** constants used for state flags */ protected static final byte FREE = 0; protected static final byte FULL = 1; protected static final byte REMOVED = 2; /** * Creates a new <code>THash</code> instance with the default * capacity and load factor. */ public TPrimitiveHash() { super(); } /** * Creates a new <code>TPrimitiveHash</code> instance with a prime * capacity at or near the specified capacity and with the default * load factor. * * @param initialCapacity an <code>int</code> value */ public TPrimitiveHash(int initialCapacity) { this(initialCapacity, DEFAULT_LOAD_FACTOR); } /** * Creates a new <code>TPrimitiveHash</code> instance with a prime * capacity at or near the minimum needed to hold * <tt>initialCapacity<tt> elements with load factor * <tt>loadFactor</tt> without triggering a rehash. * * @param initialCapacity an <code>int</code> value * @param loadFactor a <code>float</code> value */ public TPrimitiveHash(int initialCapacity, float loadFactor) { super(); _loadFactor = loadFactor; setUp((int)Math.ceil(initialCapacity / loadFactor)); } protected int capacity() { return _states.length; } /** * Delete the record at <tt>index</tt>. * * @param index an <code>int</code> value */ protected void removeAt(int index) { super.removeAt(index); _states[index] = REMOVED; } /** * initializes the hashtable to a prime capacity which is at least * <tt>initialCapacity + 1</tt>. * * @param initialCapacity an <code>int</code> value * @return the actual capacity chosen */ protected int setUp(int initialCapacity) { int capacity; capacity = super.setUp(initialCapacity); _states = new byte[capacity]; return capacity; } } // TPrimitiveHash --- NEW FILE: ToObjectArrayProcedure.java --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove; /** * A procedure which stores each value it receives into a target array. * * Created: Sat Jan 12 10:13:42 2002 * * @author Eric D. Friedman * @version $Id: ToObjectArrayProcedure.java,v 1.1 2002/01/14 05:59:43 ericdf Exp $ */ final class ToObjectArrayProcedure implements TObjectProcedure { private final Object[] target; private int pos = 0; public ToObjectArrayProcedure(final Object[] target) { this.target = target; } public final boolean execute(Object value) { target[pos++] = value; return true; } } // ToObjectArrayProcedure --- NEW FILE: gen_obj_primitive_map.pl --- #!/usr/bin/perl -w use strict; use vars qw($code $containsPrimitiveValue $primitiveValueEQ); my @types = qw(int long double float); for my $valueType (@types) { my $clearValType = "($valueType)0"; my $c = $code; my $ValueType = ucfirst $valueType; my $valueImpl = undef; my $valueEQ = undef; $valueImpl = $containsPrimitiveValue; $valueImpl =~ s/<valueType>/$valueType/g; $valueEQ = $primitiveValueEQ; $valueEQ =~ s/<valueType>/$valueType/g; $c =~ s/<valueType>/$valueType/g; $c =~ s/<ValueType>/$ValueType/g; $c =~ s/<clearValType>/$clearValType/g; $c =~ s/<containsValue>/$valueImpl/g; $c =~ s/<valueEQ>/$valueEQ/g; open FH, ">TObject${ValueType}HashMap.java" || die $!; print FH $c; close FH; } BEGIN { $primitiveValueEQ = <<'EOF'; /** * Compare two <valueType>s for equality. */ private final boolean eq(<valueType> v1, <valueType> v2) { return v1 == v2; } EOF $containsPrimitiveValue = <<'EOF'; /** * checks for the presence of <tt>val</tt> in the values of the map. * * @param val an <code><valueType></code> value * @return a <code>boolean</code> value */ public boolean containsValue(<valueType> val) { Object[] keys = _set; <valueType>[] vals = _values; for (int i = vals.length; i-- > 0;) { if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) { return true; } } return false; } EOF $code = <<'EOF'; /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; /** * An open addressed Map implementation for Object keys and <valueType> values. * * Created: Sun Nov 4 08:52:45 2001 * * @author Eric D. Friedman * @version $Id: gen_obj_primitive_map.pl,v 1.1 2002/01/14 05:59:43 ericdf Exp $ */ public class TObject<ValueType>HashMap extends TObjectHash implements Serializable { /** the values of the map */ protected transient <valueType>[] _values; /** * Creates a new <code>TObject<ValueType>HashMap</code> instance with the default * capacity and load factor. */ public TObject<ValueType>HashMap() { super(); } /** * Creates a new <code>TObject<ValueType>HashMap</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 TObject<ValueType>HashMap(int initialCapacity) { super(initialCapacity); } /** * Creates a new <code>TObject<ValueType>HashMap</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 TObject<ValueType>HashMap(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } /** * initializes the hashtable to a prime capacity which is at least * <tt>initialCapacity + 1</tt>. * * @param initialCapacity an <code>int</code> value * @return the actual capacity chosen */ protected int setUp(int initialCapacity) { int capacity; capacity = super.setUp(initialCapacity); _values = new <valueType>[capacity]; return capacity; } /** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code><valueType></code> value * @return the previous value associated with <tt>key</tt>, * or null if none was found. */ public <valueType> put(Object key, <valueType> value) { <valueType> previous = <clearValType>; int index = insertionIndex(key); boolean isNewMapping = true; if (index < 0) { index = -index -1; previous = _values[index]; isNewMapping = false; } Object oldKey = _set[index]; _set[index] = key; _values[index] = value; if (isNewMapping) { postInsertHook(oldKey == null); } return previous; } /** * rehashes the map to the new capacity. * * @param newCapacity an <code>int</code> value */ protected void rehash(int newCapacity) { int oldCapacity = _set.length; Object oldKeys[] = _set; <valueType> oldVals[] = _values; _set = new Object[newCapacity]; _values = new <valueType>[newCapacity]; for (int i = oldCapacity; i-- > 0;) { if(oldKeys[i] != null && oldKeys[i] != REMOVED) { Object o = oldKeys[i]; int index = insertionIndex(o); _set[index] = o; _values[index] = oldVals[i]; } } } /** * retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ public <valueType> get(Object key) { int index = index(key); return index < 0 ? <clearValType> : _values[index]; } /** * Empties the map. * */ public void clear() { super.clear(); Object[] keys = _set; <valueType>[] vals = _values; for (int i = keys.length; i-- > 0;) { keys[i] = null; vals[i] = <clearValType>; } } /** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return an <code><valueType></code> value */ public <valueType> remove(Object key) { <valueType> prev = <clearValType>; int index = index(key); if (index >= 0) { prev = _values[index]; removeAt(index); // clear key,state; adjust size } return prev; } /** * 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 */ public boolean equals(Object other) { if (! (other instanceof TObject<ValueType>HashMap)) { return false; } TObject<ValueType>HashMap that = (TObject<ValueType>HashMap)other; if (that.size() != this.size()) { return false; } return forEachEntry(new EqProcedure(that)); } private static final class EqProcedure implements TObject<ValueType>Procedure { private final TObject<ValueType>HashMap _otherMap; EqProcedure(TObject<ValueType>HashMap otherMap) { _otherMap = otherMap; } public final boolean execute(Object key, <valueType> value) { int index = _otherMap.index(key); if (index >= 0 && eq(value, _otherMap.get(key))) { return true; } return false; } <valueEQ> } /** * removes the mapping at <tt>index</tt> from the map. * * @param index an <code>int</code> value */ protected void removeAt(int index) { super.removeAt(index); // clear key, state; adjust size _values[index] = <clearValType>; } /** * Returns the values of the map. * * @return a <code>Collection</code> value */ public <valueType>[] getValues() { <valueType>[] vals = new <valueType>[size()]; <valueType>[] v = _values; Object[] keys = _set; for (int i = v.length, j = 0; i-- > 0;) { if (keys[i] != null && keys[i] != REMOVED) { vals[j++] = v[i]; } } return vals; } /** * returns the keys of the map. * * @return a <code>Set</code> value */ public Object[] keys() { Object[] keys = new Object[size()]; Object[] k = _set; for (int i = k.length, j = 0; i-- > 0;) { if (k[i] != null && k[i] != REMOVED) { keys[j++] = k[i]; } } return keys; } <containsValue> /** * checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey(Object key) { return contains(key); } /** * 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 procedure) { return forEach(procedure); } /** * Executes <tt>procedure</tt> for each value in the map. * * @param procedure a <code>T<ValueType>Procedure</code> value * @return false if the loop over the values terminated because * the procedure returned false for some value. */ public boolean forEachValue(T<ValueType>Procedure procedure) { Object[] keys = _set; <valueType>[] values = _values; for (int i = values.length; i-- > 0;) { if (keys[i] != null && keys[i] != REMOVED && ! procedure.execute(values[i])) { return false; } } return true; } /** * Executes <tt>procedure</tt> for each key/value entry in the * map. * * @param procedure a <code>TOObject<ValueType>Procedure</code> value * @return false if the loop over the entries terminated because * the procedure returned false for some entry. */ public boolean forEachEntry(TObject<ValueType>Procedure procedure) { Object[] keys = _set; <valueType>[] values = _values; for (int i = keys.length; i-- > 0;) { if (keys[i] != null && keys[i] != REMOVED && ! procedure.execute(keys[i],values[i])) { return false; } } return true; } /** * Transform the values in this map using <tt>function</tt>. * * @param function a <code>T<ValueType>Function</code> value */ public void transformValues(T<ValueType>Function function) { Object[] keys = _set; <valueType>[] values = _values; for (int i = values.length; i-- > 0;) { if (keys[i] != null && keys[i] != REMOVED) { values[i] = function.execute(values[i]); } } } private void writeObject(final ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); // number of entries stream.writeInt(_size); class WriteProcedure implements TObject<ValueType>Procedure { IOException e; public boolean execute(Object key, <valueType> value) { try { stream.writeObject(key); stream.write<ValueType>(value); } catch (IOException ioe) { this.e = ioe; return false; } // end of try-catch return true; } } WriteProcedure writeProcedure = new WriteProcedure(); if (! forEachEntry(writeProcedure)) { throw writeProcedure.e; } } private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int size = stream.readInt(); setUp(size); while (size-- > 0) { Object key = stream.readObject(); <valueType> val = stream.read<ValueType>(); put(key, val); } } } // TObject<ValueType>HashMap EOF } Index: TDoubleArrayList.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleArrayList.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 Index: TDoubleDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleDoubleHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TDoubleDoubleHashMap.java 2001/12/28 20:04:39 1.6 --- TDoubleDoubleHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public double put(double key, double value) { + byte previousState; double previous = (double)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); double[] keys = _set; double[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TDoubleDoubleProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleDoubleProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TDoubleDoubleProcedure.java 2001/11/10 22:30:28 1.4 --- TDoubleDoubleProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TDoubleDoubleProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>double</code> value + * @param b an <code>double</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(double a, double b); }// TDoubleDoubleProcedure Index: TDoubleFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleFloatHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TDoubleFloatHashMap.java 2001/12/28 20:04:39 1.6 --- TDoubleFloatHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public float put(double key, float value) { + byte previousState; float previous = (float)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); double[] keys = _set; float[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TDoubleFloatProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleFloatProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TDoubleFloatProcedure.java 2001/11/10 22:30:28 1.4 --- TDoubleFloatProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TDoubleFloatProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>double</code> value + * @param b an <code>float</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(double a, float b); }// TDoubleFloatProcedure Index: TDoubleFunction.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleFunction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Index: TDoubleHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleHash.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TDoubleHash.java 2002/01/06 08:23:05 1.7 --- TDoubleHash.java 2002/01/14 05:59:43 1.8 *************** *** 30,34 **** */ ! abstract public class TDoubleHash extends THash implements Serializable { /** the set of doubles */ --- 30,35 ---- */ ! abstract public class TDoubleHash extends TPrimitiveHash ! implements Serializable { /** the set of doubles */ *************** *** 192,195 **** --- 193,197 ---- // one we have. if (states[index] == REMOVED) { + int firstRemoved = index; while (states[index] != FREE && (states[index] == REMOVED || set[index] != val)) { *************** *** 199,202 **** --- 201,205 ---- } } + return states[index] == FULL ? -index -1 : firstRemoved; } // if it's full, the key is already stored Index: TDoubleHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleHashSet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TDoubleHashSet.java 2001/12/28 20:04:39 1.4 --- TDoubleHashSet.java 2002/01/14 05:59:43 1.5 *************** *** 92,98 **** } _set[index] = val; _states[index] = FULL; ! postInsertHook(); return true; // yes, we added something --- 92,99 ---- } + byte previousState = _states[index]; _set[index] = val; _states[index] = FULL; ! postInsertHook(previousState == FREE); return true; // yes, we added something *************** *** 112,117 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 113,116 ---- *************** *** 144,147 **** --- 143,147 ---- */ public void clear() { + super.clear(); double[] set = _set; byte[] states = _states; *************** *** 151,157 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 151,154 ---- Index: TDoubleIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleIntHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TDoubleIntHashMap.java 2001/12/28 20:04:39 1.6 --- TDoubleIntHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public int put(double key, int value) { + byte previousState; int previous = (int)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); double[] keys = _set; int[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TDoubleIntProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleIntProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TDoubleIntProcedure.java 2001/11/10 22:30:28 1.4 --- TDoubleIntProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TDoubleIntProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>double</code> value + * @param b an <code>int</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(double a, int b); }// TDoubleIntProcedure Index: TDoubleLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleLongHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TDoubleLongHashMap.java 2001/12/28 20:04:39 1.6 --- TDoubleLongHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public long put(double key, long value) { + byte previousState; long previous = (long)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); double[] keys = _set; long[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TDoubleLongProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleLongProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TDoubleLongProcedure.java 2001/11/10 22:30:28 1.4 --- TDoubleLongProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TDoubleLongProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>double</code> value + * @param b an <code>long</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(double a, long b); }// TDoubleLongProcedure Index: TDoubleObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleObjectHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TDoubleObjectHashMap.java 2001/12/28 20:04:39 1.6 --- TDoubleObjectHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public Object put(double key, Object value) { + byte previousState; Object previous = null; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); double[] keys = _set; Object[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TDoubleObjectProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleObjectProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TDoubleObjectProcedure.java 2001/11/10 22:30:28 1.4 --- TDoubleObjectProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TDoubleObjectProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>double</code> value + * @param b an <code>Object</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(double a, Object b); }// TDoubleObjectProcedure Index: TDoubleProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleProcedure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TDoubleProcedure.java 2001/11/06 07:19:32 1.2 --- TDoubleProcedure.java 2002/01/14 05:59:43 1.3 *************** *** 30,38 **** public interface TDoubleProcedure { /** ! * Executes this procedure using <tt>value</tt>. * * @param value a value of type <code>double</code> ! * @return false to terminate procedure execution (in a loop over ! * a set); true to continue. */ public boolean execute(double value); --- 30,40 ---- public interface TDoubleProcedure { /** ! * Executes this procedure. A false return value indicates that ! * the application executing this procedure should not invoke this ! * procedure again. * * @param value a value of type <code>double</code> ! * @return true if additional invocations of the procedure are ! * allowed. */ public boolean execute(double value); Index: TFloatArrayList.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatArrayList.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 Index: TFloatDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatDoubleHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TFloatDoubleHashMap.java 2001/12/28 20:04:39 1.6 --- TFloatDoubleHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public double put(float key, double value) { + byte previousState; double previous = (double)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); float[] keys = _set; double[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TFloatDoubleProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatDoubleProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TFloatDoubleProcedure.java 2001/11/10 22:30:28 1.4 --- TFloatDoubleProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TFloatDoubleProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>float</code> value + * @param b an <code>double</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(float a, double b); }// TFloatDoubleProcedure Index: TFloatFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatFloatHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TFloatFloatHashMap.java 2001/12/28 20:04:39 1.6 --- TFloatFloatHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public float put(float key, float value) { + byte previousState; float previous = (float)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); float[] keys = _set; float[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TFloatFloatProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatFloatProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TFloatFloatProcedure.java 2001/11/10 22:30:28 1.4 --- TFloatFloatProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TFloatFloatProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>float</code> value + * @param b an <code>float</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(float a, float b); }// TFloatFloatProcedure Index: TFloatFunction.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatFunction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Index: TFloatHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatHash.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TFloatHash.java 2002/01/06 08:23:05 1.7 --- TFloatHash.java 2002/01/14 05:59:43 1.8 *************** *** 30,34 **** */ ! abstract public class TFloatHash extends THash implements Serializable { /** the set of floats */ --- 30,35 ---- */ ! abstract public class TFloatHash extends TPrimitiveHash ! implements Serializable { /** the set of floats */ *************** *** 192,195 **** --- 193,197 ---- // one we have. if (states[index] == REMOVED) { + int firstRemoved = index; while (states[index] != FREE && (states[index] == REMOVED || set[index] != val)) { *************** *** 199,202 **** --- 201,205 ---- } } + return states[index] == FULL ? -index -1 : firstRemoved; } // if it's full, the key is already stored Index: TFloatHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatHashSet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TFloatHashSet.java 2001/12/28 20:04:39 1.4 --- TFloatHashSet.java 2002/01/14 05:59:43 1.5 *************** *** 92,98 **** } _set[index] = val; _states[index] = FULL; ! postInsertHook(); return true; // yes, we added something --- 92,99 ---- } + byte previousState = _states[index]; _set[index] = val; _states[index] = FULL; ! postInsertHook(previousState == FREE); return true; // yes, we added something *************** *** 112,117 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 113,116 ---- *************** *** 144,147 **** --- 143,147 ---- */ public void clear() { + super.clear(); float[] set = _set; byte[] states = _states; *************** *** 151,157 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 151,154 ---- Index: TFloatIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatIntHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TFloatIntHashMap.java 2001/12/28 20:04:39 1.6 --- TFloatIntHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public int put(float key, int value) { + byte previousState; int previous = (int)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); float[] keys = _set; int[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TFloatIntProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatIntProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TFloatIntProcedure.java 2001/11/10 22:30:28 1.4 --- TFloatIntProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TFloatIntProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>float</code> value + * @param b an <code>int</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(float a, int b); }// TFloatIntProcedure Index: TFloatLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatLongHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TFloatLongHashMap.java 2001/12/28 20:04:39 1.6 --- TFloatLongHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public long put(float key, long value) { + byte previousState; long previous = (long)0; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); float[] keys = _set; long[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TFloatLongProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatLongProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TFloatLongProcedure.java 2001/11/10 22:30:28 1.4 --- TFloatLongProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TFloatLongProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>float</code> value + * @param b an <code>long</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(float a, long b); }// TFloatLongProcedure Index: TFloatObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatObjectHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TFloatObjectHashMap.java 2001/12/28 20:04:39 1.6 --- TFloatObjectHashMap.java 2002/01/14 05:59:43 1.7 *************** *** 92,95 **** --- 92,96 ---- */ public Object put(float key, Object value) { + byte previousState; Object previous = null; int index = insertionIndex(key); *************** *** 100,108 **** isNewMapping = false; } _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(); } --- 101,110 ---- isNewMapping = false; } + previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { ! postInsertHook(previousState == FREE); } *************** *** 125,130 **** _states = new byte[newCapacity]; - _free = newCapacity - _size; - _removed = 0; // 0 removed elements after a rehash for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { --- 127,130 ---- *************** *** 154,157 **** --- 154,158 ---- */ public void clear() { + super.clear(); float[] keys = _set; Object[] vals = _values; *************** *** 163,169 **** states[i] = FREE; } - _size = 0; - _removed = 0; - _free = _set.length; } --- 164,167 ---- Index: TFloatObjectProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatObjectProcedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TFloatObjectProcedure.java 2001/11/10 22:30:28 1.4 --- TFloatObjectProcedure.java 2002/01/14 05:59:43 1.5 *************** *** 29,32 **** --- 29,43 ---- public interface TFloatObjectProcedure { + + /** + * Executes this procedure. A false return value indicates that + * the application executing this procedure should not invoke this + * procedure again. + * + * @param a an <code>float</code> value + * @param b an <code>Object</code> value + * @return true if additional invocations of the procedure are + * allowed. + */ public boolean execute(float a, Object b); }// TFloatObjectProcedure Index: TFloatProcedure.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatProcedure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TFloatProcedure.java 2001/11/06 07:19:32 1.2 --- TFloatProcedure.java 2002/01/14 05:59:43 1.3 *************** *** 30,38 **** public interface TFloatProcedure { /** ! * Executes this procedure using <tt>value</tt>. * * @param value a value of type <code>float</code> ! * @return false to terminate procedure execution (in a loop over ! * a set); true to continue. */ public boolean execute(float value); --- 30,40 ---- public interface TFloatProcedure { /** ! * Executes this procedure. A false return value indicates that ! * the application executing this procedure should not invoke this ! * procedure again. * * @param value a value of type <code>float</code> ! * @return true if additional invocations of the procedure are ! * allowed. */ public boolean execute(float value); Index: THash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THash.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** THash.java 2001/12/30 23:55:45 1.3 --- THash.java 2002/01/14 05:59:43 1.4 *************** *** 30,41 **** abstract public class THash { - /** flags indicating whether each position in the hash is - * FREE, FULL, or REMOVED */ - protected transient byte[] _states; - /** the current number of occupied slots in the hash. */ protected transient int _size; ! /** the number of free slots in the hash table. */ protected transient int _free; --- 30,37 ---- abstract public class THash { /** the current number of occupied slots in the hash. */ protected transient int _size; ! /** the current number of free slots in the hash. */ protected transient int _free; *************** *** 65,85 **** /** - * The minimum number of free elements allowed. When the number - * of free elements drops below this amount, the next insertion - * will trigger a rehash. - */ - protected int _minFree; - - /** - * The number of REMOVED slots in the table. - */ - protected int _removed; - - /** constants used for state flags */ - protected static final byte FREE = 0; - protected static final byte FULL = 1; - protected static final byte REMOVED = 2; - - /** * Creates a new <code>THash</code> instance with the default * capacity and load factor. --- 61,64 ---- *************** *** 116,129 **** /** - * Returns the state table for this hash. - * - * @return a <code>byte[]</code> value with values in the set - * (FREE, FULL, REMOVED). - */ - protected byte[] states() { - return _states; - } - - /** * Tells whether this set is currently holding any elements. * --- 95,98 ---- *************** *** 144,159 **** /** * Ensure that this hashtable has sufficient capacity to hold ! * <tt>desiredCapacity<tt> elements without requiring a rehash. ! * This is a tuning method you can call before doing a large ! * insert. * * @param desiredCapacity an <code>int</code> value */ public void ensureCapacity(int desiredCapacity) { ! if (desiredCapacity > (_states.length - _minFree - _removed)) { ! rehash(PrimeFinder.nextPrime((int)Math.ceil(desiredCapacity / _loadFactor) + 1)); ! computeMinMax(); } } --- 113,133 ---- /** + * @return the current physical capacity of the hash table. + */ + abstract protected int capacity(); + + /** * Ensure that this hashtable has sufficient capacity to hold ! * <tt>desiredCapacity<tt> <b>additional</b> elements without ! * requiring a rehash. This is a tuning method you can call ! * before doing a large insert. * * @param desiredCapacity an <code>int</code> value */ public void ensureCapacity(int desiredCapacity) { ! if (desiredCapacity > (_maxSize - size())) { ! rehash(PrimeFinder.nextPrime((int)Math.ceil(desiredCapacity + size() / _loadFactor) + 1)); ! computeMaxSize(capacity()); } } *************** *** 178,183 **** public void compact() { // need at least one free spot for open addressing ! rehash(PrimeFinder.nextPrime((int)Math.ceil(_size / _loadFactor) + 1)); ! computeMinMax(); } --- 152,157 ---- public void compact() { // need at least one free spot for open addressing ! rehash(PrimeFinder.nextPrime((int)Math.ceil(size()/_loadFactor) + 1)); ! computeMaxSize(capacity()); } *************** *** 194,210 **** compact(); } ! /** ! * Delete the record at <tt>index</tt>. * * @param index an <code>int</code> value */ protected void removeAt(int index) { - _states[index] = REMOVED; _size--; - _removed++; } /** * initializes the hashtable to a prime capacity which is at... [truncated message content] |