Java Code Examples for it.unimi.dsi.fastutil.longs.Long2ObjectMap#containsKey()

The following examples show how to use it.unimi.dsi.fastutil.longs.Long2ObjectMap#containsKey() . 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: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateBetweenY(int minY, int maxY)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();

        for (Chunk chunk : schematicChunks.values())
        {
            // Only mark chunks that are actually rendered (if the schematic world contains more chunks)
            if (chunk.isEmpty() == false && clientChunks.containsKey(ChunkPos.asLong(chunk.x, chunk.z)))
            {
                rg.markBlockRangeForRenderUpdate((chunk.x << 4) - 1, minY, (chunk.z << 4) - 1, (chunk.x << 4) + 16, maxY, (chunk.z << 4) + 16);
            }
        }
    }
}
 
Example 2
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void markSchematicChunkForRenderUpdate(SubChunkPos chunkPos)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();
        long key = ChunkPos.asLong(chunkPos.getX(), chunkPos.getZ());

        if (schematicChunks.containsKey(key) && clientChunks.containsKey(key))
        {
            RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
            rg.markBlockRangeForRenderUpdate((chunkPos.getX() << 4) - 1, (chunkPos.getY() << 4) - 1, (chunkPos.getZ() << 4) - 1,
                                             (chunkPos.getX() << 4) + 1, (chunkPos.getY() << 4) + 1, (chunkPos.getZ() << 4) + 1);
        }
    }
}
 
Example 3
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void markSchematicChunksForRenderUpdate(ChunkPos chunkPos)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();
        long key = ChunkPos.asLong(chunkPos.x, chunkPos.z);

        if (schematicChunks.containsKey(key) && clientChunks.containsKey(key))
        {
            RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
            rg.markBlockRangeForRenderUpdate((chunkPos.x << 4) - 1,   0, (chunkPos.z << 4) - 1,
                                             (chunkPos.x << 4) + 1, 255, (chunkPos.z << 4) + 1);
        }
    }
}
 
Example 4
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void markSchematicChunkForRenderUpdate(BlockPos pos)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();
        long key = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);

        if (schematicChunks.containsKey(key) && clientChunks.containsKey(key))
        {
            RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
            rg.markBlockRangeForRenderUpdate(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1,pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
        }
    }
}
 
Example 5
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
private void calculateRelationship(StrippedPartition partitions, Long2ObjectMap<TupleEquivalenceClassRelation> relationships) {

        int partitionNr = 0;
        for (IntList partition : partitions.getValues()) {
            if (this.debugSysout)
                System.out.println(".");
            for (long index : partition) {
                if (!relationships.containsKey(index)) {
                    relationships.put(index, new TupleEquivalenceClassRelation());
                }
                relationships.get(index).addNewRelationship(partitions.getAttributeID(), partitionNr);
            }
            partitionNr++;
        }

    }
 
Example 6
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
private void handleList(IntList list, Long2ObjectMap<Set<IntList>> maxSets, boolean firstStep) {

        for (int i = 0; i < list.size(); i++) {
            int removedElement = list.removeInt(i);
            if (maxSets.containsKey(list.size()) && maxSets.get(list.size()).contains(list))
                maxSets.get(list.size()).remove(list);
            else {
                if (list.size() > 2) {
                    this.handleList(list, maxSets, false);
                }
            }
            list.add(i, removedElement);
        }

        if (firstStep)
            maxSets.get(list.size()).add(list);
    }
 
Example 7
Source File: BipartiteGraphTestHelper.java    From GraphJet with Apache License 2.0 6 votes vote down vote up
/**
 * Build a random bipartite graph of given left and right sizes.
 *
 * @param leftSize   is the left hand size of the bipartite graph
 * @param rightSize  is the right hand size of the bipartite graph
 * @param random     is the random number generator to use for constructing the graph
 * @return a random bipartite graph
 */
public static StaticBipartiteGraph buildRandomBipartiteGraph(
    int leftSize, int rightSize, double edgeProbability, Random random) {
  Long2ObjectMap<LongList> leftSideGraph = new Long2ObjectOpenHashMap<LongList>(leftSize);
  Long2ObjectMap<LongList> rightSideGraph = new Long2ObjectOpenHashMap<LongList>(rightSize);
  int averageLeftDegree = (int) (rightSize * edgeProbability);
  int averageRightDegree = (int) (leftSize * edgeProbability);
  for (int i = 0; i < leftSize; i++) {
    leftSideGraph.put(i, new LongArrayList(averageLeftDegree));
    for (int j = 0; j < rightSize; j++) {
      if (random.nextDouble() < edgeProbability) {
        leftSideGraph.get(i).add(j);
        if (rightSideGraph.containsKey(j)) {
          rightSideGraph.get(j).add(i);
        } else {
          LongList rightSideList = new LongArrayList(averageRightDegree);
          rightSideList.add(i);
          rightSideGraph.put(j, rightSideList);
        }
      }
    }
  }

  return new StaticBipartiteGraph(leftSideGraph, rightSideGraph);
}
 
