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