当前位置: 首页>>代码示例>>Java>>正文


Java TLongHashSet类代码示例

本文整理汇总了Java中gnu.trove.set.hash.TLongHashSet的典型用法代码示例。如果您正苦于以下问题:Java TLongHashSet类的具体用法?Java TLongHashSet怎么用?Java TLongHashSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TLongHashSet类属于gnu.trove.set.hash包,在下文中一共展示了TLongHashSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: countUnsupportedNeighbors

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:23,代码来源:FallingBlocksMatchModule.java

示例2: update

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@Override
public void update(JSONObject json) {
    position = json.optInt("position");
    if(overwrites == null) overwrites = new TLongObjectHashMap<>();
    TLongSet toRemove = new TLongHashSet(overwrites.keys());
    JSONArray array = json.getJSONArray("permission_overwrites");
    for(int i = 0, j = array.length(); i < j; i++) {
        JSONObject overwrite = array.getJSONObject(i);
        long id = overwrite.getLong("id");
        toRemove.remove(id);
        overwrites.put(id, new CachedOverwrite(overwrite));
    }
    for(TLongIterator it = toRemove.iterator(); it.hasNext();) {
        overwrites.remove(it.next());
    }
    name = json.optString("name");
    topic = json.optString("topic");
    nsfw = json.optBoolean("nsfw");
    lastMessageId = json.optLong("last_message_id");
    bitrate = json.optInt("bitrate");
    userLimit = json.optInt("user_limit");
    parentId = json.optLong("parent_id");
}
 
开发者ID:natanbc,项目名称:discord-bot-gateway,代码行数:24,代码来源:CachedChannel.java

示例3: distinct

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@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();
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:18,代码来源:SparseArrayWithLongCoding.java

示例4: distinct

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@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();
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:17,代码来源:SparseArrayOfLongs.java

