本文整理汇总了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);
}
示例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);
}
};
}
};
}
示例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();
}
示例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;
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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("-- ");
}
}
示例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;
}
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}