Package gnu.trove.decorator
Class TIntHashSetDecorator
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<java.lang.Integer>
-
- gnu.trove.decorator.TIntHashSetDecorator
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Iterable<java.lang.Integer>,java.util.Collection<java.lang.Integer>,java.util.Set<java.lang.Integer>
public class TIntHashSetDecorator extends java.util.AbstractSet<java.lang.Integer> implements java.util.Set<java.lang.Integer>, java.io.ExternalizableWrapper class to make a TIntHashSet conform to the java.util.Set API. This class simply decorates an underlying TIntHashSet 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TIntHashSet_setthe wrapped primitive set
-
Constructor Summary
Constructors Constructor Description TIntHashSetDecorator()FOR EXTERNALIZATION ONLY!!TIntHashSetDecorator(TIntHashSet 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.Integer value)Inserts a value into the set.voidclear()Empties the set.TIntHashSetDecoratorclone()Clones the underlying trove collection and returns the clone wrapped in a new decorator instance.booleanequals(java.lang.Object other)Compares this set with another set for equality of their stored entries.TIntHashSetgetSet()Returns a reference to the set wrapped by this decorator.booleanisEmpty()Indicates whether set has any entries.java.util.Iterator<java.lang.Integer>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.protected intunwrap(java.lang.Object value)Unwraps a valueprotected java.lang.Integerwrap(int k)Wraps a valuevoidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, retainAll, toArray, toArray, toString
-
-
-
-
Field Detail
-
_set
protected TIntHashSet _set
the wrapped primitive set
-
-
Constructor Detail
-
TIntHashSetDecorator
public TIntHashSetDecorator()
FOR EXTERNALIZATION ONLY!!
-
TIntHashSetDecorator
public TIntHashSetDecorator(TIntHashSet set)
Creates a wrapper that decorates the specified primitive set.
-
-
Method Detail
-
getSet
public TIntHashSet getSet()
Returns a reference to the set wrapped by this decorator.
-
clone
public TIntHashSetDecorator 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.- Overrides:
clonein classjava.lang.Object- Returns:
- a copy of the receiver
-
add
public boolean add(java.lang.Integer value)
Inserts a value into the set.- Specified by:
addin interfacejava.util.Collection<java.lang.Integer>- Specified by:
addin interfacejava.util.Set<java.lang.Integer>- Overrides:
addin classjava.util.AbstractCollection<java.lang.Integer>- 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.Integer>- Specified by:
equalsin interfacejava.util.Set<java.lang.Integer>- Overrides:
equalsin classjava.util.AbstractSet<java.lang.Integer>- 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.Integer>- Specified by:
clearin interfacejava.util.Set<java.lang.Integer>- Overrides:
clearin classjava.util.AbstractCollection<java.lang.Integer>
-
remove
public boolean remove(java.lang.Object value)
Deletes a value from the set.- Specified by:
removein interfacejava.util.Collection<java.lang.Integer>- Specified by:
removein interfacejava.util.Set<java.lang.Integer>- Overrides:
removein classjava.util.AbstractCollection<java.lang.Integer>- Parameters:
value- anObjectvalue- Returns:
- true if the set was modified
-
iterator
public java.util.Iterator<java.lang.Integer> iterator()
Creates an iterator over the values of the set.- Specified by:
iteratorin interfacejava.util.Collection<java.lang.Integer>- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Integer>- Specified by:
iteratorin interfacejava.util.Set<java.lang.Integer>- Specified by:
iteratorin classjava.util.AbstractCollection<java.lang.Integer>- 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.Integer>- Specified by:
sizein interfacejava.util.Set<java.lang.Integer>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Integer>- Returns:
- the set's size.
-
isEmpty
public boolean isEmpty()
Indicates whether set has any entries.- Specified by:
isEmptyin interfacejava.util.Collection<java.lang.Integer>- Specified by:
isEmptyin interfacejava.util.Set<java.lang.Integer>- Overrides:
isEmptyin classjava.util.AbstractCollection<java.lang.Integer>- Returns:
- true if the set is empty
-
wrap
protected java.lang.Integer wrap(int k)
Wraps a value- Parameters:
k- value in the underlying set- Returns:
- an Object representation of the value
-
unwrap
protected int unwrap(java.lang.Object value)
Unwraps a value- Parameters:
value- wrapped value- Returns:
- an unwrapped representation of the value
-
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
-
-