/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
public int size() { synchronized( mutex ) { return m.size(); } } public boolean isEmpty(){
public int size() { return m.size(); } public boolean isEmpty() { return m.isEmpty(); }
public int getComponentCount(Class<? extends Component> componentClass) { TLongObjectMap<Component> map = store.get(componentClass); return (map == null) ? 0 : map.size(); }
/** * Creates a new <code>TLongObjectHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>TLongObjectMap</tt> to be copied. */ public TLongObjectHashMap( TLongObjectMap<? extends V> map ) { this( map.size(), 0.5f, map.getNoEntryKey() ); putAll( map ); }
@Override public long size() { return elements.size(); }
/** {@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; }
@Override public List<T> asList() { ArrayList<T> list = new ArrayList<>(elements.size()); elements.forEachValue(list::add); return Collections.unmodifiableList(list); }
@Override public List<PermissionOverride> getPermissionOverrides() { // already unmodifiable! return Arrays.asList(overrides.values(new PermissionOverride[overrides.size()])); }
@Override public Set<T> asSet() { HashSet<T> set = new HashSet<>(elements.size()); elements.forEachValue(set::add); return Collections.unmodifiableSet(set); }
@Override public List<T> asList() { List<T> list = new ArrayList<>(elements.size()); elements.forEachValue(list::add); list.sort(comparator); return Collections.unmodifiableList(list); }
protected boolean send(String message, boolean skipQueue) { if (!connected) return false; long now = System.currentTimeMillis(); if (this.ratelimitResetTime <= now) { this.messagesSent.set(0); this.ratelimitResetTime = now + 60000;//60 seconds this.printedRateLimitMessage = false; } //Allows 115 messages to be sent before limiting. if (this.messagesSent.get() <= 115 || (skipQueue && this.messagesSent.get() <= 119)) //technically we could go to 120, but we aren't going to chance it { LOG.trace("<- {}", message); socket.sendText(message); this.messagesSent.getAndIncrement(); return true; } else { if (!printedRateLimitMessage) { LOG.warn("Hit the WebSocket RateLimit! This can be caused by too many presence or voice status updates (connect/disconnect/mute/deaf). " + "Regular: {} Voice: {} Chunking: {}", ratelimitQueue.size(), queuedAudioConnections.size(), chunkSyncQueue.size()); printedRateLimitMessage = true; } return false; } }
@Override public Spliterator<T> spliterator() { return Spliterators.spliterator(iterator(), elements.size(), SPLIT_CHARACTERISTICS); }
boolean handleMemberChunk(JSONArray arr) { if (partialGuild == null) { //In this case we received a GUILD_DELETE with unavailable = true while chunking // however we have to wait for the GUILD_CREATE with unavailable = false before // requesting new chunks GuildSetupController.log.debug("Dropping member chunk due to unavailable guild"); return true; } for (Object o : arr) { JSONObject obj = (JSONObject) o; long id = obj.getJSONObject("user").getLong("id"); members.put(id, obj); } if (members.size() >= expectedMemberCount) { completeSetup(); return false; } return true; }
private void ensureMembers() { expectedMemberCount = partialGuild.getInt("member_count"); members = new TLongObjectHashMap<>(expectedMemberCount); removedMembers = new TLongHashSet(); JSONArray memberArray = partialGuild.getJSONArray("members"); if (memberArray.length() < expectedMemberCount && !requestedChunk) { updateStatus(GuildSetupController.Status.CHUNKING); getController().addGuildForChunking(id, join); requestedChunk = true; } else if (handleMemberChunk(memberArray) && !requestedChunk) { // Discord sent us enough members to satisfy the member_count // but we found duplicates and still didn't reach enough to satisfy the count // in this case we try to do chunking instead // This is caused by lazy guilds and intended behavior according to jake GuildSetupController.log.trace( "Received suspicious members with a guild payload. Attempting to chunk. " + "member_count: {} members: {} actual_members: {} guild_id: {}", expectedMemberCount, memberArray.length(), members.size(), id); members.clear(); updateStatus(GuildSetupController.Status.CHUNKING); getController().addGuildForChunking(id, join); requestedChunk = true; } }
/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
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(); 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); mng.closeAudioConnection(ConnectionStatus.DISCONNECTED_REMOVED_DURING_RECONNECT); it.remove(); } } } }
/** * Returns the number of entries in the map. * * @return the map's size. */ @Override public int size() { return this._map.size(); }
/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
/** * Creates a new <code>TLongObjectHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>TLongObjectMap</tt> to be copied. */ public TLongObjectHashMap( TLongObjectMap<V> map ) { this( map.size(), 0.5f, map.getNoEntryKey() ); putAll( map ); }