private void rehash() { NameSet newSet = new NameSet(this.elementSize * 2); // double the number of expected elements char[] current; for (int i = this.names.length; --i >= 0;) if ((current = this.names[i]) != null) newSet.add(current); this.names = newSet.names; this.elementSize = newSet.elementSize; this.threshold = newSet.threshold; }
keepers[index++] = internedNames.add(name);
public char[] add(char[] name) { int length = this.names.length; int index = CharOperation.hashCode(name) % length; char[] current; while ((current = this.names[index]) != null) { if (CharOperation.equals(current, name)) return current; if (++index == length) index = 0; } this.names[index] = name; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return name; }
private static char[][] internSimpleNames(char[][] simpleNames, boolean removeWellKnown) { if (simpleNames == null) return EmptySimpleNames; int length = simpleNames.length; if (length == 0) return EmptySimpleNames; char[][] keepers = new char[length][]; int index = 0; next: for (int i = 0; i < length; i++) { char[] name = simpleNames[i]; int sLength = name.length; for (int j = 0, m = WellKnownSimpleNames.length; j < m; j++) { char[] wellKnownName = WellKnownSimpleNames[j]; if (sLength > wellKnownName.length) break; // all remaining well known names are shorter if (CharOperation.equals(name, wellKnownName)) { if (!removeWellKnown) keepers[index++] = WellKnownSimpleNames[j]; continue next; } } // InternedSimpleNames[0] is for the rest (> 29) // InternedSimpleNames[1] is for size 1... // InternedSimpleNames[29] is for size 29 NameSet internedNames = InternedSimpleNames[sLength < MaxSimpleNames ? sLength : 0]; keepers[index++] = internedNames.add(name); } if (length > index) { if (index == 0) return EmptySimpleNames; System.arraycopy(keepers, 0, keepers = new char[index][], 0, index); } return keepers; }
public char[] add(char[] name) { int length = this.names.length; int index = CharOperation.hashCode(name) % length; char[] current; while ((current = this.names[index]) != null) { if (CharOperation.equals(current, name)) return current; if (++index == length) index = 0; } this.names[index] = name; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return name; }
private void rehash() { NameSet newSet = new NameSet(this.elementSize * 2); // double the number of expected elements char[] current; for (int i = this.names.length; --i >= 0;) if ((current = this.names[i]) != null) newSet.add(current); this.names = newSet.names; this.elementSize = newSet.elementSize; this.threshold = newSet.threshold; }
keepers[index++] = internedNames.add(name);
public char[] add(char[] name) { int length = this.names.length; int index = CharOperation.hashCode(name) % length; char[] current; while ((current = this.names[index]) != null) { if (CharOperation.equals(current, name)) return current; if (++index == length) index = 0; } this.names[index] = name; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return name; }
private void rehash() { NameSet newSet = new NameSet(this.elementSize * 2); // double the number of expected elements char[] current; for (int i = this.names.length; --i >= 0;) if ((current = this.names[i]) != null) newSet.add(current); this.names = newSet.names; this.elementSize = newSet.elementSize; this.threshold = newSet.threshold; }
keepers[index++] = internedNames.add(name);
public char[] add(char[] name) { int length = this.names.length; int index = CharOperation.hashCode(name) % length; char[] current; while ((current = this.names[index]) != null) { if (CharOperation.equals(current, name)) return current; if (++index == length) index = 0; } this.names[index] = name; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return name; }
private void rehash() { NameSet newSet = new NameSet(this.elementSize * 2); // double the number of expected elements char[] current; for (int i = this.names.length; --i >= 0;) if ((current = this.names[i]) != null) newSet.add(current); this.names = newSet.names; this.elementSize = newSet.elementSize; this.threshold = newSet.threshold; }
private static char[][] internSimpleNames(char[][] simpleNames, boolean removeWellKnown) { if (simpleNames == null) return EmptySimpleNames; int length = simpleNames.length; if (length == 0) return EmptySimpleNames; char[][] keepers = new char[length][]; int index = 0; next: for (int i = 0; i < length; i++) { char[] name = simpleNames[i]; int sLength = name.length; for (int j = 0, m = WellKnownSimpleNames.length; j < m; j++) { char[] wellKnownName = WellKnownSimpleNames[j]; if (sLength > wellKnownName.length) break; // all remaining well known names are shorter if (CharOperation.equals(name, wellKnownName)) { if (!removeWellKnown) keepers[index++] = WellKnownSimpleNames[j]; continue next; } } // InternedSimpleNames[0] is for the rest (> 29) // InternedSimpleNames[1] is for size 1... // InternedSimpleNames[29] is for size 29 NameSet internedNames = InternedSimpleNames[sLength < MaxSimpleNames ? sLength : 0]; keepers[index++] = internedNames.add(name); } if (length > index) { if (index == 0) return EmptySimpleNames; System.arraycopy(keepers, 0, keepers = new char[index][], 0, index); } return keepers; }
public char[] add(char[] name) { int length = this.names.length; int index = CharOperation.hashCode(name) % length; char[] current; while ((current = this.names[index]) != null) { if (CharOperation.equals(current, name)) return current; if (++index == length) index = 0; } this.names[index] = name; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return name; }
private void rehash() { NameSet newSet = new NameSet(this.elementSize * 2); // double the number of expected elements char[] current; for (int i = this.names.length; --i >= 0;) if ((current = this.names[i]) != null) newSet.add(current); this.names = newSet.names; this.elementSize = newSet.elementSize; this.threshold = newSet.threshold; }
keepers[index++] = internedNames.add(name);
public char[] add(char[] name) { int length = this.names.length; int index = CharOperation.hashCode(name) % length; char[] current; while ((current = this.names[index]) != null) { if (CharOperation.equals(current, name)) return current; if (++index == length) index = 0; } this.names[index] = name; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return name; }
private void rehash() { NameSet newSet = new NameSet(this.elementSize * 2); // double the number of expected elements char[] current; for (int i = this.names.length; --i >= 0;) if ((current = this.names[i]) != null) newSet.add(current); this.names = newSet.names; this.elementSize = newSet.elementSize; this.threshold = newSet.threshold; }
keepers[index++] = internedNames.add(name);
keepers[index++] = internedNames.add(name);