List of usage examples for com.google.common.collect Iterators indexOf
public static <T> int indexOf(Iterator<T> iterator, Predicate<? super T> predicate)
From source file:com.mattc.launcher.util.Utility.java
/** * Get Index of an Object in a Collection. * /*from ww w. j a v a2 s. c om*/ * @param list * @param item * @return */ public static int getIndexOf(Collection<?> list, Object item) { final Iterator<?> iter = list.iterator(); return Iterators.indexOf(iter, Predicates.equalTo(item)); }
From source file:de.johni0702.sponge.noteblockapi.song.Instrument.java
/** * Converts the specified note pitch to a sound effect pitch. * @param registry The game registry//w w w . j a v a 2s . co m * @param pitch The note * @return The sound effect pitch in range [0, 2] */ public float getPitch(GameRegistry registry, NotePitch pitch) { Iterator<? extends NotePitch> iter = registry.getAllOf(NotePitch.class).iterator(); return PITCH[Iterators.indexOf(iter, Predicates.equalTo(pitch))]; }