gnu.trove.map.TLongLongMap Java Examples
The following examples show how to use
gnu.trove.map.TLongLongMap.
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: N5FragmentSegmentAssignmentInitialLut.java From paintera with GNU General Public License v2.0 | 6 votes |
@Override public TLongLongMap get() { try { RandomAccessibleInterval<UnsignedLongType> data = openDatasetSafe(meta.reader(), meta.dataset()); final long[] keys = new long[(int) data.dimension(0)]; final long[] values = new long[keys.length]; LOG.debug("Found {} assignments", keys.length); final Cursor<UnsignedLongType> keyCursor = Views.flatIterable(Views.hyperSlice(data, 1, 0L)).cursor(); final Cursor<UnsignedLongType> valueCursor = Views.flatIterable(Views.hyperSlice(data, 1, 1L)).cursor(); for (int i = 0; i < keys.length; ++i) { keys[i] = keyCursor.next().getIntegerLong(); values[i] = valueCursor.next().getIntegerLong(); } return new TLongLongHashMap(keys, values); } catch (IOException e) { LOG.debug("Exception while trying to return initial lut from N5", e); LOG.info("Unable to read initial lut from {} -- returning empty map", meta); return new TLongLongHashMap(); } }
Example #2
Source File: GuildSettingsUtils.java From SkyBot with GNU Affero General Public License v3.0 | 6 votes |
private static void loadVcAutoRoles(DatabaseAdapter adapter, TLongObjectMap<TLongLongMap> vcAutoRoleCache) { logger.info("Loading vc auto roles."); adapter.getVcAutoRoles((items) -> { items.forEach( (item) -> { final TLongLongMap cache = Optional.ofNullable( vcAutoRoleCache.get(item.getGuildId()) ) .orElseGet( () -> { vcAutoRoleCache.put(item.getGuildId(), new TLongLongHashMap()); // This returns the old value which was null return vcAutoRoleCache.get(item.getGuildId()); } ); cache.put(item.getVoiceChannelId(), item.getRoleId()); } ); logger.info("Loaded " + items.size() + " vc auto roles."); return null; }); }
Example #3
Source File: FragmentSegmentAssignmentOnlyLocalSerializer.java From paintera with GNU General Public License v2.0 | 5 votes |
private static Supplier<TLongLongMap> tryDeserializeInitialLutSupplier( final JsonObject map, final JsonDeserializationContext context) { try { return SerializationHelpers.deserializeFromClassInfo(map, context); } catch (ClassNotFoundException e) { throw new JsonParseException("Unable to deserialize initial lut supplier", e); } }
Example #4
Source File: FragmentSegmentAssignmentOnlyLocal.java From paintera with GNU General Public License v2.0 | 5 votes |
public FragmentSegmentAssignmentOnlyLocal( final Supplier<TLongLongMap> initialLut, final Persister persister) { super(); this.initialLut = initialLut; this.persister = persister; LOG.debug("Assignment map: {}", fragmentToSegmentMap); // TODO should reset lut also forget about all actions? I think not. resetLut(); }
Example #5
Source File: GuildListener.java From SkyBot with GNU Affero General Public License v3.0 | 5 votes |
private void handleVcAutoRole(Guild guild, Member member, VoiceChannel channel, boolean remove) { final Member self = guild.getSelfMember(); final long guildId = guild.getIdLong(); final TLongObjectMap<TLongLongMap> vcAutoRoleCache = variables.getVcAutoRoleCache(); if (!vcAutoRoleCache.containsKey(guildId)) { return; } final TLongLongMap vcToRolePair = vcAutoRoleCache.get(guildId); if (vcToRolePair.get(channel.getIdLong()) > 0) { final Role role = guild.getRoleById(vcToRolePair.get(channel.getIdLong())); if (role != null && self.canInteract(member) && self.canInteract(role) && self.hasPermission(Permission.MANAGE_ROLES)) { if (remove) { guild .removeRoleFromMember(member, role) .reason("VC auto role removed") .queue(); } else { guild .addRoleToMember(member, role) .reason("VC auto role applied") .queue(); } } } }
Example #6
Source File: FragmentSegmentAssignmentOnlyLocal.java From paintera with GNU General Public License v2.0 | 4 votes |
@Override public TLongLongMap get() { return new TLongLongHashMap(); }
Example #7
Source File: FragmentSegmentAssignmentOnlyLocal.java From paintera with GNU General Public License v2.0 | 4 votes |
public Supplier<TLongLongMap> getInitialLutSupplier() { return this.initialLut; }
Example #8
Source File: Variables.java From SkyBot with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the vc autorole cache * <p> * Layout: * Guild id -> * Voice channel id -> Role id * * @return The vc autorole cache */ public TLongObjectMap<TLongLongMap> getVcAutoRoleCache() { return vcAutoRoleCache; }