@Override public Iterator<NextTickListEntry> iterator() { return new Iterator<NextTickListEntry>() { private final TLongObjectIterator<BlockUpdateEntry> iterator = trackerMap.iterator();; @Override public boolean hasNext() { return iterator.hasNext(); } @Override public NextTickListEntry next() { iterator.advance(); return iterator.value().asMCEntry(); } @Override public void remove() { removeEntry(iterator.value(), true); } }; }
@Override public void process(@Nonnull final EntityPlayer player) { if (this.systems.size() == 0) return; final double range = ModOptions.specialEffectRange; final BlockPos min = EnvironState.getPlayerPosition().add(-range, -range, -range); final BlockPos max = EnvironState.getPlayerPosition().add(range, range, range); final TLongObjectIterator<ParticleSystem> itr = this.systems.iterator(); while (itr.hasNext()) { itr.advance(); // If it is out of range expire, else update if (!BlockPosHelper.contains(itr.value().getPos(), min, max)) { itr.value().setExpired(); } else { itr.value().onUpdate(); } // If it's dead remove from the list if (!itr.value().isAlive()) itr.remove(); } }
@Override public JsonElement serialize( final FragmentSegmentAssignment src, final Type typeOfSrc, final JsonSerializationContext context ) { final Gson gson = new Gson(); final JsonObject jsonILut = new JsonObject(); final TLongObjectIterator< long[] > ilutIterator = src.ilut.iterator(); while ( ilutIterator.hasNext() ) { ilutIterator.advance(); jsonILut.add( Long.toString( ilutIterator.key() ), gson.toJsonTree( ilutIterator.value() ) ); } final JsonObject jsonObject = new JsonObject(); jsonObject.add( "ilut", jsonILut ); return jsonObject; }
/** * Make any unsupported blocks fall that are disturbed for the current tick */ private void fallCheck() { this.visitsWorstTick = Math.max(this.visitsWorstTick, this.visitsThisTick); this.visitsThisTick = 0; World world = this.getMatch().getWorld(); TLongObjectMap<ParticipantState> blockDisturbers = this.blockDisturbersByTick.remove(this.getMatch().getClock().now().tick); if(blockDisturbers == null) return; TLongSet supported = new TLongHashSet(); TLongSet unsupported = new TLongHashSet(); TLongObjectMap<ParticipantState> fallsByBreaker = new TLongObjectHashMap<>(); try { while(!blockDisturbers.isEmpty()) { long pos = blockDisturbers.keySet().iterator().next(); ParticipantState breaker = blockDisturbers.remove(pos); // Search down for the first block that can actually fall for(;;) { long below = neighborPos(pos, BlockFace.DOWN); if(!Materials.isColliding(blockAt(world, below).getType())) break; blockDisturbers.remove(pos); // Remove all the blocks we find along the way pos = below; } // Check if the block needs to fall, if it isn't already falling if(!fallsByBreaker.containsKey(pos) && !this.isSupported(pos, supported, unsupported)) { fallsByBreaker.put(pos, breaker); } } } catch(MaxSearchVisitsExceeded ex) { this.logError(ex); } for(TLongObjectIterator<ParticipantState> iter = fallsByBreaker.iterator(); iter.hasNext();) { iter.advance(); this.fall(iter.key(), iter.value()); } }
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( ! ( other instanceof TLongObjectMap ) ) { return false; } TLongObjectMap that = ( TLongObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TLongObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); long key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
public boolean equals( Object other ) { if ( ! ( other instanceof TLongObjectMap ) ) { return false; } TLongObjectMap that = ( TLongObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TLongObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); long key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
/** {@inheritDoc} */ @Override @SuppressWarnings("rawtypes") public boolean equals( Object other ) { if ( ! ( other instanceof TLongObjectMap ) ) { return false; } TLongObjectMap that = ( TLongObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TLongObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); long key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
public SparseMatrixT<T> resize(int[] dim){ SparseMatrixT<T> mat = new SparseMatrixT<T>(dim); TLongObjectIterator<T> it = vector.iterator(); while(it.hasNext()){ it.advance(); long key = it.key(); T val = it.value(); int[] idx = getIndices(key); mat.set(idx, val); } return mat; }
public SparseMatrix<T> resize(int dim){ SparseMatrix<T> mat = new SparseMatrix<T>(dim); TLongObjectIterator<T> it = vector.iterator(); while(it.hasNext()){ it.advance(); long key = it.key(); T val = it.value(); int[] idx = getIndices(key); mat.set(idx[0],idx[1], val); } return mat; }
/** * Creates a new formula interpreter for the parameter values in this table. */ public FormulaInterpreter createInterpreter() { FormulaInterpreter interpreter = new FormulaInterpreter(); TLongObjectIterator<Map<String, ParameterCell>> it = entries.iterator(); while (it.hasNext()) { it.advance(); Map<String, ParameterCell> map = it.value(); for (ParameterCell cell : map.values()) cell.bindTo(interpreter); } return interpreter; }
/** * Calculates new random values for the parameters in this table that have * an uncertainty distribution assigned. The method creates a formula * interpreter that is used for the evaluation of the uncertainty parameters * and returned with the new values bound. Thus, the returned interpreter * can be used in calculations. */ public FormulaInterpreter simulate() { FormulaInterpreter interpreter = createInterpreter(); TLongObjectIterator<Map<String, ParameterCell>> it = entries.iterator(); while (it.hasNext()) { it.advance(); Map<String, ParameterCell> map = it.value(); for (ParameterCell cell : map.values()) { cell.eval(interpreter); cell.simulate(); cell.bindTo(interpreter); } } return interpreter; }
/** Get all product or waste treatment providers from the database. */ public List<LongPair> getProviderFlows() { List<LongPair> list = new ArrayList<>(); TLongObjectIterator<TLongArrayList> it = providerMap.iterator(); while (it.hasNext()) { it.advance(); long productId = it.key(); for (long processId : it.value().toArray()) { list.add(LongPair.of(processId, productId)); } } return list; }
/** {@inheritDoc} */ public TLongObjectIterator<V> iterator() { return new TLongObjectHashIterator<V>( this ); }
public TLongObjectIterator<V> iterator() { return new TLongObjectHashIterator<V>( this ); }
/** {@inheritDoc} */ @Override public TLongObjectIterator<V> iterator() { return new TLongObjectHashIterator( this ); }
protected void updateAudioManagerReferences() { final TLongObjectMap<AudioManager> managerMap = api.getAudioManagerMap(); if (managerMap.size() > 0) LOG.trace("Updating AudioManager references"); synchronized (managerMap) { for (TLongObjectIterator<AudioManager> it = managerMap.iterator(); it.hasNext(); ) { it.advance(); final long guildId = it.key(); final AudioManagerImpl mng = (AudioManagerImpl) it.value(); ConnectionListener listener = mng.getConnectionListener(); GuildImpl guild = (GuildImpl) api.getGuildById(guildId); if (guild == null) { //We no longer have access to the guild that this audio manager was for. Set the value to null. queuedAudioConnections.remove(guildId); if (listener != null) listener.onStatusChange(ConnectionStatus.DISCONNECTED_REMOVED_FROM_GUILD); it.remove(); } else { final AudioManagerImpl newMng = new AudioManagerImpl(guild); newMng.setSelfMuted(mng.isSelfMuted()); newMng.setSelfDeafened(mng.isSelfDeafened()); newMng.setQueueTimeout(mng.getConnectTimeout()); newMng.setSendingHandler(mng.getSendingHandler()); newMng.setReceivingHandler(mng.getReceiveHandler()); newMng.setConnectionListener(listener); newMng.setAutoReconnect(mng.isAutoReconnect()); if (mng.isConnected() || mng.isAttemptingToConnect()) { final long channelId = mng.isConnected() ? mng.getConnectedChannel().getIdLong() : mng.getQueuedAudioConnection().getIdLong(); final VoiceChannel channel = api.getVoiceChannelById(channelId); if (channel != null) { if (mng.isConnected()) mng.closeAudioConnection(ConnectionStatus.ERROR_CANNOT_RESUME); //closing old connection in order to reconnect later newMng.setQueuedAudioConnection(channel); } else { //The voice channel is not cached. It was probably deleted. queuedAudioConnections.remove(guildId); if (listener != null) listener.onStatusChange(ConnectionStatus.DISCONNECTED_CHANNEL_DELETED); } } it.setValue(newMng); } } } }
protected ConnectionRequest getNextAudioConnectRequest() { //Don't try to setup audio connections before JDA has finished loading. if (!isReady()) return null; long now = System.currentTimeMillis(); TLongObjectIterator<ConnectionRequest> it = queuedAudioConnections.iterator(); while (it.hasNext()) { it.advance(); ConnectionRequest audioRequest = it.value(); if (audioRequest.getNextAttemptEpoch() < now) { Guild guild = api.getGuildById(audioRequest.getGuildIdLong()); if (guild == null) { it.remove(); //if (listener != null) // listener.onStatusChange(ConnectionStatus.DISCONNECTED_REMOVED_FROM_GUILD); //already handled by event handling continue; } ConnectionListener listener = guild.getAudioManager().getConnectionListener(); if (audioRequest.getStage() != ConnectionStage.DISCONNECT) { VoiceChannel channel = guild.getVoiceChannelById(audioRequest.getChannel().getIdLong()); if (channel == null) { it.remove(); if (listener != null) listener.onStatusChange(ConnectionStatus.DISCONNECTED_CHANNEL_DELETED); continue; } if (!guild.getSelfMember().hasPermission(channel, Permission.VOICE_CONNECT)) { it.remove(); if (listener != null) listener.onStatusChange(ConnectionStatus.DISCONNECTED_LOST_PERMISSION); continue; } } return audioRequest; } } return null; }
public TLongObjectIterator<V> iterator() { return container.iterator(); }
public TLongObjectIterator<String> iterator() { return container.iterator(); }
/** * Returns a <tt>TLongObjectIterator</tt> with access to this map's keys and values. * * @return a <tt>TLongObjectIterator</tt> with access to this map's keys and values. */ public TLongObjectIterator<V> iterator();
/** * Returns a {@see TLongObjectIterator} with access to this map's keys and values. * @return a {@see TLongObjectIterator} with access to this map's keys and values. */ public TLongObjectIterator<K> iterator() { return map.iterator(); }