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


Java TLongSet类代码示例

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


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

示例1: countUnsupportedNeighbors

import gnu.trove.set.TLongSet; //导入依赖的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: equals

import gnu.trove.set.TLongSet; //导入依赖的package包/类
/** {@inheritDoc) */
public boolean equals( Object other ) {
    if (! ( other instanceof TLongSet ) ) {
        return false;
    }
    final TLongSet that = ( TLongSet ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            if ( ! that.contains( _set[i] ) ) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:19,代码来源:TLongObjectHashMap.java

示例3: equals

import gnu.trove.set.TLongSet; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean equals( Object other ) {
    if ( ! ( other instanceof TLongSet ) ) {
        return false;
    }
    TLongSet that = ( TLongSet ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            if ( ! that.contains( _set[i] ) ) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:19,代码来源:TLongHashSet.java

示例4: calculateAllReduceFactors

import gnu.trove.set.TLongSet; //导入依赖的package包/类
@Override
public void calculateAllReduceFactors(final TLongObjectMap<TLongArrayList> nodeSegmentTable,
                                      final TLongObjectMap<ISegment> segmentsTable,
                                      final TLongSet relevantLinks,
                                      TLongObjectMap<IPixelCut> pixelCuts) {
	TLongObjectMap<IRenderingSegment> renderingResults = new TLongObjectHashMap<>();
	nodeSegmentTable.forEachEntry((nodeId, segmentIds) -> {
        if (segmentIds.size() > 1) {
            ISegment[] segments = new ISegment[segmentIds.size()];
            for (int i = 0; i < segmentIds.size(); i++) {
                segments[i] = segmentsTable.get(segmentIds.get(i));
            }
            investigateNode(nodeId, renderingResults, segments);
        }
        return true;
    });
    adaptPixelCuts(pixelCuts, renderingResults);
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:19,代码来源:RenderingCalculatorImpl.java

示例5: update

import gnu.trove.set.TLongSet; //导入依赖的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

示例6: equals

import gnu.trove.set.TLongSet; //导入依赖的package包/类
public boolean equals( Object other ) {
    if (! ( other instanceof TLongSet ) ) {
        return false;
    }
    final TLongSet that = ( TLongSet ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            if ( ! that.contains( _set[i] ) ) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:TLongObjectHashMap.java

示例7: distinct

import gnu.trove.set.TLongSet; //导入依赖的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

示例8: distinct

import gnu.trove.set.TLongSet; //导入依赖的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

示例9: Trivia

import gnu.trove.set.TLongSet; //导入依赖的package包/类
public Trivia(TextChannel channel, TLongSet players, OpenTriviaDatabase.Question question) {
    super(channel, players, question.correctAnswer, (question.incorrectAnswers.size() + 1) / 2);

    List<String> options = new ArrayList<>(question.incorrectAnswers);
    options.add(question.correctAnswer);

    int triesLeft = options.size()/2;

    totalOptions = options.size();
    correctOptionIndex = options.indexOf(question.correctAnswer);

    Collections.shuffle(options);

    int[] idx = {1};
    channel.sendMessage(new EmbedBuilder()
            .setDescription("**" + question.question + "**")
            .addField("Options", options.stream().map(o->idx[0]++ + " - " + o).collect(Collectors.joining("**\n**", "**", "**")), false)
            .addField("Difficulty", question.difficulty, true)
            .addField("Category", question.category, true)
            .setFooter(triesLeft + " tries left | Answer with the option number", null)
            .build()
    ).queue();
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:24,代码来源:Trivia.java

示例10: trivia

import gnu.trove.set.TLongSet; //导入依赖的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

示例11: friends

import gnu.trove.set.TLongSet; //导入依赖的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

示例12: equals

import gnu.trove.set.TLongSet; //导入依赖的package包/类
/** {@inheritDoc) */
@Override
public boolean equals( Object other ) {
    if (! ( other instanceof TLongSet ) ) {
        return false;
    }
    final TLongSet that = ( TLongSet ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            if ( ! that.contains( _set[i] ) ) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:20,代码来源:TLongObjectHashMap.java

示例13: equals

import gnu.trove.set.TLongSet; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TLongSet ) ) {
        return false;
    }
    TLongSet that = ( TLongSet ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    for ( int i = _states.length; i-- > 0; ) {
        if ( _states[i] == FULL ) {
            if ( ! that.contains( _set[i] ) ) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:20,代码来源:TLongHashSet.java

示例14: equals

import gnu.trove.set.TLongSet; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TLongSet ) ) {
        return false;
    }
    TLongSet that = ( TLongSet ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    for ( int i = capacity(); i-- > 0; ) {
        if ( _states.get(i) == FULL ) {
            if ( ! that.contains( _set.get( i ) ) ) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:20,代码来源:TLongOffheapHashSet.java

示例15: hasNodeIntersections

import gnu.trove.set.TLongSet; //导入依赖的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


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