當前位置: 首頁>>代碼示例>>Java>>正文


Java IntPredicate.test方法代碼示例

本文整理匯總了Java中java.util.function.IntPredicate.test方法的典型用法代碼示例。如果您正苦於以下問題:Java IntPredicate.test方法的具體用法?Java IntPredicate.test怎麽用?Java IntPredicate.test使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.function.IntPredicate的用法示例。


在下文中一共展示了IntPredicate.test方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeInt

import java.util.function.IntPredicate; //導入方法依賴的package包/類
/**
 * Constructs a quantified predicate matcher for an {@code IntStream}.
 *
 * @param predicate the {@code Predicate} to apply to stream elements
 * @param matchKind the kind of quantified match (all, any, none)
 * @return a {@code TerminalOp} implementing the desired quantified match
 *         criteria
 */
public static TerminalOp<Integer, Boolean> makeInt(IntPredicate predicate,
                                                   MatchKind matchKind) {
    Objects.requireNonNull(predicate);
    Objects.requireNonNull(matchKind);
    class MatchSink extends BooleanTerminalSink<Integer> implements Sink.OfInt {
        MatchSink() {
            super(matchKind);
        }

        @Override
        public void accept(int t) {
            if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
                stop = true;
                value = matchKind.shortCircuitResult;
            }
        }
    }

    return new MatchOp<>(StreamShape.INT_VALUE, matchKind, MatchSink::new);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:MatchOps.java

示例2: filter

import java.util.function.IntPredicate; //導入方法依賴的package包/類
@Override
public final IntStream filter(IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return new StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                    StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
            return new Sink.ChainedInt<Integer>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(int t) {
                    if (predicate.test(t))
                        downstream.accept(t);
                }
            };
        }
    };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:IntPipeline.java

示例3: estimateSize

import java.util.function.IntPredicate; //導入方法依賴的package包/類
/**
 * Estimates the size of a filter applied to an IMembershipSet
 * @return an approximation of the size based on sampling. May return 0.
 * There are no strict guarantees on the quality of the approximation,
 * but is good enough for initialization of a hash table sizes.
 */
public static int estimateSize(final IMembershipSet baseMap,
                               final IntPredicate filter) {
    final IMembershipSet sampleSet = baseMap.sample(sizeEstimationSampleSize, 0);
    if (sampleSet.getSize() == 0)
        return 0;
    int eSize = 0;
    final IRowIterator iter = sampleSet.getIterator();
    int curr = iter.getNextRow();
    while (curr >= 0) {
        if (filter.test(curr))
            eSize++;
        curr = iter.getNextRow();
    }
    return (baseMap.getSize() * eSize) / sampleSet.getSize();
}
 
開發者ID:vmware,項目名稱:hillview,代碼行數:22,代碼來源:MembershipSetFactory.java

示例4: scanAllVersion

import java.util.function.IntPredicate; //導入方法依賴的package包/類
void scanAllVersion(IntPredicate predicate) {
    SkipListScanner scanner = this.slist.scan(0, true, 0, true);
    if (scanner == null) {
        return;
    }
    while (scanner.next()) {
        long pHead = scanner.getValuePointer();
        if (pHead == 0) {
            continue;
        }
        int oHead = Unsafe.getInt(pHead);
        if (oHead == 0) {
            continue;
        }
        for (ListNode i=ListNode.create(this.base, oHead); i!=null; i=i.getNextNode()) {
            boolean cont = predicate.test(i.getOffset());
            if (!cont) {
                return;
            }
        }
    }
}
 
開發者ID:waterguo,項目名稱:antsdb,代碼行數:23,代碼來源:MemTablet.java

示例5: checkAndSetOrder