示例5: trivia

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@Command(
        name = "trivia",
        description = "Play trivia",
        usage = "`>>trivia`: Play trivia",
        permission = CommandPermission.USER,
        category = CommandCategory.GAME
)
public static void trivia(@Argument("channel") TextChannel channel, @Argument("author") User author) {
    if(check(channel)) return;
    OpenTriviaDatabase.Question q = OpenTriviaDatabase.random();
    if(q == null) {
        channel.sendMessage("Error getting a question from open trivia database").queue();
        return;
    }
    TLongSet players = new TLongHashSet();
    players.add(author.getIdLong());
    EventManagerThread.current().newThread(()->{
        try {
            Thread.sleep(100);
        } catch(InterruptedException e) {
            return;
        }
        InteractiveOperations.create(channel.getIdLong(), 120, new Trivia(channel, players, q));
    }, "Game Starter").start();
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:26,代码来源:GameCommands.java

示例6: friends

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@Command(
        name = "pokemonguess",
        description = "Guess which pokemon it is",
        usage = "`>>pokemonguess`: Play pokemon guess solo\n" +
                "`>>pokemonguess @Someone @SomeoneElse ...`: Play pokemon guess with your friends (if you have any)",
        permission = CommandPermission.USER,
        category = CommandCategory.GAME
)
public static void pokemonguess(@Argument("channel") TextChannel channel, @Argument("author") User author, @Argument("message") Message message) {
    if(check(channel)) return;
    TLongSet players = new TLongHashSet();
    players.add(author.getIdLong());
    for(User u : message.getMentionedUsers()) players.add(u.getIdLong());
    EventManagerThread.current().newThread(()->{
        try {
            Thread.sleep(100);
        } catch(InterruptedException e) {
            return;
        }
        InteractiveOperations.create(channel.getIdLong(), 120, new Pokemon(channel, players));
    }, "Game Starter").start();
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:23,代码来源:GameCommands.java

示例7: upvoters

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
public static TUnmodifiableLongSet upvoters() {
    if(upvoters == null) {
        synchronized(GabrielData.class) {
            if(upvoters != null) return upvoters;
            upvoters = new TUnmodifiableLongSet(new TLongHashSet());
            Thread t = new Thread(()->{
                DiscordBotsAPI api = GabrielBot.getInstance().discordBotsAPI;
                if(api.getToken() == null) return;
                while(true) {
                    upvoters = new TUnmodifiableLongSet(new TLongHashSet(api.getUpvoterIds(GabrielBot.getInstance().getShards()[0].getJDA().getSelfUser().getIdLong())));
                    try {
                        TimeUnit.MINUTES.sleep(3);
                    } catch(InterruptedException e) {
                        GabrielBot.LOGGER.error("Upvoter updater interrupted");
                        return;
                    }
                }
            });
            t.setName("DBL Upvotes Updater Thread");
            t.setDaemon(true);
            t.setPriority(1);
            t.start();
        }
    }
    return upvoters;
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:27,代码来源:GabrielData.java

示例8: hasNodeIntersections

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
/**
 * Return whether this ring has intersections in terms of node ids appearing
 * multiple times.
 */
public boolean hasNodeIntersections() {
    int size = this.nodeIds.size();
    // Keep a set of already encountered ids
    TLongSet before = new TLongHashSet();
    // The first id can't be there already because the set is empty
    before.add(this.nodeIds.get(0));
    // Check all nodes except the last one which gets special care
    for (int i = 1; i < size - 1; i++) {
        long id = this.nodeIds.get(i);
        // Is it already on the set -> there is an intersection
        if (before.contains(id)) {
            return true;
        }
        // Add to the set of encountered ids
        before.add(id);
    }
    // If this ring is closed, the last node intersects the first one, but
    // that is okay
    if (this.isClosed()) {
        return false;
    }
    // If the ring is not closed, the last node might be an intersection
    // with one of the others
    return before.contains(this.nodeIds.get(size - 1));
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:30,代码来源:ChainOfNodes.java

示例9: findMemberRelationsRecursively

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
private void findMemberRelationsRecursively(Deque<OsmRelation> queue,
                                            Set<OsmRelation> outRelations) throws EntityNotFoundException {
    TLongSet ids = new TLongHashSet();
    while (!queue.isEmpty()) {
        OsmRelation relation = queue.remove();
        for (OsmRelationMember member : OsmModelUtil
                .membersAsList(relation)) {
            if (member.getType() != EntityType.Relation) {
                continue;
            }
            long id = member.getId();
            if (ids.contains(id)) {
                continue;
            }
            ids.add(id);

            OsmRelation child = this.entityProvider.getRelation(id);
            outRelations.add(child);
            queue.add(child);
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:EntityFinderThrowMissing.java

示例10: findMemberRelationsRecursively

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
private void findMemberRelationsRecursively(Deque<OsmRelation> queue,
                                            Set<OsmRelation> outRelations) {
    TLongSet ids = new TLongHashSet();
    while (!queue.isEmpty()) {
        OsmRelation relation = queue.remove();
        for (OsmRelationMember member : OsmModelUtil
                .membersAsList(relation)) {
            if (member.getType() != EntityType.Relation) {
                continue;
            }
            long id = member.getId();
            if (ids.contains(id)) {
                continue;
            }
            ids.add(id);

            try {
                OsmRelation child = this.entityProvider.getRelation(id);
                outRelations.add(child);
                queue.add(child);
            } catch (EntityNotFoundException e) {
                // ignore silently
            }
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:27,代码来源:EntityFinderIgnoreMissing.java

示例11: findMemberRelationsRecursively

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
private void findMemberRelationsRecursively(Deque<OsmRelation> queue,
                                            Set<OsmRelation> outRelations) {
    TLongSet ids = new TLongHashSet();
    while (!queue.isEmpty()) {
        OsmRelation relation = queue.remove();
        for (OsmRelationMember member : OsmModelUtil
                .membersAsList(relation)) {
            if (member.getType() != EntityType.Relation) {
                continue;
            }
            long id = member.getId();
            if (ids.contains(id)) {
                continue;
            }
            ids.add(id);

            try {
                OsmRelation child = this.entityProvider.getRelation(id);
                outRelations.add(child);
                queue.add(child);
            } catch (EntityNotFoundException e) {
                this.logRelationNotFound(id);
            }
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:27,代码来源:EntityFinderLogMissing.java

示例12: getVisibleIds

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@Override
public synchronized TLongHashSet getVisibleIds()
{
	final TLongHashSet visibleIds = new TLongHashSet();
	final int w = viewer.getWidth();
	final int h = viewer.getHeight();
	final AffineTransform3D viewerTransform = new AffineTransform3D();
	viewer.getState().getViewerTransform( viewerTransform );
	IntervalView< LabelMultisetType > screenLabels =
			Views.interval(
					Views.hyperSlice(
							RealViews.affine( labels, viewerTransform ), 2, 0 ),
					new FinalInterval( w, h ) );

	for ( final LabelMultisetType pixel : Views.iterable( screenLabels ) )
	{
		for ( final Entry< Label > entry : pixel.entrySet() )
				visibleIds.add( entry.getElement().id() );
	}

	return visibleIds;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:23,代码来源:LabelMultiSetIdPicker.java

示例13: initAssignments

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
/**
 * Initialize assignments.
 *
 * @param params
 */
protected void initAssignments( final P params )
{
	final IHDF5Reader reader = HDF5Factory.openForReading( params.inFile );

	/* fragment segment assignment */
	assignment = new FragmentSegmentAssignment( idService );
	final TLongLongHashMap lut = H5Utils.loadLongLongLut( reader, params.assignment, 1024 );
	if ( lut != null )
		assignment.initLut( lut );

	/* complete fragments */
	completeFragmentsAssignment = new FragmentAssignment();
	final TLongHashSet set = new TLongHashSet();
	H5Utils.loadLongCollection( set, reader, params.completeFragments, 1024 );

	/* color stream */
	colorStream = new ModalGoldenAngleSaturatedARGBStream( assignment );
	colorStream.setAlpha( 0x20 );

	reader.close();
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:27,代码来源:BigCatViewer.java

示例14: getCoastLines

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
@Override
public Set<CB_TDWay> getCoastLines(TileCoordinate tc) {
    if (tc.getZoomlevel() <= TileInfo.TILE_INFO_ZOOMLEVEL) {
        return Collections.emptySet();
    }
    TileCoordinate correspondingOceanTile = tc.translateToZoomLevel(TileInfo.TILE_INFO_ZOOMLEVEL).get(0);
    TLongHashSet coastlines = this.tilesToCoastlines.get(correspondingOceanTile);
    if (coastlines == null) {
        return Collections.emptySet();
    }

    final Set<CB_TDWay> res = new HashSet<>();
    coastlines.forEach(new TLongProcedure() {
        @Override
        public boolean execute(long id) {
            CB_TDWay way = CB_RAMTileBasedDataProcessor.this.ways.get(id);
            if (way != null) {
                res.add(way);
                return true;
            }
            return false;
        }
    });
    return res;
}
 
开发者ID:Longri,项目名称:CB_MAP,代码行数:26,代码来源:CB_RAMTileBasedDataProcessor.java

示例15: registerHighway

import gnu.trove.set.hash.TLongHashSet; //导入依赖的package包/类
private void registerHighway(final Way way, final TLongHashSet usedNodes, final TLongHashSet intersectionNodes) {
	for (final Tag tg : way.getTags()) {
		final String key = tg.getKey();
		if (key.equals("highway")) {
			final List<WayNode> nodes = way.getWayNodes();
			for (final WayNode node : nodes) {
				final long id = node.getNodeId();
				if (usedNodes.contains(id)) {
					intersectionNodes.add(id);
				} else {
					usedNodes.add(id);
				}
			}
			if (nodes.size() > 2 && nodes.get(0) == nodes.get(nodes.size() - 1)) {
				intersectionNodes.add(nodes.get(nodes.size() / 2).getNodeId());
			}
		}
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:20,代码来源:GamaOsmFile.java


注:本文中的gnu.trove.set.hash.TLongHashSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。