Example 8
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateBetweenX(int minX, int maxX)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        final int xMin = Math.min(minX, maxX);
        final int xMax = Math.max(minX, maxX);
        final int cxMin = (xMin >> 4);
        final int cxMax = (xMax >> 4);
        RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();

        for (Chunk chunk : schematicChunks.values())
        {
            // Only mark chunks that are actually rendered (if the schematic world contains more chunks)
            if (chunk.x >= cxMin && chunk.x <= cxMax && chunk.isEmpty() == false &&
                clientChunks.containsKey(ChunkPos.asLong(chunk.x, chunk.z)))
            {
                minX = Math.max( chunk.x << 4      , xMin);
                maxX = Math.min((chunk.x << 4) + 15, xMax);
                rg.markBlockRangeForRenderUpdate(minX, 0, (chunk.z << 4), maxX, 255, (chunk.z << 4) + 15);
            }
        }
    }
}
 
Example 9
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateBetweenZ(int minZ, int maxZ)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        final int zMin = Math.min(minZ, maxZ);
        final int zMax = Math.max(minZ, maxZ);
        final int czMin = (zMin >> 4);
        final int czMax = (zMax >> 4);
        RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();

        for (Chunk chunk : schematicChunks.values())
        {
            // Only mark chunks that are actually rendered (if the schematic world contains more chunks)
            if (chunk.z >= czMin && chunk.z <= czMax && chunk.isEmpty() == false &&
                clientChunks.containsKey(ChunkPos.asLong(chunk.x, chunk.z)))
            {
                minZ = Math.max( chunk.z << 4      , zMin);
                maxZ = Math.min((chunk.z << 4) + 15, zMax);
                rg.markBlockRangeForRenderUpdate((chunk.x << 4), 0, minZ, (chunk.x << 4) + 15, 255, maxZ);
            }
        }
    }
}
 
Example 10
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private void handlePartition(IntList actuelList, long position, Long2ObjectMap<LongSet> index, Set<IntList> max) {

        if (!this.isSubset(actuelList, index)) {
            max.add(actuelList);
            for (long e : actuelList) {
                if (!index.containsKey(e)) {
                    index.put(e, new LongArraySet());
                }
                index.get(e).add(position);
            }
        }
    }
 
Example 11
Source File: FastCollectionsUtils.java    From fastjgame with Apache License 2.0 4 votes vote down vote up
public static <V> void requireNotContains(Long2ObjectMap<V> map, long key, String msg) {
    if (map.containsKey(key)) {
        throw new IllegalArgumentException("duplicate " + msg + "-" + key);
    }
}
 
Example 12
Source File: FastCollectionsUtils.java    From fastjgame with Apache License 2.0 4 votes vote down vote up
public static <V> void requireContains(Long2ObjectMap<V> map, long key, String msg) {
    if (!map.containsKey(key)) {
        throw new IllegalArgumentException("nonexistent " + msg + "-" + key);
    }
}
 
Example 13
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
public Set<IntList> computeMaximumSetsAlternative(List<StrippedPartition> partitions) {

        if (this.debugSysout) {
            System.out.println("\tstartet calculation of maximal partitions");
        }
        long start = System.currentTimeMillis();

        Set<IntList> sortedPartitions = new TreeSet<IntList>(new ListComparator());
        for (StrippedPartition p : partitions) {
            sortedPartitions.addAll(p.getValues());
        }
        Iterator<IntList> it = sortedPartitions.iterator();
        Long2ObjectMap<Set<IntList>> maxSets = new Long2ObjectOpenHashMap<Set<IntList>>();
        long remainingPartitions = sortedPartitions.size();
        if (this.debugSysout) {
            System.out.println("\tNumber of Partitions: " + remainingPartitions);
        }
        if (it.hasNext()) {
            IntList actuelList = it.next();
            long minSize = actuelList.size();
            Set<IntList> set = new HashSet<IntList>();
            set.add(actuelList);
            while ((actuelList = it.next()) != null && (actuelList.size() == minSize)) {
                if (this.debugSysout) {
                    System.out.println("\tremaining: " + --remainingPartitions);
                }
                set.add(actuelList);
            }
            maxSets.put(minSize, set);
            if (actuelList != null) {
                maxSets.put(actuelList.size(), new HashSet<IntList>());
                if (this.debugSysout) {
                    System.out.println("\tremaining: " + --remainingPartitions);
                }
                this.handleList(actuelList, maxSets, true);
                while (it.hasNext()) {
                    actuelList = it.next();
                    if (this.debugSysout) {
                        System.out.println("\tremaining: " + --remainingPartitions);
                    }
                    if (!maxSets.containsKey(actuelList.size()))
                        maxSets.put(actuelList.size(), new HashSet<IntList>());
                    this.handleList(actuelList, maxSets, true);
                }
            }
        }

        long end = System.currentTimeMillis();
        if (this.debugSysout)
            System.out.println("\tTime needed: " + (end - start));

        Set<IntList> max = this.mergeResult(maxSets);
        maxSets.clear();
        sortedPartitions.clear();

        return max;
    }