Class Iterator2Collection<T>
java.lang.Object
com.ibm.wala.util.collections.Iterator2Collection<T>
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
- Direct Known Subclasses:
Iterator2List
,Iterator2Set
Converts an
Iterator
to a Collection
. Note that if you just want to use Java 5's
for-each loop with an Iterator
, use Iterator2Iterable
.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> arg0) void
clear()
boolean
boolean
containsAll
(Collection<?> arg0) boolean
protected abstract Collection
<T> int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> arg0) boolean
retainAll
(Collection<?> arg0) int
size()
Object[]
toArray()
<U> U[]
toArray
(U[] a) static <T> Iterator2List
<T> Returns aList
containing all elements in i, preserving duplicates.static <T> Iterator2Set
<T> Returns aSet
containing all elements in i.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, spliterator, stream, toArray
-
Constructor Details
-
Iterator2Collection
public Iterator2Collection()
-
-
Method Details
-
getDelegate
-
toSet
Returns aSet
containing all elements in i. Note that duplicates will be removed.- Throws:
IllegalArgumentException
-
toList
Returns aList
containing all elements in i, preserving duplicates.- Throws:
IllegalArgumentException
-
toString
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T>
-
toArray
- Specified by:
toArray
in interfaceCollection<T>
-
add
- Specified by:
add
in interfaceCollection<T>
-
contains
- Specified by:
contains
in interfaceCollection<T>
-
remove
- Specified by:
remove
in interfaceCollection<T>
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
-
iterator
-
toArray
public <U> U[] toArray(U[] a) - Specified by:
toArray
in interfaceCollection<T>
-
equals
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<T>
- Overrides:
hashCode
in classObject
-