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}] ------------"/> |