コード例 #1
1
ファイル: HashMap.java プロジェクト: Cultivators/JDKResource
  /**
   * 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() {
    HashMap<K, V> result = null;
    try {
      result = (HashMap<K, V>) super.clone();
    } catch (CloneNotSupportedException e) {
      // assert false;
    }
    result.table = new Entry[table.length];
    result.entrySet = null;
    result.modCount = 0;
    result.size = 0;
    result.init();
    result.putAllForCreate(this);

    return result;
  }
コード例 #2
0
ファイル: HashMap.java プロジェクト: Cultivators/JDKResource
 /**
  * Constructs a new <tt>HashMap</tt> with the same mappings as the specified <tt>Map</tt>. The
  * <tt>HashMap</tt> is created with default load factor (0.75) and an initial capacity sufficient
  * to hold the mappings in the specified <tt>Map</tt>.
  *
  * @param m the map whose mappings are to be placed in this map
  * @throws NullPointerException if the specified map is null
  */
 public HashMap(Map<? extends K, ? extends V> m) {
   this(
       Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_INITIAL_CAPACITY),
       DEFAULT_LOAD_FACTOR);
   putAllForCreate(m);
 }