/** * Constructs an empty <tt>HashMap</tt> with the default initial capacity (16) and the default * load factor (0.75). */ @SuppressWarnings("unchecked") public IntHashMap() { loadFactor = DEFAULT_LOAD_FACTOR; threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR); table = new Entry[DEFAULT_INITIAL_CAPACITY]; init(); }
/** * Constructs an empty <tt>HashMap</tt> with the default initial capacity (16) and the default * load factor (0.75). */ @SuppressWarnings("unchecked") public IntHashMap() { loadFactor = DEFAULT_LOAD_FACTOR; threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR); table = new Entry[DEFAULT_INITIAL_CAPACITY]; init(); }
/** * Constructs an empty <tt>HashMap</tt> with the default initial capacity (16) and the default * load factor (0.75). */ public IntHashMap() { loadFactor = DEFAULT_LOAD_FACTOR; threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR); table = new Entry[DEFAULT_INITIAL_CAPACITY]; init(); }
threshold = (int)(capacity * loadFactor); table = new Entry[capacity]; init();
threshold = (int)(capacity * loadFactor); table = new Entry[capacity]; init();
threshold = (int)(capacity * loadFactor); table = new Entry[capacity]; init();
/** * Reconstitute the <tt>HashMap</tt> instance from a stream (i.e., deserialize it). * * @param s * @throws IOException * @throws ClassNotFoundException */ private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor, and any hidden stuff s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); table = new Entry[numBuckets]; init(); // Give subclass a chance to do its thing. // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i = 0; i < size; i++) { int key = s.readInt(); Object value = s.readObject(); putForCreate(key, value); } }
/** * Returns a shallow copy of this <tt>HashMap</tt> instance: the keys and values themselves * are not cloned. * * @return a shallow copy of this map. */ public Object clone() throws CloneNotSupportedException { IntHashMap result = null; try { result = (IntHashMap)super.clone(); result.table = new Entry[table.length]; result.entrySet = null; result.modCount = 0; result.size = 0; result.init(); result.putAllForCreate(this); } catch (CloneNotSupportedException e) { // assert false; } return result; }
/** * Returns a shallow copy of this <tt>HashMap</tt> instance: the keys and values themselves are * not cloned. * * @return a shallow copy of this map. */ @SuppressWarnings("unchecked") @Override public Object clone() throws CloneNotSupportedException { IntHashMap<V> result = null; try { result = (IntHashMap<V>)super.clone(); result.table = new Entry[table.length]; result.entrySet = null; result.modCount = 0; result.size = 0; result.init(); result.putAllForCreate(this); } catch (CloneNotSupportedException e) { // assert false; } return result; }
/** * Reconstitute the <tt>HashMap</tt> instance from a stream (i.e., deserialize it). * * @param s * @throws IOException * @throws ClassNotFoundException */ @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor, and any hidden stuff s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); table = new Entry[numBuckets]; init(); // Give subclass a chance to do its thing. // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i = 0; i < size; i++) { int key = s.readInt(); V value = (V)s.readObject(); putForCreate(key, value); } }
/** * Returns a shallow copy of this <tt>HashMap</tt> instance: the keys and values themselves are * not cloned. * * @return a shallow copy of this map. */ @SuppressWarnings("unchecked") @Override public Object clone() throws CloneNotSupportedException { IntHashMap<V> result = null; try { result = (IntHashMap<V>)super.clone(); result.table = new Entry[table.length]; result.entrySet = null; result.modCount.set(0); result.size = 0; result.init(); result.putAllForCreate(this); } catch (CloneNotSupportedException e) { // assert false; } return result; }
/** * Reconstitute the <tt>HashMap</tt> instance from a stream (i.e., deserialize it). * * @param s * @throws IOException * @throws ClassNotFoundException */ @SuppressWarnings("unchecked") private void readObject(final java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { modCount = new AtomicInteger(0); // Read in the threshold, loadfactor, and any hidden stuff s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); table = new Entry[numBuckets]; init(); // Give subclass a chance to do its thing. // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i = 0; i < size; i++) { int key = s.readInt(); V value = (V)s.readObject(); putForCreate(key, value); } }