Tabnine Logo
HashMap.makeTable
Code IndexAdd Tabnine to your IDE (free)

How to use
makeTable
method
in
java.util.HashMap

Best Java code snippets using java.util.HashMap.makeTable (Showing top 20 results out of 315)

origin: robovm/robovm

HashMapEntry<K, V>[] newTable = makeTable(newCapacity);
if (size == 0) {
  return newTable;
origin: robovm/robovm

/**
 * Constructs a new {@code HashMap} instance with the specified capacity.
 *
 * @param capacity
 *            the initial capacity of this hash map.
 * @throws IllegalArgumentException
 *                when the capacity is less than zero.
 */
public HashMap(int capacity) {
  if (capacity < 0) {
    throw new IllegalArgumentException("Capacity: " + capacity);
  }
  if (capacity == 0) {
    @SuppressWarnings("unchecked")
    HashMapEntry<K, V>[] tab = (HashMapEntry<K, V>[]) EMPTY_TABLE;
    table = tab;
    threshold = -1; // Forces first put() to replace EMPTY_TABLE
    return;
  }
  if (capacity < MINIMUM_CAPACITY) {
    capacity = MINIMUM_CAPACITY;
  } else if (capacity > MAXIMUM_CAPACITY) {
    capacity = MAXIMUM_CAPACITY;
  } else {
    capacity = Collections.roundUpToPowerOfTwo(capacity);
  }
  makeTable(capacity);
}
origin: robovm/robovm

  private void readObject(ObjectInputStream stream) throws IOException,
      ClassNotFoundException {
    stream.defaultReadObject();
    int capacity = stream.readInt();
    if (capacity < 0) {
      throw new InvalidObjectException("Capacity: " + capacity);
    }
    if (capacity < MINIMUM_CAPACITY) {
      capacity = MINIMUM_CAPACITY;
    } else if (capacity > MAXIMUM_CAPACITY) {
      capacity = MAXIMUM_CAPACITY;
    } else {
      capacity = Collections.roundUpToPowerOfTwo(capacity);
    }
    makeTable(capacity);

    int size = stream.readInt();
    if (size < 0) {
      throw new InvalidObjectException("Size: " + size);
    }

    init(); // Give subclass (LinkedHashMap) a chance to initialize itself
    for (int i = 0; i < size; i++) {
      @SuppressWarnings("unchecked") K key = (K) stream.readObject();
      @SuppressWarnings("unchecked") V val = (V) stream.readObject();
      constructorPut(key, val);
    }
  }
}
origin: robovm/robovm

/**
 * Returns a shallow copy of this map.
 *
 * @return a shallow copy of this map.
 */
