Package com.ibm.wala.util.collections
Class Iterator2Collection<T>
- java.lang.Object
-
- com.ibm.wala.util.collections.Iterator2Collection<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
- Direct Known Subclasses:
Iterator2List
,Iterator2Set
public abstract class Iterator2Collection<T> extends java.lang.Object implements java.util.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(java.util.Collection<? extends T> arg0)
void
clear()
boolean
contains(java.lang.Object arg0)
boolean
containsAll(java.util.Collection<?> arg0)
boolean
equals(java.lang.Object o)
protected abstract java.util.Collection<T>
getDelegate()
int
hashCode()
boolean
isEmpty()
java.util.Iterator<T>
iterator()
boolean
remove(java.lang.Object arg0)
boolean
removeAll(java.util.Collection<?> arg0)
boolean
retainAll(java.util.Collection<?> arg0)
int
size()
java.lang.Object[]
toArray()
<U> U[]
toArray(U[] a)
static <T> Iterator2List<T>
toList(java.util.Iterator<? extends T> i)
Returns aList
containing all elements in i, preserving duplicates.static <T> Iterator2Set<T>
toSet(java.util.Iterator<? extends T> i)
Returns aSet
containing all elements in i.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
getDelegate
protected abstract java.util.Collection<T> getDelegate()
-
toSet
public static <T> Iterator2Set<T> toSet(java.util.Iterator<? extends T> i) throws java.lang.IllegalArgumentException
Returns aSet
containing all elements in i. Note that duplicates will be removed.- Throws:
java.lang.IllegalArgumentException
-
toList
public static <T> Iterator2List<T> toList(java.util.Iterator<? extends T> i) throws java.lang.IllegalArgumentException
Returns aList
containing all elements in i, preserving duplicates.- Throws:
java.lang.IllegalArgumentException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<T>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection<T>
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interfacejava.util.Collection<T>
-
contains
public boolean contains(java.lang.Object arg0)
- Specified by:
contains
in interfacejava.util.Collection<T>
-
remove
public boolean remove(java.lang.Object arg0)
- Specified by:
remove
in interfacejava.util.Collection<T>
-
addAll
public boolean addAll(java.util.Collection<? extends T> arg0)
- Specified by:
addAll
in interfacejava.util.Collection<T>
-
containsAll
public boolean containsAll(java.util.Collection<?> arg0)
- Specified by:
containsAll
in interfacejava.util.Collection<T>
-
removeAll
public boolean removeAll(java.util.Collection<?> arg0)
- Specified by:
removeAll
in interfacejava.util.Collection<T>
-
retainAll
public boolean retainAll(java.util.Collection<?> arg0)
- Specified by:
retainAll
in interfacejava.util.Collection<T>
-
iterator
public java.util.Iterator<T> iterator()
-
toArray
public <U> U[] toArray(U[] a)
- Specified by:
toArray
in interfacejava.util.Collection<T>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Collection<T>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<T>
- Overrides:
hashCode
in classjava.lang.Object
-
-