@SuppressWarnings("unchecked") public static <K, V> Map<K, V> expandForNextKey(Map<K, V> orig, K newElem) { if (orig instanceof CompactMap<?, ?>) { return ((CompactMap<K, V>)orig).expandForNextKeyIfNeeded(newElem); } else if (orig == NO_CONTENT) { return createMap(1); } else { return orig; } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() < 16 || containsKey(newElem)) { return this; } return new TinyHashMap32<K, V>(this); } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() < 128 || containsKey(newElem)) { return this; } return new TinyHashMap<K, V>(this); } }
/** Set the token text for this node */ @Override public void setText(String text_) { text = TextCache.getManager().getString(text_); }
/** Creates a new instance of APTFileNode */ public APTFileNode(FileSystem fileSystem, CharSequence path) { Parameters.notNull("null fileSystem", fileSystem); //NOI18N this.fileSystem = fileSystem; this.path = FilePathCache.getManager().getString(path); this.guard = TextCache.getManager().getString(guard); tokenized = true; }
private static CharSequence getCanonicalKey(FileObject fileObject, CharSequence fileKey) { try { CharSequence res = CndFileUtils.getCanonicalPath(fileObject); res = FilePathCache.getManager().getString(res); if (fileKey.equals(res)) { return fileKey; } return res; } catch (IOException e) { // skip exception return fileKey; } }
@Override public final CharSequence getString(CharSequence text) { return getDelegate(text).getString(text); }
TinyArrayMap(TinyTwoValuesMap<K, V> twoValues, int capacity) { assert capacity >= 2; keyValues = new Object[capacity*2]; this.size = twoValues.size(); int index = 0; this.keyValues[index++] = twoValues.getFirstKey(); this.keyValues[index++] = twoValues.getFirstValue(); this.keyValues[index++] = twoValues.getSecondKey(); this.keyValues[index] = twoValues.getSecondValue(); }
@SuppressWarnings("unchecked") private void freeze() { if (storage instanceof Map<?,?>) { if (storage != EMPTY) { Object[] arr = compact((Map<CharSequence,Object>)storage); storage = cacheHolder(new Holder(arr)); } } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() <= 3 || containsKey(newElem)) { return this; } return new TinyMap6<K, V>(this); } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() <= 5 || containsKey(newElem)) { return this; } return new TinyMap8<K, V>(this); } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() < 64 || containsKey(newElem)) { return this; } return new TinyHashMap128<K, V>(this); } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() <= 7 || containsKey(newElem)) { return this; } return new TinyMap16<K, V>(this); } }
@Override public Map<K, V> expandForNextKeyIfNeeded(K newElem) { if (size() < 32 || containsKey(newElem)) { return this; } return new TinyHashMap64<K, V>(this); } }
protected MapSnapshot(MapSnapshot<V> parent) { storage = EMPTY; assert (parent == null || parent.parent == null || !parent.parent.isEmpty()) : "how grand father could be empty " + parent; // optimization to prevent chaining of empty snapshots while (parent != null && parent.isEmpty()) { parent = parent.parent; } this.parent = parent; if (this.parent != null) { this.parent.freeze(); } }
@Override public V get(Object aKey) { assert aKey != null; int index = indexForKey(aKey); if (index >= 0) { @SuppressWarnings("unchecked") V val = (V) keyValues[index+1]; return val; } return null; }
@Override public final void setText(String t) { text = TextCache.getManager().getString(t); }
@Override public final void setTextID(CharSequence textID) { this.text = TextCache.getManager().getString(textID); }
@Override public final void setTextID(CharSequence textID) { this.text = TextCache.getManager().getString(textID); }
@Override public final void setText(String t) { text = TextCache.getManager().getString(t); }