@SuppressWarnings("unchecked")
@Override public Object clone() {
  /*
   * This could be made more efficient. It unnecessarily hashes all of
   * the elements in the map.
   */
  HashMap<K, V> result;
  try {
    result = (HashMap<K, V>) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
  // Restore clone to empty state, retaining our capacity and threshold
  result.makeTable(table.length);
  result.entryForNullKey = null;
  result.size = 0;
  result.keySet = null;
  result.entrySet = null;
  result.values = null;
  result.init(); // Give subclass a chance to initialize itself
  result.constructorPutAll(this); // Calls method overridden in subclass!!
  return result;
}
origin: robovm/robovm

HashMapEntry<K, V>[] newTable = makeTable(newCapacity);
if (size != 0) {
  int newMask = newCapacity - 1;
origin: MobiVM/robovm

/**
 * Constructs a new {@code HashMap} instance with the specified capacity.
 *
 * @param capacity
 *            the initial capacity of this hash map.
 * @throws IllegalArgumentException
 *                when the capacity is less than zero.
 */
public HashMap(int capacity) {
  if (capacity < 0) {
    throw new IllegalArgumentException("Capacity: " + capacity);
  }
  if (capacity == 0) {
    @SuppressWarnings("unchecked")
    HashMapEntry<K, V>[] tab = (HashMapEntry<K, V>[]) EMPTY_TABLE;
    table = tab;
    threshold = -1; // Forces first put() to replace EMPTY_TABLE
    return;
  }
  if (capacity < MINIMUM_CAPACITY) {
    capacity = MINIMUM_CAPACITY;
  } else if (capacity > MAXIMUM_CAPACITY) {
    capacity = MAXIMUM_CAPACITY;
  } else {
    capacity = Collections.roundUpToPowerOfTwo(capacity);
  }
  makeTable(capacity);
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Constructs a new {@code HashMap} instance with the specified capacity.
 *
 * @param capacity
 *            the initial capacity of this hash map.
 * @throws IllegalArgumentException
 *                when the capacity is less than zero.
 */
public HashMap(int capacity) {
  if (capacity < 0) {
    throw new IllegalArgumentException("Capacity: " + capacity);
  }
  if (capacity == 0) {
    @SuppressWarnings("unchecked")
    HashMapEntry<K, V>[] tab = (HashMapEntry<K, V>[]) EMPTY_TABLE;
    table = tab;
    threshold = -1; // Forces first put() to replace EMPTY_TABLE
    return;
  }
  if (capacity < MINIMUM_CAPACITY) {
    capacity = MINIMUM_CAPACITY;
  } else if (capacity > MAXIMUM_CAPACITY) {
    capacity = MAXIMUM_CAPACITY;
  } else {
    capacity = Collections.roundUpToPowerOfTwo(capacity);
  }
  makeTable(capacity);
}
origin: ibinti/bugvm

/**
 * Constructs a new {@code HashMap} instance with the specified capacity.
 *
 * @param capacity
 *            the initial capacity of this hash map.
 * @throws IllegalArgumentException
 *                when the capacity is less than zero.
 */
public HashMap(int capacity) {
  if (capacity < 0) {
    throw new IllegalArgumentException("Capacity: " + capacity);
  }
  if (capacity == 0) {
    @SuppressWarnings("unchecked")
    HashMapEntry<K, V>[] tab = (HashMapEntry<K, V>[]) EMPTY_TABLE;
    table = tab;
    threshold = -1; // Forces first put() to replace EMPTY_TABLE
    return;
  }
  if (capacity < MINIMUM_CAPACITY) {
    capacity = MINIMUM_CAPACITY;
  } else if (capacity > MAXIMUM_CAPACITY) {
    capacity = MAXIMUM_CAPACITY;
  } else {
    capacity = Collections.roundUpToPowerOfTwo(capacity);
  }
  makeTable(capacity);
}
origin: com.jtransc/jtransc-rt

/**
 * Constructs a new {@code HashMap} instance with the specified capacity.
 *
 * @param capacity
 *            the initial capacity of this hash map.
 * @throws IllegalArgumentException
 *                when the capacity is less than zero.
 */
public HashMap(int capacity) {
  if (capacity < 0) {
    throw new IllegalArgumentException("Capacity: " + capacity);
  }
  if (capacity == 0) {
    @SuppressWarnings("unchecked")
    HashMapEntry<K, V>[] tab = (HashMapEntry<K, V>[]) EMPTY_TABLE;
    table = tab;
    threshold = -1; // Forces first put() to replace EMPTY_TABLE
    return;
  }
  if (capacity < MINIMUM_CAPACITY) {
    capacity = MINIMUM_CAPACITY;
  } else if (capacity > MAXIMUM_CAPACITY) {
    capacity = MAXIMUM_CAPACITY;
  } else {
    capacity = Collections.roundUpToPowerOfTwo(capacity);
  }
  makeTable(capacity);
}
origin: com.bugvm/bugvm-rt

/**
 * Constructs a new {@code HashMap} instance with the specified capacity.
 *
 * @param capacity
 *            the initial capacity of this hash map.
 * @throws IllegalArgumentException
 *                when the capacity is less than zero.
 */
public HashMap(int capacity) {
  if (capacity < 0) {
    throw new IllegalArgumentException("Capacity: " + capacity);
  }
  if (capacity == 0) {
    @SuppressWarnings("unchecked")
    HashMapEntry<K, V>[] tab = (HashMapEntry<K, V>[]) EMPTY_TABLE;
    table = tab;
    threshold = -1; // Forces first put() to replace EMPTY_TABLE
    return;
  }
  if (capacity < MINIMUM_CAPACITY) {
    capacity = MINIMUM_CAPACITY;
  } else if (capacity > MAXIMUM_CAPACITY) {
    capacity = MAXIMUM_CAPACITY;
  } else {
    capacity = Collections.roundUpToPowerOfTwo(capacity);
  }
  makeTable(capacity);
}
origin: ibinti/bugvm

  private void readObject(ObjectInputStream stream) throws IOException,
      ClassNotFoundException {
    stream.defaultReadObject();
    int capacity = stream.readInt();
    if (capacity < 0) {
      throw new InvalidObjectException("Capacity: " + capacity);
    }
    if (capacity < MINIMUM_CAPACITY) {
      capacity = MINIMUM_CAPACITY;
    } else if (capacity > MAXIMUM_CAPACITY) {
      capacity = MAXIMUM_CAPACITY;
    } else {
      capacity = Collections.roundUpToPowerOfTwo(capacity);
    }
    makeTable(capacity);

    int size = stream.readInt();
    if (size < 0) {
      throw new InvalidObjectException("Size: " + size);
    }

    init(); // Give subclass (LinkedHashMap) a chance to initialize itself
    for (int i = 0; i < size; i++) {
      @SuppressWarnings("unchecked") K key = (K) stream.readObject();
      @SuppressWarnings("unchecked") V val = (V) stream.readObject();
      constructorPut(key, val);
    }
  }
}
origin: MobiVM/robovm

  private void readObject(ObjectInputStream stream) throws IOException,
      ClassNotFoundException {
    stream.defaultReadObject();
    int capacity = stream.readInt();
    if (capacity < 0) {
      throw new InvalidObjectException("Capacity: " + capacity);
    }
    if (capacity < MINIMUM_CAPACITY) {
      capacity = MINIMUM_CAPACITY;
    } else if (capacity > MAXIMUM_CAPACITY) {
      capacity = MAXIMUM_CAPACITY;
    } else {
      capacity = Collections.roundUpToPowerOfTwo(capacity);
    }
    makeTable(capacity);

    int size = stream.readInt();
    if (size < 0) {
      throw new InvalidObjectException("Size: " + size);
    }

    init(); // Give subclass (LinkedHashMap) a chance to initialize itself
    for (int i = 0; i < size; i++) {
      @SuppressWarnings("unchecked") K key = (K) stream.readObject();
      @SuppressWarnings("unchecked") V val = (V) stream.readObject();
      constructorPut(key, val);
    }
  }
}
origin: com.gluonhq/robovm-rt

  private void readObject(ObjectInputStream stream) throws IOException,
      ClassNotFoundException {
    stream.defaultReadObject();
    int capacity = stream.readInt();
    if (capacity < 0) {
      throw new InvalidObjectException("Capacity: " + capacity);
    }
    if (capacity < MINIMUM_CAPACITY) {
      capacity = MINIMUM_CAPACITY;
    } else if (capacity > MAXIMUM_CAPACITY) {
      capacity = MAXIMUM_CAPACITY;
    } else {
      capacity = Collections.roundUpToPowerOfTwo(capacity);
    }
    makeTable(capacity);

    int size = stream.readInt();
    if (size < 0) {
      throw new InvalidObjectException("Size: " + size);
    }

    init(); // Give subclass (LinkedHashMap) a chance to initialize itself
    for (int i = 0; i < size; i++) {
      @SuppressWarnings("unchecked") K key = (K) stream.readObject();
      @SuppressWarnings("unchecked") V val = (V) stream.readObject();
      constructorPut(key, val);
    }
  }
}
origin: com.mobidevelop.robovm/robovm-rt

  private void readObject(ObjectInputStream stream) throws IOException,
      ClassNotFoundException {
    stream.defaultReadObject();
    int capacity = stream.readInt();
    if (capacity < 0) {
      throw new InvalidObjectException("Capacity: " + capacity);
    }
    if (capacity < MINIMUM_CAPACITY) {
      capacity = MINIMUM_CAPACITY;
    } else if (capacity > MAXIMUM_CAPACITY) {
      capacity = MAXIMUM_CAPACITY;
    } else {
      capacity = Collections.roundUpToPowerOfTwo(capacity);
    }
    makeTable(capacity);

    int size = stream.readInt();
    if (size < 0) {
      throw new InvalidObjectException("Size: " + size);
    }

    init(); // Give subclass (LinkedHashMap) a chance to initialize itself
    for (int i = 0; i < size; i++) {
      @SuppressWarnings("unchecked") K key = (K) stream.readObject();
      @SuppressWarnings("unchecked") V val = (V) stream.readObject();
      constructorPut(key, val);
    }
  }
}
origin: com.bugvm/bugvm-rt

  private void readObject(ObjectInputStream stream) throws IOException,
      ClassNotFoundException {
    stream.defaultReadObject();
    int capacity = stream.readInt();
    if (capacity < 0) {
      throw new InvalidObjectException("Capacity: " + capacity);
    }
    if (capacity < MINIMUM_CAPACITY) {
      capacity = MINIMUM_CAPACITY;
    } else if (capacity > MAXIMUM_CAPACITY) {
      capacity = MAXIMUM_CAPACITY;
    } else {
      capacity = Collections.roundUpToPowerOfTwo(capacity);
    }
    makeTable(capacity);

    int size = stream.readInt();
    if (size < 0) {
      throw new InvalidObjectException("Size: " + size);
    }

    init(); // Give subclass (LinkedHashMap) a chance to initialize itself
    for (int i = 0; i < size; i++) {
      @SuppressWarnings("unchecked") K key = (K) stream.readObject();
      @SuppressWarnings("unchecked") V val = (V) stream.readObject();
      constructorPut(key, val);
    }
  }
}
origin: ibinti/bugvm

