Searches for the first occurrence where the predicate evaluates to true, returns -1 if the predicate does not evaluate to true.
976483
public static <T> int detectIndex(Iterable<T> iterable, Predicate<? super T> predicate)
    {
        if (iterable instanceof ArrayList<?>)
        {
            return ArrayListIterate.detectIndex((ArrayList<T>) iterable, predicate);
        }
        if (iterable instanceof List<?>)
        {
            return ListIterate.detectIndex((List<T>) iterable, predicate);
        }
        if (iterable != null)
        {
            return IterableIterate.detectIndex(iterable, predicate);
        }
        throw new IllegalArgumentException("Cannot perform detectIndex on null");
    }
85633
def is_first(self, value):
        
        if value == self._defaults['ai.session.isFirst'] and 'ai.session.isFirst' in self._values:
            del self._values['ai.session.isFirst']
        else:
            self._values['ai.session.isFirst'] = value
1351138
def search_greater(values, target):
    
    first = 0
    last = len(values)

    while first < last:
        middle = (first + last) // 2
        if values[middle][0] < target:
            first = middle + 1
        else:
            last = middle

    return first
72471
private static int search(
        long utcDays,
        long[] firstOfMonth
    ) {

        int low = 0;
        int high = firstOfMonth.length - 1;

        while (low <= high) {
            int middle = (low + high) / 2;

            if (firstOfMonth[middle] <= utcDays) {
                low = middle + 1;
            } else {
                high = middle - 1;
            }
        }

        return low - 1;

    }
1087140
private int findValue(String s) {

        for (int i = 0; i < values.size(); i++) {
            if (s.equals(values.elementAt(i))) {
                return i;
            }    // end of if (s.equals(values.elementAt(i)))
        }        // end of for (int i=0; i<values.size(); i++)

        return -1;
    }
707170
public boolean is(MatrixPredicate predicate) {
        MatrixIterator it = iterator();
        boolean result = predicate.test(rows, columns);

        while (it.hasNext() && result) {
            double x = it.next();
            int i = it.rowIndex();
            int j = it.columnIndex();
            result = predicate.test(i, j, x);
        }

        return result;
    }
901700
boolean contains(AccessOrder<?> e) {
    return (e.getPreviousInAccessOrder() != null)
        || (e.getNextInAccessOrder() != null)
        || (e == first);
  }
146320
public boolean containsNone(int start, int end) {
        if (start < MIN_VALUE || start > MAX_VALUE) {
            throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
        }
        if (end < MIN_VALUE || end > MAX_VALUE) {
            throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(end, 6));
        }
        int i = -1;
        while (true) {
            if (start < list[++i]) break;
        }
        return ((i & 1) == 0 && end < list[i]);
    }
801269
def find_first_match(basedir, string):
    
    matches = find(basedir, string)
    return matches[0] if matches else matches
843024
def __findFirstMissing(self, array, start, end):
        
        if (start > end):
            return end + 1

        if (start != array[start]):
            return start

        mid = int((start + end) / 2)

        if (array[mid] == mid):
            return self.__findFirstMissing(array, mid + 1, end)

        return self.__findFirstMissing(array, start, mid)
920282
private int search(int startLine, boolean backward) throws IOException {
        search = search.toLowerCase();
        try (Stream<String> stream = Files.lines(path)) {
            if (backward) {
                int idx = -1;
                if (startLine > 0)
                    idx = searchTo(startLine - 1, true);
                if (idx < 0)
                    idx = searchFrom(startLine, true);
                return idx;
            }
            else {
                int idx = searchFrom(startLine);
                if (idx < 0) {
                    // wrap search
                    idx = searchTo(startLine - 1);
                }
                return idx;
            }
        }
        catch (UncheckedIOException ex) {
            throw ex.getCause();
        }
    }
888064
function find (c, predicate) {
        for (var i = 0; i < c.length; i++) {
            if (predicate(c[i]))
                return c[i];
        }
        return null;
    }
1158150
def first_true(iterable, func):
    # type: (Iterable[T], Callable) -> T
    "
    try:
        return next((x for x in iterable if func(x)))
    except StopIteration as e:
        # TODO: Find a better error message
        raise_from(IndexError('No match for %s' % func), e)
348048
def find_start_of_previous_word(self, count=1, WORD=False):
        
        # Reverse the text before the cursor, in order to do an efficient
        # backwards search.
        text_before_cursor = self.text_before_cursor[::-1]

        regex = _FIND_BIG_WORD_RE if WORD else _FIND_WORD_RE
        iterator = regex.finditer(text_before_cursor)

        try:
            for i, match in enumerate(iterator):
                if i + 1 == count:
                    return - match.end(1)
        except StopIteration:
            pass
884510
function findPrevNode(firstNode, item, comparer) {
    let ret;
    let prevNode = firstNode;
    // while item > prevNode.value
    while (prevNode != undefined && comparer(prevNode.value, item) > 0) {
        ret = prevNode;
        prevNode = prevNode.next;
    }
    return ret;
}
191709
private static int checkWildCard(final SearchableString value, final Literal suffix, final int start) {
        for (final int index : value.getIndices(suffix)) {
            if (index >= start) {
                return index;
            }
        }
        return -1;
    }
93872
@Override
  public int compareTo(RepairDigramRecord o) {
    if (this.freq > o.freq) {
      return 1;
    }
    else if (this.freq < o.freq) {
      return -1;
    }
    return 0;
  }