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 anIteratorto 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 booleanadd(T arg0)booleanaddAll(Collection<? extends T> arg0)voidclear()booleancontains(Object arg0)booleancontainsAll(Collection<?> arg0)booleanequals(Object o)protected abstract Collection<T>getDelegate()inthashCode()booleanisEmpty()Iterator<T>iterator()booleanremove(Object arg0)booleanremoveAll(Collection<?> arg0)booleanretainAll(Collection<?> arg0)intsize()Object[]toArray()<U> U[]toArray(U[] a)static <T> Iterator2List<T>toList(Iterator<? extends T> i)Returns aListcontaining all elements in i, preserving duplicates.static <T> Iterator2Set<T>toSet(Iterator<? extends T> i)Returns aSetcontaining all elements in i.StringtoString()-
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 aSetcontaining 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 aListcontaining all elements in i, preserving duplicates.- Throws:
IllegalArgumentException
-
size
public int size()
- Specified by:
sizein interfaceCollection<T>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T>
-
add
public boolean add(T arg0)
- Specified by:
addin interfaceCollection<T>
-
contains
public boolean contains(Object arg0)
- Specified by:
containsin interfaceCollection<T>
-
remove
public boolean remove(Object arg0)
- Specified by:
removein interfaceCollection<T>
-
addAll
public boolean addAll(Collection<? extends T> arg0)
- Specified by:
addAllin interfaceCollection<T>
-
containsAll
public boolean containsAll(Collection<?> arg0)
- Specified by:
containsAllin interfaceCollection<T>
-
removeAll
public boolean removeAll(Collection<?> arg0)
- Specified by:
removeAllin interfaceCollection<T>
-
retainAll
public boolean retainAll(Collection<?> arg0)
- Specified by:
retainAllin interfaceCollection<T>
-
toArray
public <U> U[] toArray(U[] a)
- Specified by:
toArrayin interfaceCollection<T>
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<T>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<T>- Overrides:
hashCodein classObject
-
-