/**
 * Returns a shallow copy of this map.
 *
 * @return a shallow copy of this map.
 */
@SuppressWarnings("unchecked")
@Override public Object clone() {
  /*
   * This could be made more efficient. It unnecessarily hashes all of
   * the elements in the map.
   */
  HashMap<K, V> result;
  try {
    result = (HashMap<K, V>) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
  // Restore clone to empty state, retaining our capacity and threshold
  result.makeTable(table.length);
  result.entryForNullKey = null;
  result.size = 0;
  result.keySet = null;
  result.entrySet = null;
  result.values = null;
  result.init(); // Give subclass a chance to initialize itself
  result.constructorPutAll(this); // Calls method overridden in subclass!!
  return result;
}
origin: MobiVM/robovm

/**
 * Returns a shallow copy of this map.
 *
 * @return a shallow copy of this map.
 */
@SuppressWarnings("unchecked")
@Override public Object clone() {
  /*
   * This could be made more efficient. It unnecessarily hashes all of
   * the elements in the map.
   */
  HashMap<K, V> result;
  try {
    result = (HashMap<K, V>) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
  // Restore clone to empty state, retaining our capacity and threshold
  result.makeTable(table.length);
  result.entryForNullKey = null;
  result.size = 0;
  result.keySet = null;
  result.entrySet = null;
  result.values = null;
  result.init(); // Give subclass a chance to initialize itself
  result.constructorPutAll(this); // Calls method overridden in subclass!!
  return result;
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns a shallow copy of this map.
 *
 * @return a shallow copy of this map.
 */
@SuppressWarnings("unchecked")
@Override public Object clone() {
  /*
   * This could be made more efficient. It unnecessarily hashes all of
   * the elements in the map.
   */
  HashMap<K, V> result;
  try {
    result = (HashMap<K, V>) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
  // Restore clone to empty state, retaining our capacity and threshold
  result.makeTable(table.length);
  result.entryForNullKey = null;
  result.size = 0;
  result.keySet = null;
  result.entrySet = null;
  result.values = null;
  result.init(); // Give subclass a chance to initialize itself
  result.constructorPutAll(this); // Calls method overridden in subclass!!
  return result;
}
origin: com.gluonhq/robovm-rt

/**
 * Returns a shallow copy of this map.
 *
 * @return a shallow copy of this map.
 */
@SuppressWarnings("unchecked")
@Override public Object clone() {
  /*
   * This could be made more efficient. It unnecessarily hashes all of
   * the elements in the map.
   */
  HashMap<K, V> result;
  try {
    result = (HashMap<K, V>) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
  // Restore clone to empty state, retaining our capacity and threshold
  result.makeTable(table.length);
  result.entryForNullKey = null;
  result.size = 0;
  result.keySet = null;
  result.entrySet = null;
  result.values = null;
  result.init(); // Give subclass a chance to initialize itself
  result.constructorPutAll(this); // Calls method overridden in subclass!!
  return result;
}
origin: com.bugvm/bugvm-rt

/**
 * Returns a shallow copy of this map.
 *
 * @return a shallow copy of this map.
 */
@SuppressWarnings("unchecked")
@Override public Object clone() {
  /*
   * This could be made more efficient. It unnecessarily hashes all of
   * the elements in the map.
   */
  HashMap<K, V> result;
  try {
    result = (HashMap<K, V>) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
  // Restore clone to empty state, retaining our capacity and threshold
  result.makeTable(table.length);
  result.entryForNullKey = null;
  result.size = 0;
  result.keySet = null;
  result.entrySet = null;
  result.values = null;
  result.init(); // Give subclass a chance to initialize itself
  result.constructorPutAll(this); // Calls method overridden in subclass!!
  return result;
}
java.utilHashMapmakeTable

Javadoc

Allocate a table of the given capacity and set the threshold accordingly.

Popular methods of HashMap

  • <init>
    Constructs a new HashMap instance containing the mappings from the specified map.
  • put
    Maps the specified key to the specified value.
  • get
    Returns the value of the mapping with the specified key.
  • containsKey
    Returns whether this map contains the specified key.
  • keySet
    Returns a set of the keys contained in this map. The set is backed by this map so changes to one are
  • remove
  • entrySet
    Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry.
  • values
    Returns a collection of the values contained in this map. The collection is backed by this map so ch
  • size
    Returns the number of elements in this map.
  • clear
    Removes all mappings from this hash map, leaving it empty.
  • isEmpty
    Returns whether this map is empty.
  • putAll
    Copies all the mappings in the specified map to this map. These mappings will replace all mappings t
  • isEmpty,
  • putAll,
  • clone,
  • toString,
  • containsValue,
  • equals,
  • hashCode,
  • computeIfAbsent,
  • getOrDefault,
  • forEach

Popular in Java

  • Creating JSON documents from java classes using gson
  • runOnUiThread (Activity)
  • putExtra (Intent)
  • startActivity (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • JOptionPane (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now