/** {@inheritDoc} */ public double[] toArray() { return TDoubleIntHashMap.this.keys(); }
/** {@inheritDoc} */ public void putAll( Map<? extends Double, ? extends Integer> map ) { ensureCapacity( map.size() ); // could optimize this for cases when map instanceof THashMap for ( Map.Entry<? extends Double, ? extends Integer> entry : map.entrySet() ) { this.put( entry.getKey().doubleValue(), entry.getValue().intValue() ); } }
/** {@inheritDoc} */ public boolean increment( double key ) { return adjustValue( key, ( int ) 1 ); }
/** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { double key = in.readDouble(); int val = in.readInt(); put(key, val); } } } // TDoubleIntHashMap
/** {@inheritDoc} */ public boolean containsAll( int[] array ) { for ( int element : array ) { if ( ! TDoubleIntHashMap.this.containsValue( element ) ) { return false; } } return true; }
double max = - Double.MAX_VALUE; TDoubleIntHashMap hist = new TDoubleIntHashMap(samples.length); for (int i = 0; i < samples.length; i++) { hist.adjustOrPutValue(samples[i], 1, 1); min = Math.min(min, samples[i]); max = Math.max(max, samples[i]); double keys[] = hist.keys(); Arrays.sort(keys); borders = new TDoubleArrayList(keys.length); int n = 0; for (int i = 0; i < keys.length; i++) { int nBin = hist.get(keys[i]); binsize += nBin; n += nBin;
/** {@inheritDoc} */ public boolean containsAll( double[] array ) { for ( double element : array ) { if ( ! TDoubleIntHashMap.this.contains( element ) ) { return false; } } return true; }
/** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( element instanceof Double ) { double ele = ( ( Double ) element ).doubleValue(); if ( ! TDoubleIntHashMap.this.containsKey( ele ) ) { return false; } } else { return false; } } return true; }
/** {@inheritDoc} */ public void clear() { TDoubleIntHashMap.this.clear(); }
/** * Creates a new <code>TDoubleIntHashMap</code> instance containing * all of the entries in the map passed in. * * @param keys a <tt>double</tt> array containing the keys for the matching values. * @param values a <tt>int</tt> array containing the values. */ public TDoubleIntHashMap( double[] keys, int[] values ) { super( Math.max( keys.length, values.length ) ); int size = Math.min( keys.length, values.length ); for ( int i = 0; i < size; i++ ) { this.put( keys[i], values[i] ); } }
/** {@inheritDoc} */ public boolean forEachKey( TDoubleProcedure procedure ) { return forEach( procedure ); }
/** {@inheritDoc} */ public int putIfAbsent( double key, int value ) { int index = insertionIndex( key ); if (index < 0) return _values[-index - 1]; return doPut( key, value, index ); }
/** {@inheritDoc} */ public boolean contains( int entry ) { return TDoubleIntHashMap.this.containsValue( entry ); }
/** {@inheritDoc} */ public boolean contains( double entry ) { return TDoubleIntHashMap.this.contains( entry ); }
/** {@inheritDoc} */ public boolean containsAll( TDoubleCollection collection ) { TDoubleIterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! TDoubleIntHashMap.this.containsKey( iter.next() ) ) { return false; } } return true; }
/** {@inheritDoc} */ public void clear() { TDoubleIntHashMap.this.clear(); }
/** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { double key = in.readDouble(); int val = in.readInt(); put(key, val); } } } // TDoubleIntHashMap
/** * Creates a new <code>TDoubleIntHashMap</code> instance containing * all of the entries in the map passed in. * * @param keys a <tt>double</tt> array containing the keys for the matching values. * @param values a <tt>int</tt> array containing the values. */ public TDoubleIntHashMap( double[] keys, int[] values ) { super( Math.max( keys.length, values.length ) ); int size = Math.min( keys.length, values.length ); for ( int i = 0; i < size; i++ ) { this.put( keys[i], values[i] ); } }