/** * Empties the map. */ public void clear() { this._map.clear(); }
/** * 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 Short get( Object key ) { int k; if ( key != null ) { if ( key instanceof Integer ) { k = unwrapKey( key ); } else { return null; } } else { k = _map.getNoEntryKey(); } short 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 ); } }
/** * 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 Short(0) if none was found. */ public Short put( Integer key, Short value ) { int k; short v; if ( key == null ) { k = _map.getNoEntryKey(); } else { k = unwrapKey( key ); } if ( value == null ) { v = _map.getNoEntryValue(); } else { v = unwrapValue( value ); } short retval = _map.put( k, v ); if ( retval == _map.getNoEntryValue() ) { return null; } return wrapValue( retval ); }
/** * 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 Integer && _map.containsKey( unwrapKey( key ) ); }
/** * 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 Short remove( Object key ) { int k; if ( key != null ) { if ( key instanceof Integer ) { k = unwrapKey( key ); } else { return null; } } else { k = _map.getNoEntryKey(); } short 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 ); } }
@Override public final long setLong(int index, long value) { this.checkBounds(index, length); final long oldValue = getLong(index); if (value == defaultValueAsLong) { this.values.remove(index); this.zoneIds.remove(index); return oldValue; } else { final short zoneId = zoneIds.get(index); this.values.put(index, value); this.zoneIds.put(index, zoneId != NULL_ZONE ? zoneId : UTC_ZONE); return oldValue; } }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TIntShortMap ) ) { return false; } TIntShortMap that = ( TIntShortMap ) other; if ( that.size() != this.size() ) { return false; } short[] values = _values; byte[] states = _states; short this_no_entry_value = getNoEntryValue(); short that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { int key = _set[i]; short that_value = that.get( key ); short 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; }
@Override() public final Array<ZonedDateTime> copy(int[] indexes) { final SparseArrayOfZonedDateTimes clone = new SparseArrayOfZonedDateTimes(indexes.length, defaultValue); for (int i = 0; i < indexes.length; ++i) { final long value = getLong(indexes[i]); if (value != defaultValueAsLong) { clone.values.put(i, value); clone.zoneIds.put(i, this.zoneIds.get(i)); } } return clone; }
public boolean containsValue( short value ){ synchronized( mutex ) { return m.containsValue( value ); } } public short get( int key ) {
public short get( int key ) { synchronized( mutex ) { return m.get( key ); } }
public boolean forEachEntry( TIntShortProcedure procedure ) { synchronized( mutex ) { return m.forEachEntry( procedure ); } } public void transformValues( TShortFunction function ) {
public boolean forEachKey( TIntProcedure procedure ) { return m.forEachKey( procedure ); } public boolean forEachValue( TShortProcedure procedure ) {
public short put( int key, short value ) { synchronized( mutex ) { return m.put( key, value ); } } public short remove( int key ) {
public boolean containsKey( int key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( short value ){
public short remove( int key ) { synchronized( mutex ) { return m.remove( key ); } } public void putAll( Map<? extends Integer, ? extends Short> map ) {
@Override public Array<ZonedDateTime> fill(ZonedDateTime value, int start, int end) { final long fillValue = value != null ? value.toInstant().toEpochMilli() : nullValue; if (fillValue == defaultValueAsLong) { this.values.clear(); this.zoneIds.clear(); } else { final short fillZoneId = value != null ? zoneIdMap1.get(value.getZone()) : NULL_ZONE; for (int i=start; i<end; ++i) { this.values.put(i, fillValue); this.zoneIds.put(i, fillZoneId); } } return this; }
@Override public final ZonedDateTime setValue(int index, ZonedDateTime value) { this.checkBounds(index, length); final ZonedDateTime oldValue = getValue(index); final long valueAsLong = value == null ? nullValue : value.toInstant().toEpochMilli(); if (valueAsLong == defaultValueAsLong) { this.values.remove(index); this.zoneIds.remove(index); return oldValue; } else { final short zoneId = value == null ? NULL_ZONE : zoneIdMap1.get(value.getZone()); this.values.put(index, valueAsLong); this.zoneIds.put(index, zoneId); return oldValue; } }
public boolean adjustValue( int key, short amount ) { synchronized( mutex ) { return m.adjustValue( key, amount ); } } public short adjustOrPutValue( int key, short adjust_amount, short put_amount ) {
public short adjustOrPutValue( int key, short adjust_amount, short put_amount ) { synchronized( mutex ) { return m.adjustOrPutValue( key, adjust_amount, put_amount ); } }
/** * 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 Short remove( Object key ) { if (! (key instanceof Integer ) ) { return null; } int k = unwrapKey( key ); if ( _map.containsKey( k ) ) { short v = _map.remove( k ); return wrapValue( v ); } return null; }