Class IntCollections.SynchronizedCollection
- java.lang.Object
-
- it.unimi.dsi.fastutil.ints.IntCollections.SynchronizedCollection
-
- All Implemented Interfaces:
IntCollection
,IntIterable
,Serializable
,Iterable<Integer>
,Collection<Integer>
- Direct Known Subclasses:
IntBigLists.SynchronizedBigList
,IntLists.SynchronizedList
,IntSets.SynchronizedSet
- Enclosing class:
- IntCollections
public static class IntCollections.SynchronizedCollection extends Object implements IntCollection, Serializable
A synchronized wrapper class for collections.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(int k)
Ensures that this collection contains the specified element (optional operation).boolean
add(Integer k)
Deprecated.boolean
addAll(IntCollection c)
Adds all elements of the given type-specific collection to this collection.boolean
addAll(Collection<? extends Integer> c)
void
clear()
boolean
contains(int k)
Returnstrue
if this collection contains the specified element.boolean
contains(Object k)
Deprecated.boolean
containsAll(IntCollection c)
Checks whether this collection contains all elements from the given type-specific collection.boolean
containsAll(Collection<?> c)
boolean
equals(Object o)
int
hashCode()
boolean
isEmpty()
IntIterator
iterator()
Returns a type-specific iterator on the elements of this collection.boolean
rem(int k)
Removes a single instance of the specified element from this collection, if it is present (optional operation).boolean
remove(Object k)
Deprecated.boolean
removeAll(IntCollection c)
Remove from this collection all elements in the given type-specific collection.boolean
removeAll(Collection<?> c)
boolean
removeIf(IntPredicate filter)
Remove from this collection all elements which satisfy the given predicate.boolean
retainAll(IntCollection c)
Retains in this collection only elements from the given type-specific collection.boolean
retainAll(Collection<?> c)
int
size()
Object[]
toArray()
int[]
toArray(int[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.<T> T[]
toArray(T[] a)
int[]
toIntArray()
Returns a primitive type array containing the items of this collection.int[]
toIntArray(int[] a)
Deprecated.String
toString()
-
Methods inherited from interface java.util.Collection
parallelStream, spliterator, stream, toArray
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntCollection
removeIf
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterable
forEach, forEach
-
-
-
-
Method Detail
-
add
public boolean add(int k)
Description copied from interface:IntCollection
Ensures that this collection contains the specified element (optional operation).- Specified by:
add
in interfaceIntCollection
- See Also:
Collection.add(Object)
-
contains
public boolean contains(int k)
Description copied from interface:IntCollection
Returnstrue
if this collection contains the specified element.- Specified by:
contains
in interfaceIntCollection
- See Also:
Collection.contains(Object)
-
rem
public boolean rem(int k)
Description copied from interface:IntCollection
Removes a single instance of the specified element from this collection, if it is present (optional operation).Note that this method should be called
remove()
, but the clash with the similarly named index-based method in theList
interface forces us to use a distinguished name. For simplicity, the set interfaces reinstatesremove()
.- Specified by:
rem
in interfaceIntCollection
- See Also:
Collection.remove(Object)
-
size
public int size()
- Specified by:
size
in interfaceCollection<Integer>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Integer>
-
toIntArray
public int[] toIntArray()
Description copied from interface:IntCollection
Returns a primitive type array containing the items of this collection.- Specified by:
toIntArray
in interfaceIntCollection
- Returns:
- a primitive type array containing the items of this collection.
- See Also:
Collection.toArray()
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<Integer>
-
toIntArray
@Deprecated public int[] toIntArray(int[] a)
Deprecated.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 interfaceIntCollection
- 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[])
-
toArray
public int[] toArray(int[] a)
Description copied from interface:IntCollection
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.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 interfaceIntCollection
- 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)
Description copied from interface:IntCollection
Adds all elements of the given type-specific collection to this collection.- Specified by:
addAll
in interfaceIntCollection
- 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)
Description copied from interface:IntCollection
Checks whether this collection contains all elements from the given type-specific collection.- Specified by:
containsAll
in interfaceIntCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection contains all elements of the argument.- See Also:
Collection.containsAll(Collection)
-
removeAll
public boolean removeAll(IntCollection c)
Description copied from interface:IntCollection
Remove from this collection all elements in the given type-specific collection.- Specified by:
removeAll
in interfaceIntCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection changed as a result of the call.- See Also:
Collection.removeAll(Collection)
-
removeIf
public boolean removeIf(IntPredicate filter)
Description copied from interface:IntCollection
Remove from this collection all elements which satisfy the given predicate.- Specified by:
removeIf
in interfaceIntCollection
- Parameters:
filter
- a predicate which returnstrue
for elements to be removed.- Returns:
true
if any elements were removed.- See Also:
Collection.removeIf(java.util.function.Predicate)
-
retainAll
public boolean retainAll(IntCollection c)
Description copied from interface:IntCollection
Retains in this collection only elements from the given type-specific collection.- Specified by:
retainAll
in interfaceIntCollection
- Parameters:
c
- a type-specific collection.- Returns:
true
if this collection changed as a result of the call.- See Also:
Collection.retainAll(Collection)
-
add
@Deprecated public boolean add(Integer k)
Deprecated.Description copied from interface:IntCollection
- Specified by:
add
in interfaceCollection<Integer>
- Specified by:
add
in interfaceIntCollection
-
contains
@Deprecated public boolean contains(Object k)
Deprecated.Description copied from interface:IntCollection
- Specified by:
contains
in interfaceCollection<Integer>
- Specified by:
contains
in interfaceIntCollection
-
remove
@Deprecated public boolean remove(Object k)
Deprecated.Description copied from interface:IntCollection
- Specified by:
remove
in interfaceCollection<Integer>
- Specified by:
remove
in interfaceIntCollection
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<Integer>
-
iterator
public 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 extendsCollection
.- Specified by:
iterator
in interfaceCollection<Integer>
- Specified by:
iterator
in interfaceIntCollection
- Specified by:
iterator
in interfaceIntIterable
- Specified by:
iterator
in interfaceIterable<Integer>
- Returns:
- a type-specific iterator on the elements of this collection.
- See Also:
Iterable.iterator()
-
addAll
public boolean addAll(Collection<? extends Integer> c)
- Specified by:
addAll
in interfaceCollection<Integer>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<Integer>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<Integer>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<Integer>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<Integer>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<Integer>
- Overrides:
hashCode
in classObject
-
-