当前位置: 首页>>代码示例>>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;未经允许,请勿转载。