Package gnu.trove.decorator

# Class TIntSetDecorator

java.lang.Object
java.util.AbstractCollection<Integer>
java.util.AbstractSet<Integer>
gnu.trove.decorator.TIntSetDecorator

All Implemented Interfaces:
  `Externalizable`, `Serializable`, `Iterable<Integer>`, `Collection<Integer>`, `Set<Integer>`

public class TIntSetDecorator extends AbstractSet<Integer> implements Set<Integer>, 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

## Field Summary

Fields
Modifier and Type
Field
Description
`protected TIntSet`
`_set`
the wrapped primitive set

## Constructor Summary

Constructors
Constructor
Description
`TIntSetDecorator()`
FOR EXTERNALIZATION ONLY!!
`TIntSetDecorator(TIntSet set)`
Creates a wrapper that decorates the specified primitive set.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`add(Integer value)`
Inserts a value into the set.
`void`
`clear()`
Empties the set.
`boolean`
`contains(Object o)`
`boolean`
`equals(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.
`Iterator<Integer>`
`iterator()`
Creates an iterator over the values of the set.
`void`
`readExternal(ObjectInput in)`
`boolean`
`remove(Object value)`
Deletes a value from the set.
`int`
`size()`
Returns the number of entries in the set.
`void`
`writeExternal(ObjectOutput out)`

### Methods inherited from class java.util.AbstractSet

`hashCode, removeAll`

### Methods inherited from class java.util.AbstractCollection

`addAll, containsAll, retainAll, toArray, toArray, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Collection

`parallelStream, removeIf, stream, toArray`

### Methods inherited from interface java.lang.Iterable

`forEach`

### Methods inherited from interface java.util.Set

`addAll, containsAll, hashCode, removeAll, retainAll, spliterator, toArray, toArray`

## Field Details

### _set

protected TIntSet _set
the wrapped primitive set

## Constructor Details

### 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 Details

### getSet

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

Returns:
  the wrapped `TIntSet` instance.

### add

public boolean add(Integer value)
Inserts a value into the set.

Specified by:
  `add` in interface `Collection<Integer>`
Specified by:
  `add` in interface `Set<Integer>`
Overrides:
  `add` in class `AbstractCollection<Integer>`
Parameters:
  `value` - true if the set was modified by the insertion

### equals

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

Specified by:
  `equals` in interface `Collection<Integer>`
Specified by:
  `equals` in interface `Set<Integer>`
Overrides:
  `equals` in class `AbstractSet<Integer>`
Parameters:
  `other` - an `Object` value
Returns:
  true if the sets are identical

### clear

public void clear()
Empties the set.

Specified by:
  `clear` in interface `Collection<Integer>`
Specified by:
  `clear` in interface `Set<Integer>`
Overrides:
  `clear` in class `AbstractCollection<Integer>`

### remove

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

Specified by:
  `remove` in interface `Collection<Integer>`
Specified by:
  `remove` in interface `Set<Integer>`
Overrides:
  `remove` in class `AbstractCollection<Integer>`
Parameters:
  `value` - an `Object` value
Returns:
  true if the set was modified

### iterator

public Iterator<Integer> iterator()
Creates an iterator over the values of the set.

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

### isEmpty

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

Specified by:
  `isEmpty` in interface `Collection<Integer>`
Specified by:
  `isEmpty` in interface `Set<Integer>`
Overrides:
  `isEmpty` in class `AbstractCollection<Integer>`
Returns:
  true if the set is empty

### contains

public boolean contains(Object o)

Specified by:
  `contains` in interface `Collection<Integer>`
Specified by:
  `contains` in interface `Set<Integer>`
Overrides:
  `contains` in class `AbstractCollection<Integer>`

### readExternal

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

### writeExternal

public void writeExternal(ObjectOutput out) throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`