Package com.ibm.wala.util.collections
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
public abstract class Iterator2Collection<T> extends Object implements Collection<T>
Converts anIterator
to aCollection
. Note that if you just want to use Java 5's for-each loop with anIterator
, useIterator2Iterable
.- See Also:
Iterator2Iterable
-
-
Constructor Summary
Constructors Constructor Description Iterator2Collection()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
add(T arg0)
boolean
addAll(Collection<? extends T> arg0)
void
clear()
boolean
contains(Object arg0)
boolean
containsAll(Collection<?> arg0)
boolean
equals(Object o)
protected abstract Collection<T>
getDelegate()
int
hashCode()
boolean
isEmpty()
Iterator<T>
iterator()
boolean
remove(Object arg0)
boolean
removeAll(Collection<?> arg0)
boolean
retainAll(Collection<?> arg0)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] a)
static <T> Iterator2List<T>
toList(Iterator<? extends T> i)
Returns aList
containing all elements in i, preserving duplicates.static <T> Iterator2Set<T>
toSet(Iterator<? extends T> i)
Returns aSet
containing all elements in i.String
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
-
-
-
-
Method Detail
-
getDelegate
protected abstract Collection<T> getDelegate()
-
toSet
public static <T> Iterator2Set<T> toSet(Iterator<? extends T> i) throws IllegalArgumentException
Returns aSet
containing all elements in i. Note that duplicates will be removed.- Throws:
IllegalArgumentException
-
toList
public static <T> Iterator2List<T> toList(Iterator<? extends T> i) throws IllegalArgumentException
Returns aList
containing all elements in i, preserving duplicates.- Throws:
IllegalArgumentException
-
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
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<T>
-
add
public boolean add(T arg0)
- Specified by:
add
in interfaceCollection<T>
-
contains
public boolean contains(Object arg0)
- Specified by:
contains
in interfaceCollection<T>
-
remove
public boolean remove(Object arg0)
- Specified by:
remove
in interfaceCollection<T>
-
addAll
public boolean addAll(Collection<? extends T> arg0)
- Specified by:
addAll
in interfaceCollection<T>
-
containsAll
public boolean containsAll(Collection<?> arg0)
- Specified by:
containsAll
in interfaceCollection<T>
-
removeAll
public boolean removeAll(Collection<?> arg0)
- Specified by:
removeAll
in interfaceCollection<T>
-
retainAll
public boolean retainAll(Collection<?> arg0)
- Specified by:
retainAll
in interfaceCollection<T>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<T>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<T>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<T>
- Overrides:
hashCode
in classObject
-
-