< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/util/IntHashTable.java

Print this page

 23  * questions.
 24  */
 25 
 26 package com.sun.tools.javac.util;
 27 
 28 /**
 29  * A hash table that maps Object to int.
 30  *
 31  * This is a custom hash table optimised for the Object {@literal ->} int
 32  * maps. This is done to avoid unnecessary object allocation in the image set.
 33  *
 34  * @author Charles Turner
 35  * @author Per Bothner
 36  */
 37 public class IntHashTable {
 38     private static final int DEFAULT_INITIAL_SIZE = 64;
 39     protected Object[] objs; // the domain set
 40     protected int[] ints; // the image set
 41     protected int mask; // used to clip int's into the domain
 42     protected int num_bindings; // the number of mappings (including DELETED)
 43     private static final Object DELETED = new Object();
 44 
 45     /**
 46      * Construct an Object {@literal ->} int hash table.
 47      *
 48      * The default size of the hash table is 64 mappings.
 49      */
 50     public IntHashTable() {
 51         objs = new Object[DEFAULT_INITIAL_SIZE];
 52         ints = new int[DEFAULT_INITIAL_SIZE];
 53         mask = DEFAULT_INITIAL_SIZE - 1;
 54     }
 55 
 56     /**
 57      * Construct an Object {@literal ->} int hash table with a specified amount of mappings.
 58      * @param capacity The number of default mappings in this hash table.
 59      */
 60     public IntHashTable(int capacity) {
 61         int log2Size = 4;
 62         while (capacity > (1 << log2Size)) {
 63             log2Size++;

 23  * questions.
 24  */
 25 
 26 package com.sun.tools.javac.util;
 27 
 28 /**
 29  * A hash table that maps Object to int.
 30  *
 31  * This is a custom hash table optimised for the Object {@literal ->} int
 32  * maps. This is done to avoid unnecessary object allocation in the image set.
 33  *
 34  * @author Charles Turner
 35  * @author Per Bothner
 36  */
 37 public class IntHashTable {
 38     private static final int DEFAULT_INITIAL_SIZE = 64;
 39     protected Object[] objs; // the domain set
 40     protected int[] ints; // the image set
 41     protected int mask; // used to clip int's into the domain
 42     protected int num_bindings; // the number of mappings (including DELETED)
 43     private static final Object DELETED = new Object() {};
 44 
 45     /**
 46      * Construct an Object {@literal ->} int hash table.
 47      *
 48      * The default size of the hash table is 64 mappings.
 49      */
 50     public IntHashTable() {
 51         objs = new Object[DEFAULT_INITIAL_SIZE];
 52         ints = new int[DEFAULT_INITIAL_SIZE];
 53         mask = DEFAULT_INITIAL_SIZE - 1;
 54     }
 55 
 56     /**
 57      * Construct an Object {@literal ->} int hash table with a specified amount of mappings.
 58      * @param capacity The number of default mappings in this hash table.
 59      */
 60     public IntHashTable(int capacity) {
 61         int log2Size = 4;
 62         while (capacity > (1 << log2Size)) {
 63             log2Size++;
< prev index next >