Top Description Inners Fields Constructors Methods
java.util

pack-priv final Class JumboEnumSet<E extends Enum<E>>

extends EnumSet<E extends Enum<E>>
Class Inheritance

Private implementation class for EnumSet, for "jumbo" enum types (i.e., those with more than 64 elements).
Author
Josh Bloch
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private long[]
elements

Bit vector representation of this set.

private static final long
private int
Inherited from java.util.EnumSet:
elementTypeuniverse

Constructor Summary

AccessConstructor and Description
pack-priv
JumboEnumSet(Class<E> elementType, Enum<?>[] universe)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the set changed as a result of the call
add
(E
element to be added to this set
e
)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds the specified element to this set if it is not already present.

pack-priv void
addAll()

Implements abstract java.util.EnumSet.addAll.

Adds all of the elements from the appropriate enum type to this enum set, which is empty prior to the call.

public boolean

Returns:

true if this set changed as a result of the call
addAll
(Collection<? extends E>
collection whose elements are to be added to this set
c
)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.Set.addAll, java.util.Collection.addAll.

Adds all of the elements in the specified collection to this set.

pack-priv void
addRange(E from, E to)

Implements abstract java.util.EnumSet.addRange.

Adds the specified range to this enum set, which is empty prior to the call.

public void
clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Removes all of the elements from this set.

public EnumSet<E>
clone()

Overrides java.util.EnumSet.clone.

Returns a copy of this set.

pack-priv void
complement()

Implements abstract java.util.EnumSet.complement.

Complements the contents of this enum set.

public boolean

Returns:

