本文整理汇总了Java中com.carrotsearch.hppc.predicates.ObjectPredicate类的典型用法代码示例。如果您正苦于以下问题:Java ObjectPredicate类的具体用法?Java ObjectPredicate怎么用?Java ObjectPredicate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectPredicate类属于com.carrotsearch.hppc.predicates包,在下文中一共展示了ObjectPredicate类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMatch
import com.carrotsearch.hppc.predicates.ObjectPredicate; //导入依赖的package包/类
/**
* Search for a match in a list of blocks.
* @param blocks the blocks to search in
* @param checksum the weak rolling checksum to search
* @param data the data being searched for (in case a hash needs to be generated)
* @return the index of the matching block, or {@code -1}
*/
private static int findMatch(final ObjectArrayList<Block> blocks, final long checksum, final byte[] data)
{
//CHECKSTYLE.OFF: VisibilityModifier - using getters for the anonymous class is kind of pointless
// use a predicate so we can stop iterating once a match is found
return blocks.forEach(new ObjectPredicate<Block>() {
int match = -1;
int index;
byte[] dataHash;
@Override
public boolean apply(final Block value)
{
if(value.getChecksum() == checksum)
{
// calculate the hash of the input data lazily
if(dataHash == null)
{
dataHash = Hashing.md5().hashBytes(data).asBytes();
}
if(Arrays.equals(dataHash, value.getHash()))
{
match = index;
return false;
}
}
index++;
return true;
}
}).match;
//CHECKSTYLE.ON: VisibilityModifier
}
示例2: removeAll
import com.carrotsearch.hppc.predicates.ObjectPredicate; //导入依赖的package包/类
@Override
public int removeAll(ObjectPredicate<? super KType> predicate) {
return map.removeAll(predicate);
}