test/java/util/Map/Collisions.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 7126277
  27  * @run main Collisions -shortrun
  28  * @run main/othervm -Djdk.map.althashing.threshold=0 Collisions -shortrun

  29  * @summary Ensure Maps behave well with lots of hashCode() collisions.
  30  * @author Mike Duigou
  31  */
  32 import java.util.*;
  33 import java.util.concurrent.ConcurrentHashMap;
  34 import java.util.concurrent.ConcurrentSkipListMap;
  35 
  36 public class Collisions {
  37 
  38     /**
  39      * Number of elements per map.
  40      */
  41     private static final int TEST_SIZE = 5000;
  42 
  43     final static class HashableInteger implements Comparable<HashableInteger> {
  44 
  45         final int value;
  46         final int hashmask; //yes duplication
  47 
  48         HashableInteger(int value, int hashmask) {




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 7126277
  27  * @run main Collisions -shortrun
  28  * @run main/othervm -Djdk.map.althashing.threshold=0 Collisions -shortrun
  29  * @run main/othervm -Djdk.map.useRandomSeed=true Collisions -shortrun
  30  * @summary Ensure Maps behave well with lots of hashCode() collisions.
  31  * @author Mike Duigou
  32  */
  33 import java.util.*;
  34 import java.util.concurrent.ConcurrentHashMap;
  35 import java.util.concurrent.ConcurrentSkipListMap;
  36 
  37 public class Collisions {
  38 
  39     /**
  40      * Number of elements per map.
  41      */
  42     private static final int TEST_SIZE = 5000;
  43 
  44     final static class HashableInteger implements Comparable<HashableInteger> {
  45 
  46         final int value;
  47         final int hashmask; //yes duplication
  48 
  49         HashableInteger(int value, int hashmask) {