true if this set contains the specified element
contains
(Object
element to be checked for containment in this collection
e
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.

public boolean

Returns:

true if this set contains all of the elements in the specified collection
containsAll
(Collection<?>
collection to be checked for containment in this set
c
)

Overrides java.util.AbstractCollection.containsAll.

Implements java.util.Set.containsAll, java.util.Collection.containsAll.

Returns true if this set contains all of the elements in the specified collection.

public boolean

Returns:

true if the specified object is equal to this set
equals
(Object
object to be compared for equality with this set
o
)

Overrides java.util.AbstractSet.equals.

Implements java.util.Set.equals, java.util.Collection.equals.

Compares the specified object with this set for equality.

public boolean

Returns:

true if this set contains no elements
isEmpty
()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Set.isEmpty, java.util.Collection.isEmpty.

Returns true if this set contains no elements.

public Iterator<E>

Returns:

an iterator over the elements contained in this set
iterator
()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements contained in this set.

private boolean
recalculateSize()

Recalculates the size of the set.

public boolean

Returns:

true if the set contained the specified element
remove
(Object
element to be removed from this set, if present
e
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present.

public boolean

Returns:

true if this set changed as a result of the call
removeAll
(Collection<?>
elements to be removed from this set
c
)

Overrides java.util.AbstractSet.removeAll.

Implements java.util.Set.removeAll, java.util.Collection.removeAll.

Removes from this set all of its elements that are contained in the specified collection.

public boolean

Returns:

true if this set changed as a result of the call
retainAll
(Collection<?>
elements to be retained in this set
c
)

Overrides java.util.AbstractCollection.retainAll.

Implements java.util.Set.retainAll, java.util.Collection.retainAll.

Retains only the elements in this set that are contained in the specified collection.

public int

Returns:

the number of elements in this set
size
()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set.

Inherited from java.util.EnumSet:
allOfcomplementOfcopyOfcopyOfnoneOfofofofofofofrangetypeCheckwriteReplace

Field Detail

elementsback to summary
private long[] elements

Bit vector representation of this set. The ith bit of the jth element of this array represents the presence of universe[64*j +i] in this set.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.EnumSet.serialVersionUID.

Annotations
@Serial
sizeback to summary
private int size

Constructor Detail

JumboEnumSetback to summary
pack-priv JumboEnumSet(Class<E> elementType, Enum<?>[] universe)

Method Detail

addback to summary
public boolean add(E e)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds the specified element to this set if it is not already present.

Parameters
e:E

element to be added to this set

Returns:boolean

true if the set changed as a result of the call

Exceptions
NullPointerException:
if e is null
addAllback to summary
pack-priv void addAll()

Implements abstract java.util.EnumSet.addAll.

Doc from java.util.EnumSet.addAll.

Adds all of the elements from the appropriate enum type to this enum set, which is empty prior to the call.

addAllback to summary
public boolean addAll(Collection<? extends E> c)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.Set.addAll, java.util.Collection.addAll.

Adds all of the elements in the specified collection to this set.

Parameters
c:Collection<? extends E>

collection whose elements are to be added to this set

Returns:boolean

true if this set changed as a result of the call

Exceptions
NullPointerException:
if the specified collection or any of its elements are null
addRangeback to summary
pack-priv void addRange(E from, E to)

Implements abstract java.util.EnumSet.addRange.

Doc from java.util.EnumSet.addRange.

Adds the specified range to this enum set, which is empty prior to the call.

clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Removes all of the elements from this set.

cloneback to summary
public EnumSet<E> clone()

Overrides java.util.EnumSet.clone.

Doc from java.util.EnumSet.clone.

Returns a copy of this set.

Returns:EnumSet<E>

a copy of this set

complementback to summary
pack-priv void complement()

Implements abstract java.util.EnumSet.complement.

Doc from java.util.EnumSet.complement.

Complements the contents of this enum set.

containsback to summary
public boolean contains(Object e)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.

Parameters
e:Object

element to be checked for containment in this collection

Returns:boolean

true if this set contains the specified element

containsAllback to summary
public boolean containsAll(Collection<?> c)

Overrides java.util.AbstractCollection.containsAll.

Implements java.util.Set.containsAll, java.util.Collection.containsAll.

Returns true if this set contains all of the elements in the specified collection.

Parameters
c:Collection<?>

collection to be checked for containment in this set

Returns:boolean

true if this set contains all of the elements in the specified collection

Exceptions
NullPointerException:
if the specified collection is null
equalsback to summary
public boolean equals(Object o)

Overrides java.util.AbstractSet.equals.

Implements java.util.Set.equals, java.util.Collection.equals.

Compares the specified object with this set for equality. Returns true if the given object is also a set, the two sets have the same size, and every member of the given set is contained in this set.

Parameters
o:Object

object to be compared for equality with this set

Returns:boolean

true if the specified object is equal to this set

isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Set.isEmpty, java.util.Collection.isEmpty.

Returns true if this set contains no elements.

Returns:boolean

true if this set contains no elements

iteratorback to summary
public Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements contained in this set. The iterator traverses the elements in their natural order (which is the order in which the enum constants are declared). The returned Iterator is a "weakly consistent" iterator that will never throw ConcurrentModificationException.

Returns:Iterator<E>

an iterator over the elements contained in this set

recalculateSizeback to summary
private boolean recalculateSize()

Recalculates the size of the set. Returns true if it's changed.

removeback to summary
public boolean remove(Object e)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present.

Parameters
e:Object

element to be removed from this set, if present

Returns:boolean

true if the set contained the specified element

removeAllback to summary
public boolean removeAll(Collection<?> c)

Overrides java.util.AbstractSet.removeAll.

Implements java.util.Set.removeAll, java.util.Collection.removeAll.

Removes from this set all of its elements that are contained in the specified collection.

Parameters
c:Collection<?>

elements to be removed from this set

Returns:boolean

true if this set changed as a result of the call

Exceptions
NullPointerException:
if the specified collection is null
retainAllback to summary
public boolean retainAll(Collection<?> c)

Overrides java.util.AbstractCollection.retainAll.

Implements java.util.Set.retainAll, java.util.Collection.retainAll.

Retains only the elements in this set that are contained in the specified collection.

Parameters
c:Collection<?>

elements to be retained in this set

Returns:boolean

true if this set changed as a result of the call

Exceptions
NullPointerException:
if the specified collection is null
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set.

Returns:int

the number of elements in this set

java.util back to summary

private Class JumboEnumSet.EnumSetIterator<E extends Enum<E>>

extends Object
implements Iterator<E extends Enum<E>>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
pack-priv long
lastReturned

The bit representing the last element returned by this iterator but not removed, or zero if no such element exists.

pack-priv int
lastReturnedIndex

The index corresponding to lastReturned in the elements array.

pack-priv long
unseen

A bit vector representing the elements in the current "word" of the set not yet returned by this iterator.

pack-priv int
unseenIndex

The index corresponding to unseen in the elements array.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public E
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lastReturnedback to summary
pack-priv long lastReturned

The bit representing the last element returned by this iterator but not removed, or zero if no such element exists.

lastReturnedIndexback to summary
pack-priv int lastReturnedIndex

The index corresponding to lastReturned in the elements array.

unseenback to summary
pack-priv long unseen

A bit vector representing the elements in the current "word" of the set not yet returned by this iterator.

unseenIndexback to summary
pack-priv int unseenIndex

The index corresponding to unseen in the elements array.

Constructor Detail

EnumSetIteratorback to summary
pack-priv EnumSetIterator()

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public E next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:E

the next element in the iteration

Annotations
@Override
@SuppressWarnings:unchecked
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override