import java.util.function.IntPredicate; //導入方法依賴的package包/類
private void checkAndSetOrder(IntPredicate expectedValue,
                              IntUnaryOperator newValue) {
    if (!expectedValue.test(invocationOrder)) {
        throw new TestSupport.AssertionFailedException(
                expectedValue + " -> " + newValue);
    }
    invocationOrder = newValue.applyAsInt(invocationOrder);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:ReaderTest.java

示例6: filterNumbersWithPredicate

import java.util.function.IntPredicate; //導入方法依賴的package包/類
public List<Integer> filterNumbersWithPredicate(final List<Integer> numbers,
    IntPredicate predicate) {
    List<Integer> filteredNumbers = new ArrayList<>();
    for (Integer number : numbers) {
        if (predicate.test(number)) {
            filteredNumbers.add(number);
        }
    }
    return filteredNumbers; 
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-with-JShell,代碼行數:11,代碼來源:example12_02.java

示例7: allMatch

import java.util.function.IntPredicate; //導入方法依賴的package包/類
public static boolean allMatch(final int[] array, final IntPredicate pred) {
    JointCallingUtils.nonNull(array, "array may not be null");
    JointCallingUtils.nonNull(pred, "predicate may not be null");
    for (final int x : array) {
        if (!pred.test(x)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:BGI-flexlab,項目名稱:SOAPgaea,代碼行數:11,代碼來源:GvcfMathUtils.java

示例8: filter

import java.util.function.IntPredicate; //導入方法依賴的package包/類
/**
 * Return a membership containing only the rows in the current one where
 * the predicate evaluates to true.
 * @param predicate  Predicate evaluated for each row.
 */
default IMembershipSet filter(IntPredicate predicate) {
    int estimatedSize = MembershipSetFactory.estimateSize(this, predicate);
    IMutableMembershipSet ms = MembershipSetFactory.create(this.getSize(), estimatedSize);

    IRowIterator baseIterator = this.getIterator();
    int tmp = baseIterator.getNextRow();
    while (tmp >= 0) {
        if (predicate.test(tmp))
            ms.add(tmp);
        tmp = baseIterator.getNextRow();
    }
    return ms.seal();
}
 
開發者ID:vmware,項目名稱:hillview,代碼行數:19,代碼來源:IMembershipSet.java

示例9: appendAsciiIndent

import java.util.function.IntPredicate; //導入方法依賴的package包/類
/**
 * Appends an ASCII indentation prefix to the supplied line.
 *
 * @param buffer
 *            the buffer to append to
 * @param depth
 *            the depth (distance from the root) of the node
 * @param childrenAtDepths
 *            a set indicating which ancestors have outstanding lineage
 * @param hasMoreSiblings
 *            flag indicating if this is the last sibling
 */
public static void appendAsciiIndent(StringBuilder buffer, int depth, IntPredicate childrenAtDepths, boolean hasMoreSiblings) {
    if (depth > 0) {
        for (int i = 0; i < depth - 1; ++i) {
            if (childrenAtDepths.test(i)) {
                buffer.append('|');
            } else {
                buffer.append(' ');
            }
            buffer.append("   ");
        }
        buffer.append(hasMoreSiblings ? '|' : '`').append("-- ");
    }
}
 
開發者ID:blackducksoftware,項目名稱:bdio,代碼行數:26,代碼來源:TreeFormat.java

示例10: getIntegerConstant

import java.util.function.IntPredicate; //導入方法依賴的package包/類
public static LogicalConstant getIntegerConstant(String string,
		IntPredicate filter) {
	if (NUMBER.matches(string) && filter.test(Integer.valueOf(string))) {
		return LogicalConstant.create(Integer.valueOf(string).toString(),
				LogicLanguageServices.getNumeralType(), true);
	} else {
		return null;
	}
}
 
開發者ID:clic-lab,項目名稱:amr,代碼行數:10,代碼來源:NumeralGenerator.java

示例11: scan

import java.util.function.IntPredicate; //導入方法依賴的package包/類
public static void scan(IntSupplier supplier, IntPredicate consumer) {
	for (;;) {
		int ch = get(supplier);
		if (ch < 0) {
			break;
		}
		if (!consumer.test(ch)) {
			break;
		}
	}
}
 
開發者ID:waterguo,項目名稱:antsdb,代碼行數:12,代碼來源:Utf8.java

示例12: retry

import java.util.function.IntPredicate; //導入方法依賴的package包/類
private boolean retry(IntPredicate job, int tries, int waitTime) {
	boolean retVal = false;
	for (int currentTry = 1; currentTry <= tries; currentTry++) {
		if (job.test(currentTry)) {
			retVal = true;
			break;
		}
		try { Thread.sleep(waitTime); } catch (InterruptedException ignore) {}
	}
	return retVal;
}
 
開發者ID:openanalytics,項目名稱:shinyproxy,代碼行數:12,代碼來源:DockerService.java

示例13: match

import java.util.function.IntPredicate; //導入方法依賴的package包/類
/**
 * Test that each char of specified string match for predicate. <p/>
 * Note that it method does not support unicode, because it usual applicable only for match letters that placed under 128 code.
 * @param str string
 * @param predicate char matcher
 * @return true if all chars match
 */
public static boolean match(String str, IntPredicate predicate) {
    final int len = str.length();
    if(len == 0) {
        return false;
    }
    for(int i = 0; i < len; i++) {
        if(!predicate.test(str.charAt(i))) {
            return false;
        }
    }
    return true;
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:20,代碼來源:StringUtils.java

示例14: allMatch

import java.util.function.IntPredicate; //導入方法依賴的package包/類
@Override
default boolean allMatch(@NonNull final IntPredicate predicate) {
  return predicate.test(this.x()) && predicate.test(this.y()) && predicate.test(this.z());
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:5,代碼來源:Vector3i.java

示例15: anyMatch

import java.util.function.IntPredicate; //導入方法依賴的package包/類
@Override
default boolean anyMatch(@NonNull final IntPredicate predicate) {
  return predicate.test(this.x()) || predicate.test(this.y()) || predicate.test(this.z());
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:5,代碼來源:Vector3i.java


注:本文中的java.util.function.IntPredicate.test方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。