Example usage for com.google.common.collect Iterators indexOf

List of usage examples for com.google.common.collect Iterators indexOf

Introduction

In this page you can find the example usage for com.google.common.collect Iterators indexOf.

Prototype

public static <T> int indexOf(Iterator<T> iterator, Predicate<? super T> predicate) 

Source Link

Document

Returns the index in iterator of the first element that satisfies the provided predicate , or -1 if the Iterator has no such elements.

Usage

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))];
}