diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2018-10-29 20:07:42 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2018-10-29 20:07:42 -0400 |
| commit | 074393ed8abda6003f31b97496fa8195c4627753 (patch) | |
| tree | feca8ba07594c35df6ccfd260c2a107cec93ed79 /base/src/main/java/bjc/utils/funcutils/IteratorUtils.java | |
| parent | de3c396e8ebee90f584957725fa1757da4c6dda6 (diff) | |
More testing.
Add some more testing utilities
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/IteratorUtils.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/funcutils/IteratorUtils.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java b/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java new file mode 100644 index 0000000..55e5985 --- /dev/null +++ b/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java @@ -0,0 +1,33 @@ +package bjc.utils.funcutils; + +import java.util.Iterator; + +/** + * Utility methods for dealing with iterators. + * + * @author bjculkin + * + */ +public class IteratorUtils { + /** + * Convert an iterator to an iterable. + * + * @param itr + * The iterator to convert. + * @return An iterable that gives back that iterator. + */ + public static <E> Iterable<E> I(Iterator<E> itr) { + return () -> itr; + } + + /** + * Convert an iterable to an iterator. + * + * @param itr + * The iterable to convert. + * @return The iterator from that iterable + */ + public static <E> Iterator<E> I(Iterable<E> itr) { + return itr.iterator(); + } +} |
