gnu.trove.decorator

Class TByteHashSetDecorator

Implemented Interfaces:
Set

public class TByteHashSetDecorator
extends AbstractSet
implements Set

Wrapper class to make a TByteHashSet conform to the java.util.Set API. This class simply decorates an underlying TByteHashSet 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

Field Summary

protected TByteHashSet
_set
the wrapped primitive set

Constructor Summary

TByteHashSetDecorator(TByteHashSet set)
Creates a wrapper that decorates the specified primitive set.

Method Summary

boolean
add(Byte value)
Inserts a value into the set.
void
clear()
Empties the set.
TByteHashSetDecorator
clone()
Clones the underlying trove collection and returns the clone wrapped in a new decorator instance.
boolean
equals(Object other)
Compares this set with another set for equality of their stored entries.
TByteHashSet
getSet()
Returns a reference to the set wrapped by this decorator.
boolean
isEmpty()
Indicates whether set has any entries.
Iterator
iterator()
Creates an iterator over the values of the set.
boolean
remove(Object value)
Deletes a value from the set.
int
size()
Returns the number of entries in the set.
protected byte
unwrap(Object value)
Unwraps a value
protected Byte
wrap(byte k)
Wraps a value

Field Details

_set

protected TByteHashSet _set
the wrapped primitive set

Constructor Details

TByteHashSetDecorator

public TByteHashSetDecorator(TByteHashSet set)
Creates a wrapper that decorates the specified primitive set.

Method Details

add

public boolean add(Byte value)
Inserts a value into the set.
Parameters:
value - true if the set was modified by the insertion

clear

public void clear()
Empties the set.

clone

public TByteHashSetDecorator 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.
Returns:
a copy of the receiver

equals

public boolean equals(Object other)
Compares this set with another set for equality of their stored entries.
Parameters:
other - an Object value
Returns:
true if the sets are identical

getSet

public TByteHashSet getSet()
Returns a reference to the set wrapped by this decorator.

isEmpty

public boolean isEmpty()
Indicates whether set has any entries.
Returns:
true if the set is empty

iterator

public Iterator iterator()
Creates an iterator over the values of the set.
Returns:
an iterator with support for removals in the underlying set

remove

public boolean remove(Object value)
Deletes a value from the set.
Parameters:
value - an Object value
Returns:
true if the set was modified

size

public int size()
Returns the number of entries in the set.
Returns:
the set's size.

unwrap

protected byte unwrap(Object value)
Unwraps a value
Parameters:
value - wrapped value
Returns:
an unwrapped representation of the value

wrap

protected Byte wrap(byte k)
Wraps a value
Parameters:
k - value in the underlying set
Returns:
an Object representation of the value

GNU Trove is copyright B) 2001-2007 Eric D. Friedman. All Rights Reserved.