Package gnu.trove.decorator
Class TShortSetDecorator
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<java.lang.Short>
-
- gnu.trove.decorator.TShortSetDecorator
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Iterable<java.lang.Short>,java.util.Collection<java.lang.Short>,java.util.Set<java.lang.Short>
public class TShortSetDecorator extends java.util.AbstractSet<java.lang.Short> implements java.util.Set<java.lang.Short>, java.io.ExternalizableWrapper class to make a TShortSet conform to the java.util.Set API. This class simply decorates an underlying TShortSet 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- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TShortSetDecorator()FOR EXTERNALIZATION ONLY!!TShortSetDecorator(TShortSet set)Creates a wrapper that decorates the specified primitive set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Short value)Inserts a value into the set.voidclear()Empties the set.booleancontains(java.lang.Object o)booleanequals(java.lang.Object other)Compares this set with another set for equality of their stored entries.TShortSetgetSet()Returns a reference to the set wrapped by this decorator.booleanisEmpty()Indicates whether set has any entries.java.util.Iterator<java.lang.Short>iterator()Creates an iterator over the values of the set.voidreadExternal(java.io.ObjectInput in)booleanremove(java.lang.Object value)Deletes a value from the set.intsize()Returns the number of entries in the set.voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
-
-
-
Field Detail
-
_set
protected TShortSet _set
the wrapped primitive set
-
-
Constructor Detail
-
TShortSetDecorator
public TShortSetDecorator()
FOR EXTERNALIZATION ONLY!!
-
TShortSetDecorator
public TShortSetDecorator(TShortSet set)
Creates a wrapper that decorates the specified primitive set.- Parameters:
set- the TShortSet to wrap.
-
-
Method Detail
-
getSet
public TShortSet getSet()
Returns a reference to the set wrapped by this decorator.- Returns:
- the wrapped TShortSet instance.
-
add
public boolean add(java.lang.Short value)
Inserts a value into the set.- Specified by:
addin interfacejava.util.Collection<java.lang.Short>- Specified by:
addin interfacejava.util.Set<java.lang.Short>- Overrides:
addin classjava.util.AbstractCollection<java.lang.Short>- Parameters:
value- true if the set was modified by the insertion
-
equals
public boolean equals(java.lang.Object other)
Compares this set with another set for equality of their stored entries.- Specified by:
equalsin interfacejava.util.Collection<java.lang.Short>- Specified by:
equalsin interfacejava.util.Set<java.lang.Short>- Overrides:
equalsin classjava.util.AbstractSet<java.lang.Short>- Parameters:
other- anObjectvalue- Returns:
- true if the sets are identical
-
clear
public void clear()
Empties the set.- Specified by:
clearin interfacejava.util.Collection<java.lang.Short>- Specified by:
clearin interfacejava.util.Set<java.lang.Short>- Overrides:
clearin classjava.util.AbstractCollection<java.lang.Short>
-
remove
public boolean remove(java.lang.Object value)
Deletes a value from the set.- Specified by:
removein interfacejava.util.Collection<java.lang.Short>- Specified by:
removein interfacejava.util.Set<java.lang.Short>- Overrides:
removein classjava.util.AbstractCollection<java.lang.Short>- Parameters:
value- anObjectvalue- Returns:
- true if the set was modified
-
iterator
public java.util.Iterator<java.lang.Short> iterator()
Creates an iterator over the values of the set.- Specified by:
iteratorin interfacejava.util.Collection<java.lang.Short>- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Short>- Specified by:
iteratorin interfacejava.util.Set<java.lang.Short>- Specified by:
iteratorin classjava.util.AbstractCollection<java.lang.Short>- Returns:
- an iterator with support for removals in the underlying set
-
size
public int size()
Returns the number of entries in the set.- Specified by:
sizein interfacejava.util.Collection<java.lang.Short>- Specified by:
sizein interfacejava.util.Set<java.lang.Short>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Short>- Returns:
- the set's size.
-
isEmpty
public boolean isEmpty()
Indicates whether set has any entries.- Specified by:
isEmptyin interfacejava.util.Collection<java.lang.Short>- Specified by:
isEmptyin interfacejava.util.Set<java.lang.Short>- Overrides:
isEmptyin classjava.util.AbstractCollection<java.lang.Short>- Returns:
- true if the set is empty
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection<java.lang.Short>- Specified by:
containsin interfacejava.util.Set<java.lang.Short>- Overrides:
containsin classjava.util.AbstractCollection<java.lang.Short>
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
-