@Beta public class IntHashSet extends AbstractIntSet implements Serializable
This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the IntHashSet instance's size (the number of elements) plus the "capacity" of the backing IntHashMap instance (the number of buckets). Thus, it's very important not to set the intial capacity too high (or the load factor too low) if iteration performance is important.
Note that this implementation is not synchronized. If multiple threads access a set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. Beta class. Classes under com.force.i18n.commons package will be moved into a dedicated project.
IntSet,
IntHashMap,
IntMap,
Serialized Form| Constructor and Description |
|---|
IntHashSet()
Constructs a new, empty set; the backing HashMap instance has
default capacity and load factor, which is 0.75.
|
IntHashSet(int initialCapacity)
Constructs a new, empty set; the backing HashMap instance has
the specified initial capacity and default load factor, which is
0.75.
|
IntHashSet(int initialCapacity,
float loadFactor)
Constructs a new, empty set; the backing HashMap instance has
the specified initial capacity and the specified load factor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int o)
Adds the specified element to this set if it is not already
present.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
contains(int o)
Returns true if this set contains the specified element.
|
IntIterator |
iterator()
Returns an iterator over the elements in this set.
|
IntSet |
makeEmpty()
Create a new empty IntSet with the same impl
|
boolean |
remove(int o)
Removes the given element from this set if it is present.
|
int |
size()
Returns the number of elements in this set (its cardinality).
|
containsAll, equals, hashCode, isEmpty, toArraypublic IntHashSet()
public IntHashSet(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacity of the hash map.loadFactor - the load factor of the hash map.IllegalArgumentException - if the initial capacity is less
than zero, or if the load factor is nonpositive.public IntHashSet(int initialCapacity)
initialCapacity - the initial capacity of the hash table.IllegalArgumentException - if the initial capacity is less
than zero.public IntSet makeEmpty()
IntSetpublic IntIterator iterator()
IntSetpublic int size()
public boolean contains(int o)
contains in interface IntSetcontains in class AbstractIntSeto - element whose presence in this set is to be tested.public boolean add(int o)
add in interface IntSetadd in class AbstractIntSeto - element to be added to this set.public boolean remove(int o)
Copyright (c) 2016-2017, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE.txt file in the repository.