Package gnu.trove.decorator
Class TIntSetDecorator
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<java.lang.Integer>
-
- gnu.trove.decorator.TIntSetDecorator
-
- 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 TIntSetDecorator extends java.util.AbstractSet<java.lang.Integer> implements java.util.Set<java.lang.Integer>, java.io.Externalizable
Wrapper class to make a TIntSet conform to the java.util.Set API. This class simply decorates an underlying TIntSet 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 TIntSetDecorator()
FOR EXTERNALIZATION ONLY!!TIntSetDecorator(TIntSet set)
Creates a wrapper that decorates the specified primitive set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(java.lang.Integer value)
Inserts a value into the set.void
clear()
Empties the set.boolean
contains(java.lang.Object o)
boolean
equals(java.lang.Object other)
Compares this set with another set for equality of their stored entries.TIntSet
getSet()
Returns a reference to the set wrapped by this decorator.boolean
isEmpty()
Indicates whether set has any entries.java.util.Iterator<java.lang.Integer>
iterator()
Creates an iterator over the values of the set.void
readExternal(java.io.ObjectInput in)
boolean
remove(java.lang.Object value)
Deletes a value from the set.int
size()
Returns the number of entries in the set.void
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
-
-
-
Field Detail
-
_set
protected TIntSet _set
the wrapped primitive set
-
-
Constructor Detail
-
TIntSetDecorator
public TIntSetDecorator()
FOR EXTERNALIZATION ONLY!!
-
TIntSetDecorator
public TIntSetDecorator(TIntSet set)
Creates a wrapper that decorates the specified primitive set.- Parameters:
set
- the TIntSet to wrap.
-
-
Method Detail
-
getSet
public TIntSet getSet()
Returns a reference to the set wrapped by this decorator.- Returns:
- the wrapped TIntSet instance.
-
add
public boolean add(java.lang.Integer value)
Inserts a value into the set.- Specified by:
add
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
add
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
add
in 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:
equals
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
equals
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
equals
in classjava.util.AbstractSet<java.lang.Integer>
- Parameters:
other
- anObject
value- Returns:
- true if the sets are identical
-
clear
public void clear()
Empties the set.- Specified by:
clear
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
clear
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
clear
in classjava.util.AbstractCollection<java.lang.Integer>
-
remove
public boolean remove(java.lang.Object value)
Deletes a value from the set.- Specified by:
remove
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
remove
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
remove
in classjava.util.AbstractCollection<java.lang.Integer>
- Parameters:
value
- anObject
value- 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:
iterator
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Integer>
- Specified by:
iterator
in interfacejava.util.Set<java.lang.Integer>
- Specified by:
iterator
in 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:
size
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
size
in interfacejava.util.Set<java.lang.Integer>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Integer>
- Returns:
- the set's size.
-
isEmpty
public boolean isEmpty()
Indicates whether set has any entries.- Specified by:
isEmpty
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
isEmpty
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
isEmpty
in classjava.util.AbstractCollection<java.lang.Integer>
- Returns:
- true if the set is empty
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<java.lang.Integer>
- Specified by:
contains
in interfacejava.util.Set<java.lang.Integer>
- Overrides:
contains
in classjava.util.AbstractCollection<java.lang.Integer>
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
-