本文整理匯總了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());
}