Package gnu.trove.decorator
Class TLongHashSetDecorator
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<java.lang.Long>
-
- gnu.trove.decorator.TLongHashSetDecorator
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,java.lang.Iterable<java.lang.Long>
,java.util.Collection<java.lang.Long>
,java.util.Set<java.lang.Long>
public class TLongHashSetDecorator extends java.util.AbstractSet<java.lang.Long> implements java.util.Set<java.lang.Long>, java.io.Externalizable
Wrapper class to make a TLongHashSet conform to the java.util.Set API. This class simply decorates an underlying TLongHashSet 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 TLongHashSet
_set
the wrapped primitive set
-
Constructor Summary
Constructors Constructor Description TLongHashSetDecorator()
FOR EXTERNALIZATION ONLY!!TLongHashSetDecorator(TLongHashSet 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.Long value)
Inserts a value into the set.void
clear()
Empties the set.TLongHashSetDecorator
clone()
Clones the underlying trove collection and returns the clone wrapped in a new decorator instance.boolean
equals(java.lang.Object other)
Compares this set with another set for equality of their stored entries.TLongHashSet
getSet()
Returns a reference to the set wrapped by this decorator.boolean
isEmpty()
Indicates whether set has any entries.java.util.Iterator<java.lang.Long>
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.protected long
unwrap(java.lang.Object value)
Unwraps a valueprotected java.lang.Long
wrap(long k)
Wraps a valuevoid
writeExternal(java.io.ObjectOutput out)
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, retainAll, toArray, toArray, toString
-
-
-
-
Field Detail
-
_set
protected TLongHashSet _set
the wrapped primitive set
-
-
Constructor Detail
-
TLongHashSetDecorator
public TLongHashSetDecorator()
FOR EXTERNALIZATION ONLY!!
-
TLongHashSetDecorator
public TLongHashSetDecorator(TLongHashSet set)
Creates a wrapper that decorates the specified primitive set.
-
-
Method Detail
-
getSet
public TLongHashSet getSet()
Returns a reference to the set wrapped by this decorator.
-
clone
public TLongHashSetDecorator 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:
clone
in classjava.lang.Object
- Returns:
- a copy of the receiver
-
add
public boolean add(java.lang.Long value)
Inserts a value into the set.- Specified by:
add
in interfacejava.util.Collection<java.lang.Long>
- Specified by:
add
in interfacejava.util.Set<java.lang.Long>
- Overrides:
add
in classjava.util.AbstractCollection<java.lang.Long>
- 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.Long>
- Specified by:
equals
in interfacejava.util.Set<java.lang.Long>
- Overrides:
equals
in classjava.util.AbstractSet<java.lang.Long>
- 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.Long>
- Specified by:
clear
in interfacejava.util.Set<java.lang.Long>
- Overrides:
clear
in classjava.util.AbstractCollection<java.lang.Long>
-
remove
public boolean remove(java.lang.Object value)
Deletes a value from the set.- Specified by:
remove
in interfacejava.util.Collection<java.lang.Long>
- Specified by:
remove
in interfacejava.util.Set<java.lang.Long>
- Overrides:
remove
in classjava.util.AbstractCollection<java.lang.Long>
- Parameters:
value
- anObject
value- Returns:
- true if the set was modified
-
iterator
public java.util.Iterator<java.lang.Long> iterator()
Creates an iterator over the values of the set.- Specified by:
iterator
in interfacejava.util.Collection<java.lang.Long>
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Long>
- Specified by:
iterator
in interfacejava.util.Set<java.lang.Long>
- Specified by:
iterator
in classjava.util.AbstractCollection<java.lang.Long>
- 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.Long>
- Specified by:
size
in interfacejava.util.Set<java.lang.Long>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Long>
- Returns:
- the set's size.
-
isEmpty
public boolean isEmpty()
Indicates whether set has any entries.- Specified by:
isEmpty
in interfacejava.util.Collection<java.lang.Long>
- Specified by:
isEmpty
in interfacejava.util.Set<java.lang.Long>
- Overrides:
isEmpty
in classjava.util.AbstractCollection<java.lang.Long>
- Returns:
- true if the set is empty
-
wrap
protected java.lang.Long wrap(long k)
Wraps a value- Parameters:
k
- value in the underlying set- Returns:
- an Object representation of the value
-
unwrap
protected long 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:
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
-
-