equal
deleted
inserted
replaced
98 /** |
98 /** |
99 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has |
99 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has |
100 * default initial capacity (16) and load factor (0.75). |
100 * default initial capacity (16) and load factor (0.75). |
101 */ |
101 */ |
102 public HashSet() { |
102 public HashSet() { |
103 map = new HashMap<E,Object>(); |
103 map = new HashMap<>(); |
104 } |
104 } |
105 |
105 |
106 /** |
106 /** |
107 * Constructs a new set containing the elements in the specified |
107 * Constructs a new set containing the elements in the specified |
108 * collection. The <tt>HashMap</tt> is created with default load factor |
108 * collection. The <tt>HashMap</tt> is created with default load factor |
111 * |
111 * |
112 * @param c the collection whose elements are to be placed into this set |
112 * @param c the collection whose elements are to be placed into this set |
113 * @throws NullPointerException if the specified collection is null |
113 * @throws NullPointerException if the specified collection is null |
114 */ |
114 */ |
115 public HashSet(Collection<? extends E> c) { |
115 public HashSet(Collection<? extends E> c) { |
116 map = new HashMap<E,Object>(Math.max((int) (c.size()/.75f) + 1, 16)); |
116 map = new HashMap<>(Math.max((int) (c.size()/.75f) + 1, 16)); |
117 addAll(c); |
117 addAll(c); |
118 } |
118 } |
119 |
119 |
120 /** |
120 /** |
121 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has |
121 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has |
125 * @param loadFactor the load factor of the hash map |
125 * @param loadFactor the load factor of the hash map |
126 * @throws IllegalArgumentException if the initial capacity is less |
126 * @throws IllegalArgumentException if the initial capacity is less |
127 * than zero, or if the load factor is nonpositive |
127 * than zero, or if the load factor is nonpositive |
128 */ |
128 */ |
129 public HashSet(int initialCapacity, float loadFactor) { |
129 public HashSet(int initialCapacity, float loadFactor) { |
130 map = new HashMap<E,Object>(initialCapacity, loadFactor); |
130 map = new HashMap<>(initialCapacity, loadFactor); |
131 } |
131 } |
132 |
132 |
133 /** |
133 /** |
134 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has |
134 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has |
135 * the specified initial capacity and default load factor (0.75). |
135 * the specified initial capacity and default load factor (0.75). |
137 * @param initialCapacity the initial capacity of the hash table |
137 * @param initialCapacity the initial capacity of the hash table |
138 * @throws IllegalArgumentException if the initial capacity is less |
138 * @throws IllegalArgumentException if the initial capacity is less |
139 * than zero |
139 * than zero |
140 */ |
140 */ |
141 public HashSet(int initialCapacity) { |
141 public HashSet(int initialCapacity) { |
142 map = new HashMap<E,Object>(initialCapacity); |
142 map = new HashMap<>(initialCapacity); |
143 } |
143 } |
144 |
144 |
145 /** |
145 /** |
146 * Constructs a new, empty linked hash set. (This package private |
146 * Constructs a new, empty linked hash set. (This package private |
147 * constructor is only used by LinkedHashSet.) The backing |
147 * constructor is only used by LinkedHashSet.) The backing |
154 * constructor from other int, float constructor.) |
154 * constructor from other int, float constructor.) |
155 * @throws IllegalArgumentException if the initial capacity is less |
155 * @throws IllegalArgumentException if the initial capacity is less |
156 * than zero, or if the load factor is nonpositive |
156 * than zero, or if the load factor is nonpositive |
157 */ |
157 */ |
158 HashSet(int initialCapacity, float loadFactor, boolean dummy) { |
158 HashSet(int initialCapacity, float loadFactor, boolean dummy) { |
159 map = new LinkedHashMap<E,Object>(initialCapacity, loadFactor); |
159 map = new LinkedHashMap<>(initialCapacity, loadFactor); |
160 } |
160 } |
161 |
161 |
162 /** |
162 /** |
163 * Returns an iterator over the elements in this set. The elements |
163 * Returns an iterator over the elements in this set. The elements |
164 * are returned in no particular order. |
164 * are returned in no particular order. |