/**
  * Grow the internal array as needed to accommodate the specified number of elements. The size of
  * the array bytes on each resize unless capacity requires more than twice the current capacity.
  */
 public void ensureCapacity(int capacity) {
   int oldCapacity = capacity();
   if (capacity > oldCapacity) {
     int newCap = Math.max(oldCapacity << 1, capacity);
     _data.resize(newCap);
   }
 }
  /**
   * Creates a new <code>TIntIntHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>int</tt> array containing the keys for the matching values.
   * @param values a <tt>int</tt> array containing the values.
   */
  public TIntIntHashMap(int[] keys, int[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
  /**
   * Creates a new <code>TByteShortHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>byte</tt> array containing the keys for the matching values.
   * @param values a <tt>short</tt> array containing the values.
   */
  public TByteShortHashMap(byte[] keys, short[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
  /**
   * Creates a new <code>TLongFloatHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>long</tt> array containing the keys for the matching values.
   * @param values a <tt>float</tt> array containing the values.
   */
  public TLongFloatHashMap(long[] keys, float[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
示例#5
0
  /**
   * Creates a new <code>TFloatByteHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>float</tt> array containing the keys for the matching values.
   * @param values a <tt>byte</tt> array containing the values.
   */
  public TFloatByteHashMap(float[] keys, byte[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
  /**
   * Creates a new <code>TDoubleCharHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>double</tt> array containing the keys for the matching values.
   * @param values a <tt>char</tt> array containing the values.
   */
  public TDoubleCharHashMap(double[] keys, char[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }