/** true if the <code>len</code> chars of <code>text</code> starting at <code>off</code> * are in the {@link #keySet()} */ public boolean containsKey(char[] text, int off, int len) { return keys[getSlot(text, off, len)] != null; }
/** true if the <code>len</code> chars of <code>text</code> starting at <code>off</code> * are in the {@link #keySet()} */ public boolean containsKey(char[] text, int off, int len) { return keys[getSlot(text, off, len)] != null; }
/** true if the <code>CharSequence</code> is in the {@link #keySet()} */ public boolean containsKey(CharSequence cs) { return keys[getSlot(cs)] != null; }
/** true if the <code>CharSequence</code> is in the {@link #keySet()} */ public boolean containsKey(CharSequence cs) { return keys[getSlot(cs)] != null; }
/** returns the value of the mapping of the chars inside this {@code CharSequence} */ public V get(CharSequence cs) { return values[getSlot(cs)]; }
/** returns the value of the mapping of <code>len</code> chars of <code>text</code> * starting at <code>off</code> */ public V get(char[] text, int off, int len) { return values[getSlot(text, off, len)]; }
/** returns the value of the mapping of <code>len</code> chars of <code>text</code> * starting at <code>off</code> */ public V get(char[] text, int off, int len) { return values[getSlot(text, off, len)]; }
/** returns the value of the mapping of the chars inside this {@code CharSequence} */ public V get(CharSequence cs) { return values[getSlot(cs)]; }
@SuppressWarnings("unchecked") private void rehash() { assert keys.length == values.length; final int newSize = 2*keys.length; final char[][] oldkeys = keys; final V[] oldvalues = values; keys = new char[newSize][]; values = (V[]) new Object[newSize]; for(int i=0; i<oldkeys.length; i++) { char[] text = oldkeys[i]; if (text != null) { // todo: could be faster... no need to compare strings on collision final int slot = getSlot(text,0,text.length); keys[slot] = text; values[slot] = oldvalues[i]; } } }
@SuppressWarnings("unchecked") private void rehash() { assert keys.length == values.length; final int newSize = 2*keys.length; final char[][] oldkeys = keys; final V[] oldvalues = values; keys = new char[newSize][]; values = (V[]) new Object[newSize]; for(int i=0; i<oldkeys.length; i++) { char[] text = oldkeys[i]; if (text != null) { // todo: could be faster... no need to compare strings on collision final int slot = getSlot(text,0,text.length); keys[slot] = text; values[slot] = oldvalues[i]; } } }
/** Add the given mapping. * If ignoreCase is true for this Set, the text array will be directly modified. * The user should never modify this text array after calling this method. */ public V put(char[] text, V value) { if (ignoreCase) for(int i=0;i<text.length;){ i += Character.toChars( Character.toLowerCase( charUtils.codePointAt(text, i)), text, i); } int slot = getSlot(text, 0, text.length); if (keys[slot] != null) { final V oldValue = values[slot]; values[slot] = value; return oldValue; } keys[slot] = text; values[slot] = value; count++; if (count + (count>>2) > keys.length) { rehash(); } return null; }
/** Add the given mapping. * If ignoreCase is true for this Set, the text array will be directly modified. * The user should never modify this text array after calling this method. */ public V put(char[] text, V value) { if (ignoreCase) { charUtils.toLowerCase(text, 0, text.length); } int slot = getSlot(text, 0, text.length); if (keys[slot] != null) { final V oldValue = values[slot]; values[slot] = value; return oldValue; } keys[slot] = text; values[slot] = value; count++; if (count + (count>>2) > keys.length) { rehash(); } return null; }