Package jetbrains.mps.util
Class IterableUtil
- java.lang.Object
 - 
- jetbrains.mps.util.IterableUtil
 
 
- 
public class IterableUtil extends Object
 
- 
- 
Constructor Summary
Constructors Constructor Description IterableUtil() 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Collection<T>asCollection(Iterable<? extends T> iter)FIXME: conversion of wildcard type to its upper bound breaks container's contract SeeIterableUtil.asSet()static <T> Iterable<T>asIterable(Iterator<T> it)FIXME: as there is no way to reset the iterator, the returned Iterable can only be iterated oncestatic <T> List<T>asList(Iterable<? extends T> iter)FIXME: conversion of wildcard type to its upper bound breaks container's contract SeeIterableUtil.asSet()static <T> Set<T>asSet(Iterable<? extends T> iter)FIXME: conversion of wildcard type to its upper bound breaks container's contract Example:static <T> List<T>copyToList(Iterable<? extends T> iter)static <T> Iterable<T>distinct(Iterable<T> t)static <T> Tget(Iterable<? extends T> data, int index)static <T> intindexOf(Iterable<? extends T> data, T element)static <T> Iterable<T>merge(Iterable<T>... its) 
 - 
 
- 
- 
Method Detail
- 
asSet
@NotNull public static <T> Set<T> asSet(@Nullable Iterable<? extends T> iter)
FIXME: conversion of wildcard type to its upper bound breaks container's contract Example:class A {}; class B extends A {}
Set sob = new HashSet();
Iterable<? extends A> ioa = sob;
Set soa = IterableUtil.asSet(ioa); soa.add(new A());
B b = sob.iterator().next(); // ClassCastException
 
- 
asCollection
@NotNull public static <T> Collection<T> asCollection(@Nullable Iterable<? extends T> iter)
FIXME: conversion of wildcard type to its upper bound breaks container's contract SeeIterableUtil.asSet() 
- 
asList
@NotNull public static <T> List<T> asList(@Nullable Iterable<? extends T> iter)
FIXME: conversion of wildcard type to its upper bound breaks container's contract SeeIterableUtil.asSet() 
- 
asIterable
@NotNull public static <T> Iterable<T> asIterable(@Nullable Iterator<T> it)
FIXME: as there is no way to reset the iterator, the returned Iterable can only be iterated once 
- 
indexOf
public static <T> int indexOf(Iterable<? extends T> data, T element)
 
 - 
 
 -