public ChunkColumn getChunkAt( int x, int z ) { this.chunkLock.readLock().lock(); try { int i = x / 16; if ( x < 0 ) { i--; } int j = z / 16; if ( z < 0 ) { j--; } TByteObjectMap<ChunkColumn> map = this.columns.get( (byte) i ); if ( map == null ) { return null; } return map.get( (byte) j ); } finally { this.chunkLock.readLock().unlock(); } }
private void generateColumn( int x, int z ) { this.chunkLock.writeLock().lock(); try { ChunkColumn chunkColumnColumn = new ChunkColumn( x, z, this ); for ( int i = 0; i < chunkColumnColumn.getSections().length; i++ ) { ChunkSection section = new ChunkSection( chunkColumnColumn ); chunkColumnColumn.getSections()[i] = section; } this.generator.generate( chunkColumnColumn ); TByteObjectMap<ChunkColumn> c = this.columns.get( (byte) x ); if ( c == null ) { this.columns.put( (byte) x, c = new TByteObjectHashMap<>() ); } c.put( (byte) z, chunkColumnColumn ); } finally { this.chunkLock.writeLock().unlock(); } }
public List<ChunkColumn> getColumns() { List<ChunkColumn> list = new ArrayList<>(); this.chunkLock.readLock().lock(); try { this.columns.forEachValue( new TObjectProcedure<TByteObjectMap<ChunkColumn>>() { @Override public boolean execute( TByteObjectMap<ChunkColumn> value ) { list.addAll( value.valueCollection() ); return true; } } ); } finally { this.chunkLock.readLock().unlock(); } return list; }
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( ! ( other instanceof TByteObjectMap ) ) { return false; } TByteObjectMap that = ( TByteObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TByteObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); byte 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 void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // MAP //noinspection unchecked _map = ( TByteObjectMap<V> ) in.readObject(); }
/** {@inheritDoc} */ @Override @SuppressWarnings("rawtypes") public boolean equals( Object other ) { if ( ! ( other instanceof TByteObjectMap ) ) { return false; } TByteObjectMap that = ( TByteObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TByteObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); byte 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 @SuppressWarnings("unchecked") public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // MAP //noinspection unchecked _map = ( TByteObjectMap<V> ) in.readObject(); }
/** {@inheritDoc} */ public void putAll( TByteObjectMap<? extends V> map ){ map.forEachEntry( PUT_ALL_PROC ); }
/** {@inheritDoc} */ @Override public void putAll( TByteObjectMap<? extends V> map ){ map.forEachEntry( PUT_ALL_PROC ); }
/** {@inheritDoc} */ public void putAll( TByteObjectMap<V> map ){ map.forEachEntry( PUT_ALL_PROC ); }
public TByteObjectMap<V> getMap() { return container; }
public TByteObjectMap<String> getMap() { return container; }
/** * Creates a new <code>TByteObjectHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>TByteObjectMap</tt> to be copied. */ public TByteObjectHashMap( TByteObjectMap<? extends V> map ) { this( map.size(), 0.5f, map.getNoEntryKey() ); putAll( map ); }
/** * Creates a wrapper that decorates the specified primitive map. * * @param map the <tt>TByteObjectMap</tt> to wrap. */ public TByteObjectMapDecorator( TByteObjectMap<V> map ) { super(); this._map = map; }
/** * Returns a reference to the map wrapped by this decorator. * * @return the wrapped <tt>TByteObjectMap</tt> instance. */ public TByteObjectMap<V> getMap() { return _map; }