it.unimi.dsi.fastutil.ints
Class AbstractIntCollection

java.lang.Object
  extended by java.util.AbstractCollection<Integer>
      extended by it.unimi.dsi.fastutil.ints.AbstractIntCollection
All Implemented Interfaces:
IntCollection, IntIterable, Iterable<Integer>, Collection<Integer>
Direct Known Subclasses:
AbstractIntBigList, AbstractIntList, AbstractIntSet, IntCollections.EmptyCollection, IntCollections.IterableCollection

public abstract class AbstractIntCollection
extends AbstractCollection<Integer>
implements IntCollection

An abstract class providing basic methods for collections implementing a type-specific interface.

In particular, this class provide iterator(), add(), remove(Object) and contains(Object) methods that just call the type-specific counterpart.


Method Summary
 boolean add(int k)
           
 boolean add(Integer o)
          Delegates to the corresponding type-specific method.
 boolean addAll(Collection<? extends Integer> c)
          Adds all elements of the given collection to this collection.
 boolean addAll(IntCollection c)
          Adds all elements of the given type-specific collection to this collection.
 boolean contains(int k)
           
 boolean contains(Object o)
          Delegates to the corresponding type-specific method.
 boolean containsAll(Collection<?> c)
          Checks whether this collection contains all elements from the given collection.
 boolean containsAll(IntCollection c)
          Checks whether this collection contains all elements from the given type-specific collection.
 IntIterator intIterator()
          Deprecated. 
 boolean isEmpty()
           
abstract  IntIterator iterator()
          Returns a type-specific iterator on the elements of this collection.
 boolean rem(int k)
          Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name.
 boolean rem(Object o)
          Delegates to the corresponding type-specific method.
 boolean remove(Object ok)
          Delegates to the type-specific rem() method.
 boolean removeAll(Collection<?> c)
          Remove from this collection all elements in the given collection.
 boolean removeAll(IntCollection c)
          Remove from this collection all elements in the given type-specific collection.
 boolean retainAll(Collection<?> c)
          Retains in this collection only elements from the given collection.
 boolean retainAll(IntCollection c)
          Retains in this collection only elements from the given type-specific collection.
 Object[] toArray()
           
 int[] toArray(int[] a)
          Returns a primitive type array containing the items of this collection.
<T> T[]
toArray(T[] a)
          Returns an containing the items of this collection; the runtime type of the returned array is that of the specified array.
 int[] toIntArray()
          Returns a primitive type array containing the items of this collection.
 int[] toIntArray(int[] a)
          Returns a primitive type array containing the items of this collection.
 String toString()
           
 
Methods inherited from class java.util.AbstractCollection
clear, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
clear, equals, hashCode, size
 

Method Detail

toArray

public int[] toArray(int[] a)
Description copied from interface: IntCollection
Returns a primitive type array containing the items of this collection.

Note that, contrarily to Collection.toArray(Object[]), this methods just writes all elements of this collection: no special value will be added after the last one.

Specified by:
toArray in interface IntCollection
Parameters:
a - if this array is big enough, it will be used to store this collection.
Returns:
a primitive type array containing the items of this collection.
See Also:
Collection.toArray(Object[])

toIntArray

public int[] toIntArray()
Description copied from interface: IntCollection
Returns a primitive type array containing the items of this collection.

Specified by:
toIntArray in interface IntCollection
Returns:
a primitive type array containing the items of this collection.
See Also:
Collection.toArray()

toIntArray

public int[] toIntArray(int[] a)
Description copied from interface: IntCollection
Returns a primitive type array containing the items of this collection.

Note that, contrarily to Collection.toArray(Object[]), this methods just writes all elements of this collection: no special value will be added after the last one.

Specified by:
toIntArray in interface IntCollection
Parameters:
a - if this array is big enough, it will be used to store this collection.
Returns:
a primitive type array containing the items of this collection.
See Also:
Collection.toArray(Object[])

addAll

public boolean addAll(IntCollection c)
Adds all elements of the given type-specific collection to this collection.

Specified by:
addAll in interface IntCollection
Parameters:
c - a type-specific collection.
Returns:
true if this collection changed as a result of the call.
See Also:
Collection.addAll(Collection)

containsAll

public boolean containsAll(IntCollection c)
Checks whether this collection contains all elements from the given type-specific collection.

