Package gnu.trove.decorator
Class TShortHashSetDecorator
- All Implemented Interfaces:
Externalizable
,Serializable
,Iterable<Short>
,Collection<Short>
,Set<Short>
public class TShortHashSetDecorator
extends AbstractSet<Short>
implements Set<Short>, Externalizable
Wrapper class to make a TShortHashSet conform to the java.util.Set API.
This class simply decorates an underlying TShortHashSet and translates the Object-based
APIs into their Trove primitive analogs.
Note that wrapping and unwrapping primitive values is extremely inefficient. If
possible, users of this class should override the appropriate methods in this class
and use a table of canonical values.
Created: Tue Sep 24 22:08:17 PDT 2002
- Author:
- Eric D. Friedman
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFOR EXTERNALIZATION ONLY!!Creates a wrapper that decorates the specified primitive set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Inserts a value into the set.void
clear()
Empties the set.clone()
Clones the underlying trove collection and returns the clone wrapped in a new decorator instance.boolean
Compares this set with another set for equality of their stored entries.getSet()
Returns a reference to the set wrapped by this decorator.boolean
isEmpty()
Indicates whether set has any entries.iterator()
Creates an iterator over the values of the set.void
boolean
Deletes a value from the set.int
size()
Returns the number of entries in the set.protected short
Unwraps a valueprotected Short
wrap
(short k) Wraps a valuevoid
Methods inherited from class java.util.AbstractSet
hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
addAll, contains, containsAll, hashCode, removeAll, retainAll, spliterator, toArray, toArray
-
Field Details
-
_set
the wrapped primitive set
-
-
Constructor Details
-
TShortHashSetDecorator
public TShortHashSetDecorator()FOR EXTERNALIZATION ONLY!! -
TShortHashSetDecorator
Creates a wrapper that decorates the specified primitive set.
-
-
Method Details
-
getSet
Returns a reference to the set wrapped by this decorator. -
clone
Clones the underlying trove collection and returns the clone wrapped in a new decorator instance. This is a shallow clone except where primitives are concerned. -
add
Inserts a value into the set.- Specified by:
add
in interfaceCollection<Short>
- Specified by:
add
in interfaceSet<Short>
- Overrides:
add
in classAbstractCollection<Short>
- Parameters:
value
- true if the set was modified by the insertion
-
equals
Compares this set with another set for equality of their stored entries.- Specified by:
equals
in interfaceCollection<Short>
- Specified by:
equals
in interfaceSet<Short>
- Overrides:
equals
in classAbstractSet<Short>
- Parameters:
other
- anObject
value- Returns:
- true if the sets are identical
-
clear
public void clear()Empties the set.- Specified by:
clear
in interfaceCollection<Short>
- Specified by:
clear
in interfaceSet<Short>
- Overrides:
clear
in classAbstractCollection<Short>
-
remove
Deletes a value from the set.- Specified by:
remove
in interfaceCollection<Short>
- Specified by:
remove
in interfaceSet<Short>
- Overrides:
remove
in classAbstractCollection<Short>
- Parameters:
value
- anObject
value- Returns:
- true if the set was modified
-
iterator
Creates an iterator over the values of the set. -
size
public int size()Returns the number of entries in the set.- Specified by:
size
in interfaceCollection<Short>
- Specified by:
size
in interfaceSet<Short>
- Specified by:
size
in classAbstractCollection<Short>
- Returns:
- the set's size.
-
isEmpty
public boolean isEmpty()Indicates whether set has any entries.- Specified by:
isEmpty
in interfaceCollection<Short>
- Specified by:
isEmpty
in interfaceSet<Short>
- Overrides:
isEmpty
in classAbstractCollection<Short>
- Returns:
- true if the set is empty
-
wrap
Wraps a value- Parameters:
k
- value in the underlying set- Returns:
- an Object representation of the value
-
unwrap
Unwraps a value- Parameters:
value
- wrapped value- Returns:
- an unwrapped representation of the value
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-