GNU Trove

gnu.trove.decorator
Class TIntHashSetDecorator

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractSet
              |
              +--gnu.trove.decorator.TIntHashSetDecorator
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.Set

public class TIntHashSetDecorator
extends java.util.AbstractSet
implements java.util.Set, java.lang.Cloneable

Wrapper 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

Since:
trove 0.1.8
Version:
$Id: TIntHashSetDecorator.java,v 1.4 2004/03/18 15:30:34 ericdf Exp $
Author:
Eric D. Friedman

Field Summary
protected  TIntHashSet _set
          the wrapped primitive set
 
Constructor Summary
TIntHashSetDecorator(TIntHashSet set)
          Creates a wrapper that decorates the specified primitive set.
 
Method Summary
 boolean add(java.lang.Object value)
          Inserts a value into the set.
 void clear()
          Empties the set.
 java.lang.Object 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.
 boolean isEmpty()
          Indicates whether set has any entries.
 java.util.Iterator iterator()
          Creates an iterator over the values of the set.
 boolean remove(java.lang.Object value)
          Deletes a value from the set.
 int size()
          Returns the number of entries in the set.
protected  int unwrap(java.lang.Object value)
          Unwraps a value
protected  java.lang.Integer wrap(int k)
          Wraps a value
 
Methods inherited from class java.util.AbstractSet
hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, contains, containsAll, hashCode, removeAll, retainAll, toArray, toArray
 

Field Detail

_set

protected TIntHashSet _set
the wrapped primitive set

Constructor Detail

TIntHashSetDecorator

public TIntHashSetDecorator(TIntHashSet set)
Creates a wrapper that decorates the specified primitive set.

Method Detail

clone

public java.lang.Object 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 class java.lang.Object
Returns:
a copy of the receiver

add

public boolean add(java.lang.Object value)
Inserts a value into the set.

Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection

equals

public boolean equals(java.lang.Object other)
Compares this set with another set for equality of their stored entries.

Specified by:
equals in interface java.util.Set
Overrides:
equals in class java.util.AbstractSet
Parameters:
other - an Object value
Returns:
true if the sets are identical

clear

public void clear()
Empties the set.

Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.AbstractCollection

remove

public boolean remove(java.lang.Object value)
Deletes a value from the set.

Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.AbstractCollection
Parameters:
value - an Object value
Returns:
true if the set was modified

iterator

public java.util.Iterator iterator()
Creates an iterator over the values of the set.

Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection
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 interface java.util.Set
Specified by:
size in class java.util.AbstractCollection
Returns:
the set's size.

isEmpty

public boolean isEmpty()
Indicates whether set has any entries.

Specified by:
isEmpty in interface java.util.Set
Overrides:
isEmpty in class java.util.AbstractCollection
Returns:
true if the set is empty

wrap

protected java.lang.Integer wrap(int k)
Wraps a value

Returns:
an Object representation of the value

unwrap

protected int unwrap(java.lang.Object value)
Unwraps a value

Returns:
an unwrapped representation of the value

GNU Trove

GNU Trove is copyright © 2001-2003 Eric D. Friedman. All Rights Reserved.