/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, * or Long(0) if none was found. */ public Long put( Long key, Long value ) { long k; long v; if ( key == null ) { k = _map.getNoEntryKey(); } else { k = unwrapKey( key ); } if ( value == null ) { v = _map.getNoEntryValue(); } else { v = unwrapValue( value ); } long retval = _map.put( k, v ); if ( retval == _map.getNoEntryValue() ) { return null; } return wrapValue( retval ); }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TLongLongMap ) ) { return false; } TLongLongMap that = ( TLongLongMap ) other; if ( that.size() != this.size() ) { return false; } long[] values = _values; byte[] states = _states; long this_no_entry_value = getNoEntryValue(); long that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { long key = _set[i]; long that_value = that.get( key ); long this_value = values[i]; if ( ( this_value != that_value ) && ( this_value != this_no_entry_value ) && ( that_value != that_no_entry_value ) ) { return false; } } } return true; }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return the removed value, or null if it was not found in the map */ public Long remove( Object key ) { long k; if ( key != null ) { if ( key instanceof Long ) { k = unwrapKey( key ); } else { return null; } } else { k = _map.getNoEntryKey(); } long v = _map.remove( k ); // There may be a false positive since primitive maps // cannot return null, so we have to do an extra // check here. if ( v == _map.getNoEntryValue() ) { return null; } else { return wrapValue( v ); } }
/** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey( Object key ) { if ( key == null ) return _map.containsKey( _map.getNoEntryKey() ); return key instanceof Long && _map.containsKey( unwrapKey( key ) ); }
/** * Retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ public Long get( Object key ) { long k; if ( key != null ) { if ( key instanceof Long ) { k = unwrapKey( key ); } else { return null; } } else { k = _map.getNoEntryKey(); } long v = _map.get( k ); // There may be a false positive since primitive maps // cannot return null, so we have to do an extra // check here. if ( v == _map.getNoEntryValue() ) { return null; } else { return wrapValue( v ); } }
public long put( long key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } public long remove( long key ) {
public long get( long key ) { synchronized( mutex ) { return m.get( key ); } }
/** * Empties the map. */ public void clear() { this._map.clear(); }
public boolean isEmpty(){ synchronized( mutex ) { return m.isEmpty(); } } public boolean containsKey( long key ) {
public long remove( long key ) { synchronized( mutex ) { return m.remove( key ); } } public void putAll( Map<? extends Long, ? extends Long> map ) {
/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
long loadedTime = loadedTimes.get(chunkKey); if (current - loadedTime <= TimeUnit.SECONDS.toMillis(server.getConfiguration().getChunkGC().getReleaseAfterLoadSeconds())) { long lastAccessTime = lastAccessTimes.get(chunkKey); if (current - lastAccessTime <= TimeUnit.SECONDS.toMillis(server.getConfiguration().getChunkGC().getReleaseAfterLastAccess())) { lastAccessTimes.remove(chunkKey); loadedTimes.remove(chunkKey); level.getEntityManager().getEntitiesInChunk(x, z).forEach(Entity::remove);
public TLongLongIterator iterator() { return m.iterator(); // Must be manually synched by user! }
public boolean containsKey( long key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( long value ){
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, * or Long(0) if none was found. */ @Override public Long put( Long key, Long value ) { long k = unwrapKey( key ); long v = unwrapValue( value ); if ( _map.containsKey( k ) ) { long retval = _map.put( k, v ); return wrapValue( retval); } _map.put( k, v ); return null; }
@Override public void run() { if (pendingChunks.isEmpty()) return; synchronized (pendingChunks) { TLongLongIterator it = pendingChunks.iterator(); List<JSONArray> requests = new LinkedList<>(); JSONArray arr = new JSONArray(); while (it.hasNext()) { // key=guild_id, value=timeout it.advance(); if (System.currentTimeMillis() <= it.value()) continue; arr.put(it.key()); if (arr.length() == 50) { requests.add(arr); arr = new JSONArray(); } } if (arr.length() > 0) requests.add(arr); requests.forEach(GuildSetupController.this::sendChunkRequest); } } }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return the removed value, or null if it was not found in the map */ @Override public Long remove( Object key ) { if (! (key instanceof Long ) ) { return null; } long k = unwrapKey( key ); if ( _map.containsKey( k ) ) { long v = _map.remove( k ); return wrapValue( v ); } return null; }
public boolean adjustValue( long key, long amount ) { synchronized( mutex ) { return m.adjustValue( key, amount ); } } public long adjustOrPutValue( long key, long adjust_amount, long put_amount ) {
public long adjustOrPutValue( long key, long adjust_amount, long put_amount ) { synchronized( mutex ) { return m.adjustOrPutValue( key, adjust_amount, put_amount ); } }