public String toString(){ String s = ""; s += "char type number:\t" + charfreq.size()+"\n"; s += "char number:\t" + charnum+"\n"; return s; }
/** {@inheritDoc} */ public boolean increment( char key ) { return adjustValue( key, ( int ) 1 ); }
/** {@inheritDoc} */ public void clear() { TCharIntHashMap.this.clear(); }
/** {@inheritDoc} */ public void putAll( Map<? extends Character, ? extends Integer> map ) { ensureCapacity( map.size() ); // could optimize this for cases when map instanceof THashMap for ( Map.Entry<? extends Character, ? extends Integer> entry : map.entrySet() ) { this.put( entry.getKey().charValue(), entry.getValue().intValue() ); } }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TCharIntMap ) ) { return false; } TCharIntMap that = ( TCharIntMap ) other; if ( that.size() != this.size() ) { return false; } int[] values = _values; byte[] states = _states; int this_no_entry_value = getNoEntryValue(); int that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { char key = _set[i]; int that_value = that.get( key ); int 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; }
/** {@inheritDoc} */ public boolean containsAll( char[] array ) { for ( char element : array ) { if ( ! TCharIntHashMap.this.contains( element ) ) { return false; } } return true; }
/** {@inheritDoc} */ public boolean containsAll( int[] array ) { for ( int element : array ) { if ( ! TCharIntHashMap.this.containsValue( element ) ) { return false; } } return true; }
/** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( element instanceof Character ) { char ele = ( ( Character ) element ).charValue(); if ( ! TCharIntHashMap.this.containsKey( ele ) ) { return false; } } else { return false; } } return true; }
/** {@inheritDoc} */ public boolean forEachKey( TCharProcedure procedure ) { return forEach( procedure ); }
/** {@inheritDoc} */ @Override public String toString() { final StringBuilder buf = new StringBuilder( "{" ); forEachEntry( new TCharIntProcedure() { private boolean first = true; public boolean execute( char key, int value ) { if ( first ) first = false; else buf.append( ", " ); buf.append(key); buf.append("="); buf.append(value); return true; } }); buf.append( "}" ); return buf.toString(); }
/** {@inheritDoc} */ public int putIfAbsent( char key, int value ) { int index = insertionIndex( key ); if (index < 0) return _values[-index - 1]; return doPut( key, value, index ); }
/** {@inheritDoc} */ public void putAll( TCharIntMap map ) { ensureCapacity( map.size() ); TCharIntIterator iter = map.iterator(); while ( iter.hasNext() ) { iter.advance(); this.put( iter.key(), iter.value() ); } }
/** {@inheritDoc} */ public boolean containsKey( char key ) { return contains( key ); }
/** {@inheritDoc} */ public boolean contains( int entry ) { return TCharIntHashMap.this.containsValue( entry ); }
/** {@inheritDoc} */ public boolean containsAll( TCharCollection collection ) { TCharIterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! TCharIntHashMap.this.containsKey( iter.next() ) ) { return false; } } return true; }
/** {@inheritDoc} */ @Override public boolean forEachKey( TCharProcedure procedure ) { return forEach( procedure ); }
/** {@inheritDoc} */ @Override public String toString() { final StringBuilder buf = new StringBuilder( "{" ); forEachEntry( new TCharIntProcedure() { private boolean first = true; public boolean execute( char key, int value ) { if ( first ) first = false; else buf.append( ", " ); buf.append(key); buf.append("="); buf.append(value); return true; } }); buf.append( "}" ); return buf.toString(); }
/** {@inheritDoc} */ public int put( char key, int value ) { int index = insertionIndex( key ); return doPut( key, value, index ); }