public class OpenIntSet extends AbstractSet<Integer> implements Serializable
Set
implementation specialized for storing int
values with
efficient storagage and look-up. Internally, this class uses open addressing to
represent the set of int
values in the set. This provides amortized
O(1) access to the get
, set
and remove
operations.
In particular, the remove
operation is designed for supporting access
behaviors where elements are frequently added and removed.
This class overloads the common set operations with primitive accessors.
This enables callers to avoid autoboxing Integer
values to their
primitive equivalents.
This class is not thread safe.
Constructor and Description |
---|
OpenIntSet()
Constructs an
OpenIntSet with the default size (4). |
OpenIntSet(Collection<Integer> ints)
Constructs an
OpenIntSet that will contain all the values in the
provided set. |
OpenIntSet(int size)
Constructs an
OpenIntSet with storage for the specified number of
elements. |
OpenIntSet(OpenIntSet ints)
Constructs an
OpenIntSet that will contain all the values in the
provided set. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(int i) |
boolean |
add(Integer i)
Adds the integer value to this set.
|
void |
clear() |
boolean |
contains(int i) |
boolean |
contains(Object o) |
boolean |
isEmpty() |
Iterator<Integer> |
iterator() |
boolean |
remove(int i) |
boolean |
remove(Integer i) |
int |
size() |
equals, hashCode, removeAll
addAll, containsAll, remove, retainAll, toArray, toArray, toString
public OpenIntSet()
OpenIntSet
with the default size (4).public OpenIntSet(int size)
OpenIntSet
with storage for the specified number of
elements.size
- the number of expected elements to be contained within this
setpublic OpenIntSet(Collection<Integer> ints)
OpenIntSet
that will contain all the values in the
provided set.public OpenIntSet(OpenIntSet ints)
OpenIntSet
that will contain all the values in the
provided set.public boolean add(Integer i)
add
in interface Collection<Integer>
add
in interface Set<Integer>
add
in class AbstractCollection<Integer>
public boolean add(int i)
public boolean contains(Object o)
contains
in interface Collection<Integer>
contains
in interface Set<Integer>
contains
in class AbstractCollection<Integer>
public boolean contains(int i)
public void clear()
clear
in interface Collection<Integer>
clear
in interface Set<Integer>
clear
in class AbstractCollection<Integer>
public boolean isEmpty()
isEmpty
in interface Collection<Integer>
isEmpty
in interface Set<Integer>
isEmpty
in class AbstractCollection<Integer>
public boolean remove(Integer i)
public boolean remove(int i)
public int size()
size
in interface Collection<Integer>
size
in interface Set<Integer>
size
in class AbstractCollection<Integer>
Copyright © 2012. All Rights Reserved.