Specified by:
containsAll in interface IntCollection
Parameters:
c - a type-specific collection.
Returns:
true if this collection contains all elements of the argument.
See Also:
Collection.containsAll(Collection)

retainAll

public boolean retainAll(IntCollection c)
Retains in this collection only elements from the given type-specific collection.

Specified by:
retainAll in interface IntCollection
Parameters:
c - a type-specific collection.
Returns:
true if this collection changed as a result of the call.
See Also:
Collection.retainAll(Collection)

removeAll

public boolean removeAll(IntCollection c)
Remove from this collection all elements in the given type-specific collection.

Specified by:
removeAll in interface IntCollection
Parameters:
c - a type-specific collection.
Returns:
true if this collection changed as a result of the call.
See Also:
Collection.removeAll(Collection)

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<Integer>
Overrides:
toArray in class AbstractCollection<Integer>

toArray

public <T> T[] toArray(T[] a)
Description copied from interface: IntCollection
Returns an containing the items of this collection; the runtime type of the returned array is that of the specified array.

Warning: Note that, contrarily to Collection.toArray(Object[]), this methods just writes all elements of this collection: no special value will be added after the last one.

Specified by:
toArray in interface IntCollection
Specified by:
toArray in interface Collection<Integer>
Overrides:
toArray in class AbstractCollection<Integer>
Parameters:
a - if this array is big enough, it will be used to store this collection.
Returns:
a primitive type array containing the items of this collection.
See Also:
Collection.toArray(Object[])

addAll

public boolean addAll(Collection<? extends Integer> c)
Adds all elements of the given collection to this collection.

Specified by:
addAll in interface Collection<Integer>
Overrides:
addAll in class AbstractCollection<Integer>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

add

public boolean add(int k)
Specified by:
add in interface IntCollection
See Also:
Collection.add(Object)

intIterator

@Deprecated
public IntIterator intIterator()
Deprecated. 

Delegates to the new covariantly stronger generic method.

Specified by:
intIterator in interface IntCollection
See Also:
IntCollection.iterator()

iterator

public abstract IntIterator iterator()
Description copied from interface: IntCollection
Returns a type-specific iterator on the elements of this collection.

Note that this specification strengthens the one given in Iterable.iterator(), which was already strengthened in the corresponding type-specific class, but was weakened by the fact that this interface extends Collection.

Specified by:
iterator in interface IntCollection
Specified by:
iterator in interface IntIterable
Specified by:
iterator in interface Iterable<Integer>
Specified by:
iterator in interface Collection<Integer>
Specified by:
iterator in class AbstractCollection<Integer>
Returns:
a type-specific iterator on the elements of this collection.

remove

public boolean remove(Object ok)
Delegates to the type-specific rem() method.

Specified by:
remove in interface Collection<Integer>
Overrides:
remove in class AbstractCollection<Integer>

add

public boolean add(Integer o)
Delegates to the corresponding type-specific method.

Specified by:
add in interface Collection<Integer>
Overrides:
add in class AbstractCollection<Integer>

rem

public boolean rem(Object o)
Delegates to the corresponding type-specific method.


contains

public boolean contains(Object o)
Delegates to the corresponding type-specific method.

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

contains

public boolean contains(int k)
Specified by:
contains in interface IntCollection
See Also:
Collection.contains(Object)

rem

public boolean rem(int k)
Description copied from interface: IntCollection
Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name. For simplicity, the set interfaces reinstates remove().

Specified by:
rem in interface IntCollection
See Also:
Collection.remove(Object)

containsAll

public boolean containsAll(Collection<?> c)
Checks whether this collection contains all elements from the given collection.

Specified by:
containsAll in interface Collection<Integer>
Overrides:
containsAll in class AbstractCollection<Integer>
Parameters:
c - a collection.
Returns:
true if this collection contains all elements of the argument.

retainAll

public boolean retainAll(Collection<?> c)
Retains in this collection only elements from the given collection.

Specified by:
retainAll in interface Collection<Integer>
Overrides:
retainAll in class AbstractCollection<Integer>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

removeAll

public boolean removeAll(Collection<?> c)
Remove from this collection all elements in the given collection. If the collection is an instance of this class, it uses faster iterators.

Specified by:
removeAll in interface Collection<Integer>
Overrides:
removeAll in class AbstractCollection<Integer>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<Integer>
Overrides:
isEmpty in class AbstractCollection<Integer>

toString

public String toString()
Overrides:
toString in class AbstractCollection<Integer>