Java Code Examples for gnu.trove.set.TLongSet#size()

The following examples show how to use gnu.trove.set.TLongSet#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: FallingBlocksMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Return the number of unsupported blocks connected to any blocks neighboring the given location,
 * which is assumed to contain an air block. The search may bail out early when the count is
 * greater or equal to the given limit, though this cannot be guaranteed.
 */
private int countUnsupportedNeighbors(long pos, int limit) {
  TLongSet supported = new TLongHashSet();
  TLongSet unsupported = new TLongHashSet();

  try {
    for (BlockFace face : NEIGHBORS) {
      if (!this.isSupported(neighborPos(pos, face), supported, unsupported)) {
        if (unsupported.size() >= limit) break;
      }
    }
  } catch (MaxSearchVisitsExceeded ex) {
    this.logError(ex);
  }

  return unsupported.size();
}
 
Example 2
Source File: FallingBlocksMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Return the number of unsupported blocks connected to any blocks neighboring the given location,
 * which is assumed to contain an air block. The search may bail out early when the count is greater
 * or equal to the given limit, though this cannot be guaranteed.
 */
private int countUnsupportedNeighbors(long pos, int limit) {
    TLongSet supported = new TLongHashSet();
    TLongSet unsupported = new TLongHashSet();

    try {
        for(BlockFace face : NEIGHBORS) {
            if(!this.isSupported(neighborPos(pos, face), supported, unsupported)) {
                if(unsupported.size() >= limit) break;
            }
        }
    }
    catch(MaxSearchVisitsExceeded ex) {
        this.logError(ex);
    }

    return unsupported.size();
}
 
Example 3
Source File: SparseArrayWithLongCoding.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
public Array<T> distinct(int limit) {
    final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
    final TLongSet set = new TLongHashSet(capacity);
    final ArrayBuilder<T> builder = ArrayBuilder.of(capacity, type());
    for (int i=0; i<length(); ++i) {
        final long code = getLong(i);
        if (set.add(code)) {
            final T value = getValue(i);
            builder.add(value);
            if (set.size() >= limit) {
                break;
            }
        }
    }
    return builder.toArray();
}
 
Example 4
Source File: SparseArrayOfLongs.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
public final Array<Long> distinct(int limit) {
    final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
    final TLongSet set = new TLongHashSet(capacity);
    final ArrayBuilder<Long> builder = ArrayBuilder.of(capacity, Long.class);
    for (int i=0; i<length(); ++i) {
        final long value = getLong(i);
        if (set.add(value)) {
            builder.addLong(value);
            if (set.size() >= limit) {
                break;
            }
        }
    }
    return builder.toArray();
}
 
Example 5
Source File: MappedArrayWithLongCoding.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
public Array<T> distinct(int limit) {
    final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
    final TLongSet set = new TLongHashSet(capacity);
    final ArrayBuilder<T> builder = ArrayBuilder.of(capacity, type());
    for (int i=0; i<length(); ++i) {
        final long code = getLong(i);
        if (set.add(code)) {
            final T value = getValue(i);
            builder.add(value);
            if (set.size() >= limit) {
                break;
            }
        }
    }
    return builder.toArray();
}
 
Example 6
Source File: MappedArrayOfLongs.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
public final Array<Long> distinct(int limit) {
    final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
    final TLongSet set = new TLongHashSet(capacity);
    final ArrayBuilder<Long> builder = ArrayBuilder.of(capacity, Long.class);
    for (int i=0; i<length(); ++i) {
        final long value = getLong(i);
        if (set.add(value)) {
            builder.addLong(value);
            if (set.size() >= limit) {
                break;
            }
        }
    }
    return builder.toArray();
}
 
Example 7
Source File: DenseArrayWithLongCoding.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
public Array<T> distinct(int limit) {
    final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
    final TLongSet set = new TLongHashSet(capacity);
    final ArrayBuilder<T> builder = ArrayBuilder.of(capacity, type());
    for (int i=0; i<length(); ++i) {
        final long code = getLong(i);
        if (set.add(code)) {
            final T value = getValue(i);
            builder.add(value);
            if (set.size() >= limit) {
                break;
            }
        }
    }
    return builder.toArray();
}
 
Example 8
Source File: DenseArrayOfLongs.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
public final Array<Long> distinct(int limit) {
    final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
    final TLongSet set = new TLongHashSet(capacity);
    final ArrayBuilder<Long> builder = ArrayBuilder.of(capacity, Long.class);
    for (int i=0; i<length(); ++i) {
        final long value = getLong(i);
        if (set.add(value)) {
            builder.addLong(value);
            if (set.size() >= limit) {
                break;
            }
        }
    }
    return builder.toArray();
}
 
Example 9
Source File: FragmentSegmentAssignmentOnlyLocal.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSegmentConsistent(final long segmentId, final TLongSet containedFragments) {
	final TLongHashSet actualFragments = segmentToFragmentsMap.get(segmentId);
	// if actualFragments is null, no assignment available for fragment/segment, that means
	// fragmentId == segmentId and fragmentId is the only fragment in this segmet.
	if (actualFragments == null)
		return containedFragments.size() == 1 && containedFragments.contains(segmentId);
	return actualFragments.equals(containedFragments);
}