/* (non-Javadoc)
@see cyclops2.monads.transformers.values.ListT#cycleUntil(java.util.function.Predicate)
766023
@Override
    public ListT<W,T> cycleUntil(final Predicate<? super T> predicate) {

        return (ListT<W,T>) FoldableTransformerSeq.super.cycleUntil(predicate);
    }
185020
public static <T, IV> int detectIndexWith(
            T[] objectArray,
            Predicate2<? super T, IV> predicate,
            IV injectedValue)
    {
        if (objectArray == null)
        {
            throw new IllegalArgumentException("Cannot perform a detectIndexWith on null");
        }
        for (int i = 0; i < objectArray.length; i++)
        {
            if (predicate.accept(objectArray[i], injectedValue))
            {
                return i;
            }
        }
        return -1;
    }
504416
public static <E> List<E> filter(final Iterable<E> iterable, final Predicate<E> pred) {
        final List<E> filtered = newArrayList();
        for (E element : iterable) {
            if (pred.test(element)) {
                filtered.add(element);
            }
        }
        return filtered;
    }
983169
@SuppressWarnings("unchecked")
    public static <T> ReactiveSeq<T> takeUntil(final Stream<T> stream, final Predicate<? super T> predicate) {
        final Iterator<T> it = stream.iterator();

        class LimitUntil implements Iterator<T> {
            T next = (T) NULL;
            boolean test = false;

            void test() {
                if (!test && next == NULL && it.hasNext()) {
                    next = it.next();

                    if (test = predicate.test(next)) {
                        next = (T) NULL;
                        close(it); // need to close any open queues
                    }
                }
            }

            @Override
            public boolean hasNext() {
                test();
                return next != NULL;
            }

            @Override
            public T next() {
                if (next == NULL)
                    throw new NoSuchElementException();

                try {
                    return next;
                } finally {
                    next = (T) NULL;
                }
            }
        }

        return ReactiveSeq.fromIterator(new LimitUntil())
                  .onClose(() -> {
                      stream.close();
                  });
    }
244933
public static <T> List<T> filter( Iterable<T> collection, Predicate<T> predicate)
    {
        List<T> filtered = new ArrayList<T>();
        for (T element : collection)
        {
        	if (predicate.isVerifiedBy(element))
        	{
        		filtered.add(element);
        	}
        }
        return filtered;
    }
5651
function shouldCallLifecycleInitHook(view, initState, index) {
    if ((view.state & 1792 /* InitState_Mask */) === initState && view.initIndex <= index) {
        view.initIndex = index + 1;
        return true;
    }
    return false;
}
1337641
public boolean walkUntil(Predicate<StringWalker> predicate)
	{
		if (predicate.test(this))
			return true;
		while (nextCharacter())
			if (predicate.test(this))
				return true;
		return false;
	}
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");
    }
983549
final void addAll(final Iterable<Cycle> cycles) {
        for (final Cycle cycle : cycles)
            add(cycle);
    }

    /**
     * Check if all the edges of the <i>cycle</i> are present in the current
     * <i>basis</i>.
     *
     * @param cycle an initial cycle
     * @return any edges of the basis are present
     */
    final boolean isSubsetOfBasis(final Cycle cycle) {
        final BitSet edgeVector = cycle.edgeVector();
        final int intersect = and(edgesOfBasis, edgeVector).cardinality();
        return intersect == cycle.length();
    }

    /**
     * Determine whether the <i>candidate</i> cycle is linearly
     * <i>independent</i> from the current basis.
     *
     * @param candidate a cycle not in currently in the basis
     * @return the candidate is independent
     */
    final boolean isIndependent(final Cycle candidate) {

        // simple checks for independence
        if (basis.isEmpty() || !isSubsetOfBasis(candidate)) return true;

        final BitMatrix matrix = BitMatrix.from(basis, candidate);

        // perform gaussian elimination
        matrix.eliminate();

        // if the last row (candidate) was eliminated it is not independent
        return !matrix.eliminated(basis.size());
    }

    /** and <i>s</i> and <i>t</i> without modifying <i>s</i> */
    private static final BitSet and(final BitSet s, final BitSet t) {
        final BitSet u = (BitSet) s.clone();
        u.and(t);
        return u;
    }
}
450573
public static <T> Predicate<T> predicate(CheckedPredicate<T> predicate) {
        return Unchecked.predicate(predicate, Unchecked.RETHROW_ALL);
    }
1162810
@SuppressWarnings("unchecked")
    public Set<QueryableEntry> query(Predicate predicate) {
        stats.incrementQueryCount();

        if (!haveAtLeastOneIndex() || !(predicate instanceof IndexAwarePredicate)) {
            return null;
        }

        IndexAwarePredicate indexAwarePredicate = (IndexAwarePredicate) predicate;
        QueryContext queryContext = queryContextProvider.obtainContextFor(this);
        if (!indexAwarePredicate.isIndexed(queryContext)) {
            return null;
        }

        Set<QueryableEntry> result = indexAwarePredicate.filter(queryContext);
        if (result != null) {
            stats.incrementIndexedQueryCount();
            queryContext.applyPerQueryStats();
        }

        return result;
    }
557430
public static void visitPreOrder(
      Node node, Visitor visitor, Predicate<Node> traverseChildrenPred) {
    visitor.visit(node);

    if (traverseChildrenPred.apply(node)) {
      for (Node c = node.getFirstChild(); c != null; c = c.getNext()) {
        visitPreOrder(c, visitor, traverseChildrenPred);
      }
    }
  }
468113
static List<Dependency> rootCycleAt(List<Dependency> cycle, Key<?> key) {
    for (int i = 0; i < cycle.size(); ++i) {
      if (key.equals(cycle.get(i).getSource())) {
        List<Dependency> returnValue = new ArrayList<Dependency>();
        returnValue.addAll(cycle.subList(i, cycle.size()));
        returnValue.addAll(cycle.subList(0, i));
        return returnValue;
      }
    }

    return cycle;
  }
93529
public void preInvoke( InterceptorContext context, InterceptorChain chain ) throws InterceptorException
    {
        preRequest( ( RequestInterceptorContext ) context, chain );
    }
1168972
@SuppressWarnings("unchecked")
  public S handleIf(BiPredicate<R, ? extends Throwable> resultPredicate) {
    Assert.notNull(resultPredicate, "resultPredicate");
    failuresChecked = true;
    failureConditions.add((BiPredicate<R, Throwable>) resultPredicate);
    return (S) this;
  }
1127636
@Override
    public ListT<W,T> dropUntil(final Predicate<? super T> p) {

        return (ListT<W,T>) FoldableTransformerSeq.super.dropUntil(p);
    }
269669
@Override
    public <R> ListT<W,R> unitIterable(final Iterable<R> it) {
        return of(run.unitIterable(it)
                     .map(i -> ListX.of(i)));
    }