Java Code Examples for it.unimi.dsi.fastutil.ints.IntCollection#size()

The following examples show how to use it.unimi.dsi.fastutil.ints.IntCollection#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FastCollectionsUtils.java    From fastjgame with Apache License 2.0 6 votes vote down vote up
/**
 * 移除map中符合条件的元素,并对删除的元素执行后续的操作。
 *
 * @param collection 必须是可修改的集合
 * @param predicate  过滤条件,为真的删除
 * @param then       元素删除之后执行的逻辑
 * @return 删除的元素数量
 */
public static int removeIfAndThen(IntCollection collection, IntPredicate predicate, IntConsumer then) {
    if (collection.size() == 0) {
        return 0;
    }
    final IntIterator itr = collection.iterator();
    int value;
    int removeNum = 0;
    while (itr.hasNext()) {
        value = itr.nextInt();
        if (predicate.test(value)) {
            itr.remove();
            removeNum++;
            then.accept(value);
        }
    }
    return removeNum;
}
 
Example 2
Source File: SingleValidationTask.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private Iterable<int[]> getRecords(IntCollection leftMatches) {
	int size = leftMatches.size();
	Collection<int[]> left = new ArrayList<>(size);
	OfInt it = leftMatches.iterator();
	while (it.hasNext()) {
		int leftId = it.nextInt();
		int[] record = leftRecords.get(leftId);
		left.add(record);
	}
	return left;
}
 
Example 3
Source File: SingleValidationTask.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private long validate(IntCollection leftMatches, IntCollection rightMatches) {
	log.trace("Validating {} left matches with {} right matches", Integer.valueOf(leftMatches.size()),
		Integer.valueOf(rightMatches.size()));
	Iterable<int[]> left = getRecords(leftMatches);
	rhs.forEach(rhsTask -> rhsTask.validate(left, rightMatches));
	return (long) leftMatches.size() * rightMatches.size();
}
 
Example 4
Source File: ArbitraryValidationTask.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Timed
	private long validate(Selector selector, Collection<int[]> left) {
		IntCollection rightMatches = intersector.findLhsMatches(selector);
//		log.trace("Validating {} left matches with {} right matches", left.size(),
//			rightMatches.size());
		rhs.forEach(rhsTask -> rhsTask.validate(left, rightMatches));
		return (long) left.size() * rightMatches.size();
	}
 
Example 5
Source File: RecordSelector.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
Iterable<int[]> getRecords(IntCollection ids) {
	int size = ids.size();
	Collection<int[]> result = new ArrayList<>(size);
	OfInt it = ids.iterator();
	while (it.hasNext()) {
		int id = it.nextInt();
		int[] record = records.get(id);
		result.add(record);
	}
	return result;
}