Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2001-06-27 11:24:31 +0000
committerPhilipe Mulet2001-06-27 11:24:31 +0000
commitb04602938404af4f8569a399fb36a5018768a262 (patch)
tree825ad6b961f7154999c39056a39221f9c08adfd2 /org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util
parent673b7eda95cd26449992e862f0c63f2c612903a0 (diff)
downloadeclipse.jdt.core-b04602938404af4f8569a399fb36a5018768a262.tar.gz
eclipse.jdt.core-b04602938404af4f8569a399fb36a5018768a262.tar.xz
eclipse.jdt.core-b04602938404af4f8569a399fb36a5018768a262.zip
externalization in progress
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java1073
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java137
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java148
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java148
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java149
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java117
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java104
7 files changed, 859 insertions, 1017 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
index 43117f6d56..e95120a140 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
@@ -7,635 +7,542 @@ package org.eclipse.jdt.internal.compiler.util;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
public final class CharOperation {
- public static final char[][] arrayConcat(char[][] first, char[][] second) {
- if (first == null)
- return second;
- if (second == null)
- return first;
-
- int length1 = first.length;
- int length2 = second.length;
- char[][] result = new char[length1 + length2][];
- /* if we do not trust System.arraycopy on our VM with char[][]'s
- int i;
- for (i = 0; i < length1; i++)
- result[i] = first[i];
- for (int j = 0; j < length2; j++)
- result[i++] = second[j];
- */
- System.arraycopy(first, 0, result, 0, length1);
- System.arraycopy(second, 0, result, length1, length2);
- return result;
- }
-
- public static final char[][] arrayConcat(char[][] first, char[] second) {
- if (second == null)
- return first;
- if (first == null)
- return new char[][] { second };
-
- int length = first.length;
- char[][] result = new char[length + 1][];
- /* if we do not trust System.arraycopy on our VM with char[][]'s
- for (int i = 0; i < length; i++)
- result[i] = first[i];
- */
- System.arraycopy(first, 0, result, 0, length);
- result[length] = second;
- return result;
- }
-
- public static final char[] concat(char[] first, char[] second) {
- if (first == null)
- return second;
- if (second == null)
- return first;
-
- int length1 = first.length;
- int length2 = second.length;
- char[] result = new char[length1 + length2];
- System.arraycopy(first, 0, result, 0, length1);
- System.arraycopy(second, 0, result, length1, length2);
- return result;
- }
-
- public static final char[] concat(char[] first, char[] second, char[] third) {
- if (first == null)
- return concat(second, third);
- if (second == null)
- return concat(first, third);
- if (third == null)
- return concat(first, second);
-
- int length1 = first.length;
- int length2 = second.length;
- int length3 = third.length;
- char[] result = new char[length1 + length2 + length3];
- System.arraycopy(first, 0, result, 0, length1);
- System.arraycopy(second, 0, result, length1, length2);
- System.arraycopy(third, 0, result, length1 + length2, length3);
- return result;
- }
-
- public static final char[] concat(
- char[] first,
- char[] second,
- char separator) {
- if (first == null)
- return second;
- if (second == null)
- return first;
-
- int length1 = first.length;
- if (length1 == 0)
- return second;
- int length2 = second.length;
- if (length2 == 0)
- return first;
-
- char[] result = new char[length1 + length2 + 1];
- System.arraycopy(first, 0, result, 0, length1);
- result[length1] = separator;
- System.arraycopy(second, 0, result, length1 + 1, length2);
- return result;
- }
-
- public static final char[] concat(
- char[] first,
- char sep1,
- char[] second,
- char sep2,
- char[] third) {
- if (first == null)
- return concat(second, third, sep2);
- if (second == null)
- return concat(first, third, sep1);
- if (third == null)
- return concat(first, second, sep1);
-
- int length1 = first.length;
- int length2 = second.length;
- int length3 = third.length;
- char[] result = new char[length1 + length2 + length3 + 2];
- System.arraycopy(first, 0, result, 0, length1);
- result[length1] = sep1;
- System.arraycopy(second, 0, result, length1 + 1, length2);
- result[length1 + length2 + 1] = sep2;
- System.arraycopy(third, 0, result, length1 + length2 + 2, length3);
- return result;
- }
-
- public static final char[] concat(char prefix, char[] array, char suffix) {
- if (array == null)
- return new char[] { prefix, suffix };
-
- int length = array.length;
- char[] result = new char[length + 2];
- result[0] = prefix;
- System.arraycopy(array, 0, result, 1, length);
- result[length + 1] = suffix;
- return result;
- }
-
- public static final char[] concatWith(
- char[][] array,
- char[] name,
- char separator) {
- int nameLength = name == null ? 0 : name.length;
- if (nameLength == 0)
- return concatWith(array, separator);
-
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return name;
-
- int size = nameLength;
- int index = length;
- while (--index >= 0)
- if (array[index].length > 0)
- size += array[index].length + 1;
- char[] result = new char[size];
- index = 0;
- for (int i = 0; i < length; i++) {
- int subLength = array[i].length;
- if (subLength > 0) {
- System.arraycopy(array[i], 0, result, index, subLength);
- index += subLength;
- result[index++] = separator;
- }
- }
- System.arraycopy(name, 0, result, index, nameLength);
- return result;
- }
-
- public static final char[] concatWith(char[][] array, char separator) {
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return TypeConstants.NoChar;
-
- int size = length - 1;
- int index = length;
- while (--index >= 0) {
- if (array[index].length == 0)
- size--;
- else
- size += array[index].length;
- }
- if (size <= 0)
- return TypeConstants.NoChar;
- char[] result = new char[size];
- index = length;
- while (--index >= 0) {
- length = array[index].length;
- if (length > 0) {
- System.arraycopy(array[index], 0, result, (size -= length), length);
- if (--size >= 0)
- result[size] = separator;
- }
+public static final char[][] arrayConcat(char[][] first, char[][] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ int length2 = second.length;
+ char[][] result = new char[length1 + length2][];
+/* if we do not trust System.arraycopy on our VM with char[][]'s
+ int i;
+ for (i = 0; i < length1; i++)
+ result[i] = first[i];
+ for (int j = 0; j < length2; j++)
+ result[i++] = second[j];
+*/
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+}
+public static final char[][] arrayConcat(char[][] first, char[] second) {
+ if (second == null)
+ return first;
+ if (first == null)
+ return new char[][] {second};
+
+ int length = first.length;
+ char[][] result = new char[length + 1][];
+/* if we do not trust System.arraycopy on our VM with char[][]'s
+ for (int i = 0; i < length; i++)
+ result[i] = first[i];
+*/
+ System.arraycopy(first, 0, result, 0, length);
+ result[length] = second;
+ return result;
+}
+public static final char[] concat(char[] first, char[] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ int length2 = second.length;
+ char[] result = new char[length1 + length2];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+}
+public static final char[] concat(char[] first, char[] second, char[] third) {
+ if (first == null)
+ return concat(second, third);
+ if (second == null)
+ return concat(first, third);
+ if (third == null)
+ return concat(first, second);
+
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ System.arraycopy(third, 0, result, length1 + length2, length3);
+ return result;
+}
+public static final char[] concat(char[] first, char[] second, char separator) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ if (length1 == 0)
+ return second;
+ int length2 = second.length;
+ if (length2 == 0)
+ return first;
+
+ char[] result = new char[length1 + length2 + 1];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = separator;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ return result;
+}
+public static final char[] concat(char[] first, char sep1, char[] second, char sep2, char[] third) {
+ if (first == null)
+ return concat(second, third, sep2);
+ if (second == null)
+ return concat(first, third, sep1);
+ if (third == null)
+ return concat(first, second, sep1);
+
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3 + 2];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = sep1;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ result[length1+length2+1] = sep2;
+ System.arraycopy(third, 0, result, length1 + length2 + 2, length3);
+ return result;
+}
+public static final char[] concat(char prefix, char[] array, char suffix) {
+ if (array == null)
+ return new char[] {prefix, suffix};
+
+ int length = array.length;
+ char[] result = new char[length + 2];
+ result[0] = prefix;
+ System.arraycopy(array, 0, result, 1, length);
+ result[length + 1] = suffix;
+ return result;
+}
+public static final char[] concatWith(char[][] array, char[] name, char separator) {
+ int nameLength = name == null ? 0 : name.length;
+ if (nameLength == 0)
+ return concatWith(array, separator);
+
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return name;
+
+ int size = nameLength;
+ int index = length;
+ while (--index >= 0)
+ if (array[index].length > 0)
+ size += array[index].length + 1;
+ char[] result = new char[size];
+ index = 0;
+ for (int i = 0; i < length; i++) {
+ int subLength = array[i].length;
+ if (subLength > 0) {
+ System.arraycopy(array[i], 0, result, index, subLength);
+ index += subLength;
+ result[index++] = separator;
}
- return result;
}
-
- public static final boolean contains(char character, char[][] array) {
- for (int i = array.length; --i >= 0;) {
- char[] subarray = array[i];
- for (int j = subarray.length; --j >= 0;)
- if (subarray[j] == character)
- return true;
+ System.arraycopy(name, 0, result, index, nameLength);
+ return result;
+}
+public static final char[] concatWith(char[][] array, char separator) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return TypeConstants.NoChar;
+
+ int size = length - 1;
+ int index = length;
+ while (--index >= 0) {
+ if (array[index].length == 0)
+ size--;
+ else
+ size += array[index].length;
+ }
+ if (size <= 0)
+ return TypeConstants.NoChar;
+ char[] result = new char[size];
+ index = length;
+ while (--index >= 0) {
+ length = array[index].length;
+ if (length > 0) {
+ System.arraycopy(array[index], 0, result, (size -= length), length);
+ if (--size >= 0)
+ result[size] = separator;
}
- return false;
}
-
- public static final boolean contains(char character, char[] array) {
- for (int i = array.length; --i >= 0;)
- if (array[i] == character)
+ return result;
+}
+public static final boolean contains(char character, char[][] array) {
+ for (int i = array.length; --i >= 0;) {
+ char[] subarray = array[i];
+ for (int j = subarray.length; --j >= 0;)
+ if (subarray[j] == character)
return true;
- return false;
}
-
- public static final char[][] deepCopy(char[][] toCopy) {
- int toCopyLength = toCopy.length;
- char[][] result = new char[toCopyLength][];
- for (int i = 0; i < toCopyLength; i++) {
- char[] toElement = toCopy[i];
- int toElementLength = toElement.length;
- char[] resultElement = new char[toElementLength];
- System.arraycopy(toElement, 0, resultElement, 0, toElementLength);
- result[i] = resultElement;
- }
- return result;
- }
-
- public static final boolean equals(char[][] first, char[][] second) {
- if (first == second)
+ return false;
+}
+public static final boolean contains(char character, char[] array) {
+ for (int i = array.length; --i >= 0;)
+ if (array[i] == character)
return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;)
- if (!equals(first[i], second[i]))
- return false;
+ return false;
+}
+public static final char[][] deepCopy(char[][] toCopy) {
+ int toCopyLength = toCopy.length;
+ char[][] result = new char[toCopyLength][];
+ for (int i = 0; i < toCopyLength; i++) {
+ char[] toElement = toCopy[i];
+ int toElementLength = toElement.length;
+ char[] resultElement = new char[toElementLength];
+ System.arraycopy(toElement, 0, resultElement, 0, toElementLength);
+ result[i] = resultElement;
+ }
+ return result;
+}
+public static final boolean equals(char[][] first, char[][] second) {
+ if (first == second)
return true;
- }
-
- public static final boolean equals(
- char[][] first,
- char[][] second,
- boolean isCaseSensitive) {
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
- if (isCaseSensitive) {
- return equals(first, second);
- }
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i]))
return false;
+ return true;
+}
+public static final boolean equals(char[][] first, char[][] second, boolean isCaseSensitive) {
- for (int i = first.length; --i >= 0;)
- if (!equals(first[i], second[i], false))
- return false;
- return true;
+ if (isCaseSensitive){
+ return equals(first, second);
}
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
- public static final boolean equals(char[] first, char[] second) {
- if (first == second)
- return true;
- if (first == null || second == null)
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i], false))
return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;)
- if (first[i] != second[i])
- return false;
+ return true;
+}
+public static final boolean equals(char[] first, char[] second) {
+ if (first == second)
return true;
- }
-
- public static final boolean equals(
- char[] first,
- char[] second,
- boolean isCaseSensitive) {
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
- if (isCaseSensitive) {
- return equals(first, second);
- }
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
+ for (int i = first.length; --i >= 0;)
+ if (first[i] != second[i])
return false;
+ return true;
+}
+public static final boolean equals(char[] first, char[] second, boolean isCaseSensitive) {
- for (int i = first.length; --i >= 0;)
- if (Character.toLowerCase(first[i]) != Character.toLowerCase(second[i]))
- return false;
- return true;
+ if (isCaseSensitive){
+ return equals(first, second);
}
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
- public static final boolean fragmentEquals(
- char[] fragment,
- char[] name,
- int startIndex,
- boolean isCaseSensitive) {
-
- int max = fragment.length;
- if (name.length < max + startIndex)
+ for (int i = first.length; --i >= 0;)
+ if (Character.toLowerCase(first[i]) != Character.toLowerCase(second[i]))
return false;
- if (isCaseSensitive) {
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (fragment[i] != name[i + startIndex])
- return false;
- return true;
- }
+ return true;
+}
+public static final boolean fragmentEquals(char[] fragment, char[] name, int startIndex, boolean isCaseSensitive) {
+
+ int max = fragment.length;
+ if (name.length < max+startIndex) return false;
+ if (isCaseSensitive){
for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (Character.toLowerCase(fragment[i])
- != Character.toLowerCase(name[i + startIndex]))
+ if (fragment[i] != name[i + startIndex])
return false;
return true;
}
-
- public static final int hashCode(char[] array) {
- int hash = 0;
- int offset = 0;
- int length = array.length;
- if (length < 16) {
- for (int i = length; i > 0; i--)
- hash = (hash * 37) + array[offset++];
- } else {
- // only sample some characters
- int skip = length / 8;
- for (int i = length; i > 0; i -= skip, offset += skip)
- hash = (hash * 39) + array[offset];
- }
- return hash & 0x7FFFFFFF;
- }
-
- public static final int indexOf(char toBeFound, char[] array) {
- for (int i = 0; i < array.length; i++)
- if (toBeFound == array[i])
- return i;
- return -1;
- }
-
- public static final int indexOf(char toBeFound, char[] array, int start) {
- for (int i = start; i < array.length; i++)
- if (toBeFound == array[i])
- return i;
- return -1;
- }
-
- public static final int lastIndexOf(char toBeFound, char[] array) {
- for (int i = array.length; --i >= 0;)
- if (toBeFound == array[i])
- return i;
- return -1;
- }
-
- public static final int lastIndexOf(
- char toBeFound,
- char[] array,
- int startIndex) {
- for (int i = array.length; --i >= startIndex;)
- if (toBeFound == array[i])
- return i;
- return -1;
- }
-
- public static final int lastIndexOf(
- char toBeFound,
- char[] array,
- int startIndex,
- int endIndex) {
- for (int i = endIndex; --i >= startIndex;)
- if (toBeFound == array[i])
- return i;
- return -1;
- }
-
- /**
- * Answer the last portion of a name given a separator
- * e.g. lastSegment("java.lang.Object".toCharArray(),'.') --> Object
- */
- final static public char[] lastSegment(char[] array, char separator) {
- int pos = lastIndexOf(separator, array);
- if (pos < 0)
- return array;
- return subarray(array, pos + 1, array.length);
- }
-
- /**
- * char[] pattern matching, accepting wild-cards '*'.
- *
- * When not case sensitive, the pattern is assumed to already be lowercased, the
- * name will be lowercased character per character as comparing.
- */
- public static final boolean match(
- char[] pattern,
- char[] name,
- boolean isCaseSensitive) {
-
- if (name == null)
- return false; // null name cannot match
- if (pattern == null)
- return true; // null pattern is equivalent to '*'
- int iPattern = 0, patternLength = pattern.length;
- int iName = 0, nameLength = name.length;
-
- /* check first segment */
- char patternChar = 0;
- while ((iPattern < patternLength)
- && (patternChar = pattern[iPattern]) != '*') {
- if (iName == nameLength)
- return false;
- if (patternChar
- != (isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName]))) {
- return false;
- }
- iName++;
- iPattern++;
+ for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
+ if (Character.toLowerCase(fragment[i]) != Character.toLowerCase(name[i + startIndex]))
+ return false;
+ return true;
+}
+public static final int hashCode(char[] array) {
+ int hash = 0;
+ int offset = 0;
+ int length = array.length;
+ if (length < 16) {
+ for (int i = length; i > 0; i--)
+ hash = (hash * 37) + array[offset++];
+ } else {
+ // only sample some characters
+ int skip = length / 8;
+ for (int i = length; i > 0; i -= skip, offset += skip)
+ hash = (hash * 39) + array[offset];
+ }
+ return hash & 0x7FFFFFFF;
+}
+public static final int indexOf(char toBeFound, char[] array) {
+ for (int i = 0; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+}
+public static final int indexOf(char toBeFound, char[] array, int start) {
+ for (int i = start; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+}
+public static final int lastIndexOf(char toBeFound, char[] array) {
+ for (int i = array.length; --i >= 0;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+}
+public static final int lastIndexOf(char toBeFound, char[] array, int startIndex) {
+ for (int i = array.length; --i >= startIndex;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+}
+public static final int lastIndexOf(char toBeFound, char[] array, int startIndex, int endIndex) {
+ for (int i = endIndex; --i >= startIndex;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+}
+/**
+ * Answer the last portion of a name given a separator
+ * e.g. lastSegment("java.lang.Object".toCharArray(),'.') --> Object
+ */
+final static public char[] lastSegment(char[] array, char separator) {
+ int pos = lastIndexOf(separator, array);
+ if (pos < 0) return array;
+ return subarray(array, pos+1, array.length);
+}
+/**
+ * char[] pattern matching, accepting wild-cards '*'.
+ *
+ * When not case sensitive, the pattern is assumed to already be lowercased, the
+ * name will be lowercased character per character as comparing.
+ */
+public static final boolean match(char[] pattern, char[] name, boolean isCaseSensitive) {
+
+ if (name == null) return false; // null name cannot match
+ if (pattern == null) return true; // null pattern is equivalent to '*'
+ int iPattern = 0, patternLength = pattern.length;
+ int iName = 0, nameLength = name.length;
+
+ /* check first segment */
+ char patternChar = 0;
+ while ((iPattern < patternLength) && (patternChar = pattern[iPattern]) != '*'){
+ if (iName == nameLength) return false;
+ if (patternChar != (isCaseSensitive
+ ? name[iName]
+ : Character.toLowerCase(name[iName]))){
+ return false;
}
- /* check sequence of star+segment */
- int segmentStart;
- if (patternChar == '*') {
- segmentStart = ++iPattern; // skip star
- } else {
- segmentStart = 0; // force iName check
+ iName++;
+ iPattern++;
+ }
+ /* check sequence of star+segment */
+ int segmentStart;
+ if (patternChar == '*'){
+ segmentStart = ++iPattern; // skip star
+ } else {
+ segmentStart = 0; // force iName check
+ }
+ int prefixStart = iName;
+ checkSegment: while (iName < nameLength && iPattern < patternLength){
+ /* segment is ending */
+ if ((patternChar = pattern[iPattern]) == '*'){
+ segmentStart = ++iPattern; // skip start
+ prefixStart = iName;
+ continue checkSegment;
}
- int prefixStart = iName;
- checkSegment : while (iName < nameLength && iPattern < patternLength) {
- /* segment is ending */
- if ((patternChar = pattern[iPattern]) == '*') {
- segmentStart = ++iPattern; // skip start
- prefixStart = iName;
- continue checkSegment;
- }
- /* chech current name character */
- if ((isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName]))
- != patternChar) {
- iPattern = segmentStart; // mismatch - restart current segment
- iName = ++prefixStart;
- continue checkSegment;
- }
- iName++;
- iPattern++;
+ /* chech current name character */
+ if ((isCaseSensitive
+ ? name[iName]
+ : Character.toLowerCase(name[iName]))!= patternChar){
+ iPattern = segmentStart; // mismatch - restart current segment
+ iName = ++prefixStart;
+ continue checkSegment;
}
-
- return (segmentStart == patternLength)
- || (iName == nameLength && iPattern == patternLength)
- || (iPattern == patternLength - 1 && pattern[iPattern] == '*');
- }
-
- public static final int occurencesOf(char toBeFound, char[] array) {
- int count = 0;
- for (int i = 0; i < array.length; i++)
- if (toBeFound == array[i])
- count++;
- return count;
+ iName++;
+ iPattern++;
}
- public static final int occurencesOf(char toBeFound, char[] array, int start) {
- int count = 0;
- for (int i = start; i < array.length; i++)
- if (toBeFound == array[i])
- count++;
- return count;
- }
-
- public static final boolean prefixEquals(char[] prefix, char[] name) {
+ return (segmentStart == patternLength)
+ || (iName == nameLength && iPattern == patternLength)
+ || (iPattern == patternLength - 1 && pattern[iPattern] == '*');
+}
+public static final int occurencesOf(char toBeFound, char[] array) {
+ int count = 0;
+ for (int i = 0; i < array.length; i++)
+ if (toBeFound == array[i]) count++;
+ return count;
+}
+public static final int occurencesOf(char toBeFound, char[] array, int start) {
+ int count = 0;
+ for (int i = start; i < array.length; i++)
+ if (toBeFound == array[i]) count++;
+ return count;
+}
+public static final boolean prefixEquals(char[] prefix, char[] name) {
- int max = prefix.length;
- if (name.length < max)
+ int max = prefix.length;
+ if (name.length < max) return false;
+ for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
+ if (prefix[i] != name[i])
return false;
+ return true;
+}
+public static final boolean prefixEquals(char[] prefix, char[] name, boolean isCaseSensitive) {
+
+ int max = prefix.length;
+ if (name.length < max) return false;
+ if (isCaseSensitive){
for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
if (prefix[i] != name[i])
return false;
return true;
}
-
- public static final boolean prefixEquals(
- char[] prefix,
- char[] name,
- boolean isCaseSensitive) {
-
- int max = prefix.length;
- if (name.length < max)
+
+ for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
+ if (Character.toLowerCase(prefix[i]) != Character.toLowerCase(name[i]))
return false;
- if (isCaseSensitive) {
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (prefix[i] != name[i])
- return false;
- return true;
- }
-
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (Character.toLowerCase(prefix[i]) != Character.toLowerCase(name[i]))
- return false;
- return true;
- }
-
- public static final void replace(
- char[] array,
- char toBeReplaced,
- char replacementChar) {
- if (toBeReplaced != replacementChar) {
- for (int i = 0, max = array.length; i < max; i++) {
- if (array[i] == toBeReplaced)
- array[i] = replacementChar;
- }
+ return true;
+}
+public static final void replace(
+ char[] array,
+ char toBeReplaced,
+ char replacementChar) {
+ if (toBeReplaced != replacementChar) {
+ for (int i = 0, max = array.length; i < max; i++) {
+ if (array[i] == toBeReplaced)
+ array[i] = replacementChar;
}
}
-
- public static final char[][] splitOn(char divider, char[] array) {
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return TypeConstants.NoCharChar;
-
- int wordCount = 1;
- for (int i = 0; i < length; i++)
- if (array[i] == divider)
- wordCount++;
- char[][] split = new char[wordCount][];
- int last = 0, currentWord = 0;
- for (int i = 0; i < length; i++) {
- if (array[i] == divider) {
- split[currentWord] = new char[i - last];
- System.arraycopy(array, last, split[currentWord++], 0, i - last);
- last = i + 1;
- }
+}
+public static final char[][] splitOn(char divider, char[] array) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return TypeConstants.NoCharChar;
+
+ int wordCount = 1;
+ for (int i = 0; i < length; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = 0, currentWord = 0;
+ for (int i = 0; i < length; i++) {
+ if (array[i] == divider) {
+ split[currentWord] = new char[i - last];
+ System.arraycopy(array, last, split[currentWord++], 0, i - last);
+ last = i + 1;
}
- split[currentWord] = new char[length - last];
- System.arraycopy(array, last, split[currentWord], 0, length - last);
- return split;
}
-
- public static final char[][] splitOn(
- char divider,
- char[] array,
- int start,
- int end) {
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return TypeConstants.NoCharChar;
-
- int wordCount = 1;
- for (int i = start; i < end; i++)
- if (array[i] == divider)
- wordCount++;
- char[][] split = new char[wordCount][];
- int last = start, currentWord = 0;
- for (int i = start; i < end; i++) {
- if (array[i] == divider) {
- split[currentWord] = new char[i - last];
- System.arraycopy(array, last, split[currentWord++], 0, i - last);
- last = i + 1;
- }
+ split[currentWord] = new char[length - last];
+ System.arraycopy(array, last, split[currentWord], 0, length - last);
+ return split;
+}
+public static final char[][] splitOn(char divider, char[] array, int start, int end) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return TypeConstants.NoCharChar;
+
+ int wordCount = 1;
+ for (int i = start; i < end; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = start, currentWord = 0;
+ for (int i = start; i < end; i++) {
+ if (array[i] == divider) {
+ split[currentWord] = new char[i - last];
+ System.arraycopy(array, last, split[currentWord++], 0, i - last);
+ last = i + 1;
}
- split[currentWord] = new char[end - last + 1];
- System.arraycopy(array, last, split[currentWord], 0, end - last + 1);
- return split;
}
-
- public static final boolean startsWith(char[] array, char[] toBeFound) {
- int i = toBeFound.length;
- if (i > array.length)
+ split[currentWord] = new char[end - last + 1];
+ System.arraycopy(array, last, split[currentWord], 0, end - last + 1);
+ return split;
+}
+public static final boolean startsWith(char[] array, char[] toBeFound) {
+ int i = toBeFound.length;
+ if (i > array.length)
+ return false;
+ while (--i >= 0)
+ if (toBeFound[i] != array[i])
return false;
- while (--i >= 0)
- if (toBeFound[i] != array[i])
- return false;
- return true;
- }
-
- /*
- * copies from array[start] through array[end - 1] (does not copy array[end])
- */
- public static final char[][] subarray(char[][] array, int start, int end) {
- if (end == -1)
- end = array.length;
- if (start > end)
- return null;
- if (start < 0)
- return null;
- if (end > array.length)
- return null;
-
- char[][] result = new char[end - start][];
- /* if we do not trust System.arraycopy on our VM with char[][]'s
- for (int i = 0, s = start; s < end; i++, s++)
- result[i] = array[s];
- */
- System.arraycopy(array, start, result, 0, end - start);
- return result;
- }
-
- /*
- * copies from array[start] through array[end - 1] (does not copy array[end])
- */
- public static final char[] subarray(char[] array, int start, int end) {
- if (end == -1)
- end = array.length;
- if (start > end)
- return null;
- if (start < 0)
- return null;
- if (end > array.length)
- return null;
-
- char[] result = new char[end - start];
- System.arraycopy(array, start, result, 0, end - start);
- return result;
- }
-
- /**
- * Answers the result of a char[] conversion to lowercase.
- * NOTE: if no conversion was necessary, then answers back the argument one.
- */
- final static public char[] toLowerCase(char[] chars) {
- if (chars == null)
- return null;
- int length = chars.length;
- char[] lowerChars = null;
- for (int i = 0; i < length; i++) {
- char c = chars[i];
- char lc = Character.toLowerCase(c);
- if ((c != lc) || (lowerChars != null)) {
- if (lowerChars == null) {
- System.arraycopy(chars, 0, lowerChars = new char[length], 0, i);
- }
- lowerChars[i] = lc;
+ return true;
+}
+/*
+ * copies from array[start] through array[end - 1] (does not copy array[end])
+ */
+public static final char[][] subarray(char[][] array, int start, int end) {
+ if (end == -1) end = array.length;
+ if (start > end) return null;
+ if (start < 0) return null;
+ if (end > array.length) return null;
+
+ char[][] result = new char[end - start][];
+/* if we do not trust System.arraycopy on our VM with char[][]'s
+ for (int i = 0, s = start; s < end; i++, s++)
+ result[i] = array[s];
+*/
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+}
+/*
+ * copies from array[start] through array[end - 1] (does not copy array[end])
+ */
+public static final char[] subarray(char[] array, int start, int end) {
+ if (end == -1) end = array.length;
+ if (start > end) return null;
+ if (start < 0) return null;
+ if (end > array.length) return null;
+
+ char[] result = new char[end - start];
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+}
+/**
+ * Answers the result of a char[] conversion to lowercase.
+ * NOTE: if no conversion was necessary, then answers back the argument one.
+ */
+final static public char[] toLowerCase(char[] chars) {
+ if (chars == null) return null;
+ int length = chars.length;
+ char[] lowerChars = null;
+ for (int i = 0; i < length; i++){
+ char c = chars[i];
+ char lc = Character.toLowerCase(c);
+ if ((c != lc) || (lowerChars != null)){
+ if (lowerChars == null){
+ System.arraycopy(chars, 0, lowerChars = new char[length], 0, i);
}
+ lowerChars[i] = lc;
}
- return lowerChars == null ? chars : lowerChars;
}
-
- final static public String toString(char[][] array) {
- char[] result = concatWith(array, '.');
- if (result == null)
- return "";
- return new String(result);
- }
-
+ return lowerChars == null ? chars : lowerChars;
+}
+final static public String toString(char[][] array) {
+ char[] result = concatWith(array, '.');
+ if (result == null)
+ return "";
+ return new String(result);
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
index 2a8438c68f..fd0deae974 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
@@ -7,83 +7,72 @@ public final class HashtableOfInt {
int elementSize; // number of elements in the table
int threshold;
- public HashtableOfInt() {
- this(13);
- }
-
- public HashtableOfInt(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new int[extraRoom];
- this.valueTable = new Object[extraRoom];
- }
-
- public boolean containsKey(int key) {
- int index = key % valueTable.length;
- int currentKey;
- while ((currentKey = keyTable[index]) != 0) {
- if (currentKey == key)
- return true;
- index = (index + 1) % keyTable.length;
- }
- return false;
- }
-
- public Object get(int key) {
- int index = key % valueTable.length;
- int currentKey;
- while ((currentKey = keyTable[index]) != 0) {
- if (currentKey == key)
- return valueTable[index];
- index = (index + 1) % keyTable.length;
- }
- return null;
- }
-
- public Object put(int key, Object value) {
- int index = key % valueTable.length;
- int currentKey;
- while ((currentKey = keyTable[index]) != 0) {
- if (currentKey == key)
- return valueTable[index] = value;
- index = (index + 1) % keyTable.length;
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
+public HashtableOfInt() {
+ this(13);
+}
+public HashtableOfInt(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new int[extraRoom];
+ this.valueTable = new Object[extraRoom];
+}
+public boolean containsKey(int key) {
+ int index = key % valueTable.length;
+ int currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key)
+ return true;
+ index = (index + 1) % keyTable.length;
}
-
- private void rehash() {
- HashtableOfInt newHashtable = new HashtableOfInt(elementSize * 2);
- // double the number of expected elements
- int currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != 0)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
+ return false;
+}
+public Object get(int key) {
+ int index = key % valueTable.length;
+ int currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key) return valueTable[index];
+ index = (index + 1) % keyTable.length;
}
-
- public int size() {
- return elementSize;
+ return null;
+}
+public Object put(int key, Object value) {
+ int index = key % valueTable.length;
+ int currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key) return valueTable[index] = value;
+ index = (index + 1) % keyTable.length;
}
+ keyTable[index] = key;
+ valueTable[index] = value;
- public String toString() {
- String s = "";
- Object object;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((object = valueTable[i]) != null)
- s += keyTable[i] + " -> " + object.toString() + "\n";
- return s;
- }
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold)
+ rehash();
+ return value;
+}
+private void rehash() {
+ HashtableOfInt newHashtable = new HashtableOfInt(elementSize * 2); // double the number of expected elements
+ int currentKey;
+ for (int i = keyTable.length; --i >= 0;)
+ if ((currentKey = keyTable[i]) != 0)
+ newHashtable.put(currentKey, valueTable[i]);
+ this.keyTable = newHashtable.keyTable;
+ this.valueTable = newHashtable.valueTable;
+ this.threshold = newHashtable.threshold;
+}
+public int size() {
+ return elementSize;
+}
+public String toString() {
+ String s = "";
+ Object object;
+ for (int i = 0, length = valueTable.length; i < length; i++)
+ if ((object = valueTable[i]) != null)
+ s += keyTable[i] + " -> " + object.toString() + "\n";
+ return s;
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
index d352c013d4..ddd3b9d361 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
@@ -7,89 +7,77 @@ public final class HashtableOfObject {
int elementSize; // number of elements in the table
int threshold;
- public HashtableOfObject() {
- this(13);
- }
-
- public HashtableOfObject(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new char[extraRoom][];
- this.valueTable = new Object[extraRoom];
- }
-
- public boolean containsKey(char[] key) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return true;
- index = (index + 1) % keyTable.length;
- }
- return false;
- }
-
- public Object get(char[] key) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return valueTable[index];
- index = (index + 1) % keyTable.length;
- }
- return null;
- }
-
- public Object put(char[] key, Object value) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return valueTable[index] = value;
- index = (index + 1) % keyTable.length;
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
+public HashtableOfObject() {
+ this(13);
+}
+public HashtableOfObject(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new char[extraRoom][];
+ this.valueTable = new Object[extraRoom];
+}
+public boolean containsKey(char[] key) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return true;
+ index = (index + 1) % keyTable.length;
}
-
- private void rehash() {
- HashtableOfObject newHashtable = new HashtableOfObject(elementSize * 2);
- // double the number of expected elements
- char[] currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
+ return false;
+}
+public Object get(char[] key) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return valueTable[index];
+ index = (index + 1) % keyTable.length;
}
-
- public int size() {
- return elementSize;
+ return null;
+}
+public Object put(char[] key, Object value) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return valueTable[index] = value;
+ index = (index + 1) % keyTable.length;
}
+ keyTable[index] = key;
+ valueTable[index] = value;
- public String toString() {
- String s = "";
- Object object;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((object = valueTable[i]) != null)
- s += new String(keyTable[i]) + " -> " + object.toString() + "\n";
- return s;
- }
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold)
+ rehash();
+ return value;
+}
+private void rehash() {
+ HashtableOfObject newHashtable = new HashtableOfObject(elementSize * 2); // double the number of expected elements
+ char[] currentKey;
+ for (int i = keyTable.length; --i >= 0;)
+ if ((currentKey = keyTable[i]) != null)
+ newHashtable.put(currentKey, valueTable[i]);
+ this.keyTable = newHashtable.keyTable;
+ this.valueTable = newHashtable.valueTable;
+ this.threshold = newHashtable.threshold;
+}
+public int size() {
+ return elementSize;
+}
+public String toString() {
+ String s = "";
+ Object object;
+ for (int i = 0, length = valueTable.length; i < length; i++)
+ if ((object = valueTable[i]) != null)
+ s += new String(keyTable[i]) + " -> " + object.toString() + "\n";
+ return s;
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
index 93db9f0f08..62eae6ad14 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
@@ -13,89 +13,77 @@ public final class HashtableOfPackage {
int elementSize; // number of elements in the table
int threshold;
- public HashtableOfPackage() {
- this(3); // usually not very large
- }
-
- public HashtableOfPackage(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new char[extraRoom][];
- this.valueTable = new PackageBinding[extraRoom];
- }
-
- public boolean containsKey(char[] key) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return true;
- index = (index + 1) % keyTable.length;
- }
- return false;
- }
-
- public PackageBinding get(char[] key) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return valueTable[index];
- index = (index + 1) % keyTable.length;
- }
- return null;
- }
-
- public PackageBinding put(char[] key, PackageBinding value) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return valueTable[index] = value;
- index = (index + 1) % keyTable.length;
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
+public HashtableOfPackage() {
+ this(3); // usually not very large
+}
+public HashtableOfPackage(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new char[extraRoom][];
+ this.valueTable = new PackageBinding[extraRoom];
+}
+public boolean containsKey(char[] key) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return true;
+ index = (index + 1) % keyTable.length;
}
-
- private void rehash() {
- HashtableOfPackage newHashtable = new HashtableOfPackage(elementSize * 2);
- // double the number of expected elements
- char[] currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
+ return false;
+}
+public PackageBinding get(char[] key) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return valueTable[index];
+ index = (index + 1) % keyTable.length;
}
-
- public int size() {
- return elementSize;
+ return null;
+}
+public PackageBinding put(char[] key, PackageBinding value) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return valueTable[index] = value;
+ index = (index + 1) % keyTable.length;
}
+ keyTable[index] = key;
+ valueTable[index] = value;
- public String toString() {
- String s = "";
- PackageBinding pkg;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((pkg = valueTable[i]) != null)
- s += pkg.toString() + "\n";
- return s;
- }
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold)
+ rehash();
+ return value;
+}
+private void rehash() {
+ HashtableOfPackage newHashtable = new HashtableOfPackage(elementSize * 2); // double the number of expected elements
+ char[] currentKey;
+ for (int i = keyTable.length; --i >= 0;)
+ if ((currentKey = keyTable[i]) != null)
+ newHashtable.put(currentKey, valueTable[i]);
+ this.keyTable = newHashtable.keyTable;
+ this.valueTable = newHashtable.valueTable;
+ this.threshold = newHashtable.threshold;
+}
+public int size() {
+ return elementSize;
+}
+public String toString() {
+ String s = "";
+ PackageBinding pkg;
+ for (int i = 0, length = valueTable.length; i < length; i++)
+ if ((pkg = valueTable[i]) != null)
+ s += pkg.toString() + "\n";
+ return s;
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
index 6cd432c466..a26527488b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
@@ -13,90 +13,77 @@ public final class HashtableOfType {
int elementSize; // number of elements in the table
int threshold;
- public HashtableOfType() {
- this(3);
- }
-
- public HashtableOfType(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new char[extraRoom][];
- this.valueTable = new ReferenceBinding[extraRoom];
- }
-
- public boolean containsKey(char[] key) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return true;
- index = (index + 1) % keyTable.length;
- }
- return false;
- }
-
- public ReferenceBinding get(char[] key) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return valueTable[index];
- index = (index + 1) % keyTable.length;
- }
- return null;
- }
-
- public ReferenceBinding put(char[] key, ReferenceBinding value) {
- int index = CharOperation.hashCode(key) % valueTable.length;
- int keyLength = key.length;
- char[] currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.length == keyLength
- && CharOperation.prefixEquals(currentKey, key))
- return valueTable[index] = value;
- index = (index + 1) % keyTable.length;
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
+public HashtableOfType() {
+ this(3);
+}
+public HashtableOfType(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new char[extraRoom][];
+ this.valueTable = new ReferenceBinding[extraRoom];
+}
+public boolean containsKey(char[] key) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return true;
+ index = (index + 1) % keyTable.length;
}
-
- private void rehash() {
- HashtableOfType newHashtable =
- new HashtableOfType(elementSize < 100 ? 100 : elementSize * 2);
- // double the number of expected elements
- char[] currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
+ return false;
+}
+public ReferenceBinding get(char[] key) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return valueTable[index];
+ index = (index + 1) % keyTable.length;
}
-
- public int size() {
- return elementSize;
+ return null;
+}
+public ReferenceBinding put(char[] key, ReferenceBinding value) {
+ int index = CharOperation.hashCode(key) % valueTable.length;
+ int keyLength = key.length;
+ char[] currentKey;
+ while ((currentKey = keyTable[index]) != null) {
+ if (currentKey.length == keyLength && CharOperation.prefixEquals(currentKey, key))
+ return valueTable[index] = value;
+ index = (index + 1) % keyTable.length;
}
+ keyTable[index] = key;
+ valueTable[index] = value;
- public String toString() {
- String s = "";
- ReferenceBinding type;
- for (int i = 0, length = valueTable.length; i < length; i++)
- if ((type = valueTable[i]) != null)
- s += type.toString() + "\n";
- return s;
- }
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold)
+ rehash();
+ return value;
+}
+private void rehash() {
+ HashtableOfType newHashtable = new HashtableOfType(elementSize < 100 ? 100 : elementSize * 2); // double the number of expected elements
+ char[] currentKey;
+ for (int i = keyTable.length; --i >= 0;)
+ if ((currentKey = keyTable[i]) != null)
+ newHashtable.put(currentKey, valueTable[i]);
+ this.keyTable = newHashtable.keyTable;
+ this.valueTable = newHashtable.valueTable;
+ this.threshold = newHashtable.threshold;
+}
+public int size() {
+ return elementSize;
+}
+public String toString() {
+ String s = "";
+ ReferenceBinding type;
+ for (int i = 0, length = valueTable.length; i < length; i++)
+ if ((type = valueTable[i]) != null)
+ s += type.toString() + "\n";
+ return s;
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
index 8c5cd5d2bb..cb6f61d03d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
@@ -2,72 +2,63 @@ package org.eclipse.jdt.internal.compiler.util;
public final class ObjectVector {
static int INITIAL_SIZE = 10;
-
+
public int size;
int maxSize;
Object[] elements;
- public ObjectVector() {
- maxSize = INITIAL_SIZE;
- size = 0;
- elements = new Object[maxSize];
- }
-
- public void add(Object newElement) {
- if (size == maxSize) // knows that size starts <= maxSize
- System.arraycopy(elements, 0, (elements = new Object[maxSize *= 2]), 0, size);
- elements[size++] = newElement;
+public ObjectVector() {
+ maxSize = INITIAL_SIZE;
+ size = 0;
+ elements = new Object[maxSize];
+}
+public void add(Object newElement) {
+ if (size == maxSize) // knows that size starts <= maxSize
+ System.arraycopy(elements, 0, (elements = new Object[maxSize *= 2]), 0, size);
+ elements[size++] = newElement;
+}
+public void addAll(Object[] newElements) {
+ if (size + newElements.length >= maxSize) {
+ maxSize = size + newElements.length; // assume no more elements will be added
+ System.arraycopy(elements, 0, (elements = new Object[maxSize]), 0, size);
}
-
- public void addAll(Object[] newElements) {
- if (size + newElements.length >= maxSize) {
- maxSize = size + newElements.length; // assume no more elements will be added
- System.arraycopy(elements, 0, (elements = new Object[maxSize]), 0, size);
+ System.arraycopy(newElements, 0, elements, size, newElements.length);
+ size += newElements.length;
+}
+public boolean contains(Object element) {
+ for (int i = size; --i >= 0;)
+ if (element == elements[i])
+ return true;
+ return false;
+}
+public Object elementAt(int index) {
+ return elements[index];
+}
+public Object find(Object element) {
+ for (int i = size; --i >= 0;)
+ if (element == elements[i])
+ return elements[i];
+ return null;
+}
+public Object remove(Object element) {
+ // assumes only one occurrence of the element exists
+ for (int i = size; --i >= 0;)
+ if (element == elements[i]) {
+ // shift the remaining elements down one spot
+ System.arraycopy(elements, i + 1, elements, i, --size - i);
+ elements[size] = null;
+ return element;
}
- System.arraycopy(newElements, 0, elements, size, newElements.length);
- size += newElements.length;
- }
-
- public boolean contains(Object element) {
- for (int i = size; --i >= 0;)
- if (element == elements[i])
- return true;
- return false;
- }
-
- public Object elementAt(int index) {
- return elements[index];
- }
-
- public Object find(Object element) {
- for (int i = size; --i >= 0;)
- if (element == elements[i])
- return elements[i];
- return null;
- }
-
- public Object remove(Object element) {
- // assumes only one occurrence of the element exists
- for (int i = size; --i >= 0;)
- if (element == elements[i]) {
- // shift the remaining elements down one spot
- System.arraycopy(elements, i + 1, elements, i, --size - i);
- elements[size] = null;
- return element;
- }
- return null;
- }
-
- public void removeAll() {
- for (int i = size; --i >= 0;)
- elements[i] = null;
- size = 0;
- }
-
- public String toString() {
- String s = "";
- for (int i = 0; i < size; i++)
- s += elements[i].toString() + "\n";
- return s;
- }
-
+ return null;
+}
+public void removeAll() {
+ for (int i = size; --i >= 0;)
+ elements[i] = null;
+ size = 0;
+}
+public String toString() {
+ String s = "";
+ for (int i = 0; i < size; i++)
+ s += elements[i].toString() + "\n";
+ return s;
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
index b844c598ac..c786cf2ee7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
@@ -2,66 +2,58 @@ package org.eclipse.jdt.internal.compiler.util;
public final class SimpleNameVector {
static int INITIAL_SIZE = 10;
-
+
public int size;
int maxSize;
char[][] elements;
- public SimpleNameVector() {
- maxSize = INITIAL_SIZE;
- size = 0;
- elements = new char[maxSize][];
- }
-
- public void add(char[] newElement) {
- if (size == maxSize) // knows that size starts <= maxSize
- System.arraycopy(elements, 0, (elements = new char[maxSize *= 2][]), 0, size);
- elements[size++] = newElement;
- }
-
- public void addAll(char[][] newElements) {
- if (size + newElements.length >= maxSize) {
- maxSize = size + newElements.length; // assume no more elements will be added
- System.arraycopy(elements, 0, (elements = new char[maxSize][]), 0, size);
- }
- System.arraycopy(newElements, 0, elements, size, newElements.length);
- size += newElements.length;
- }
-
- public boolean contains(char[] element) {
- for (int i = size; --i >= 0;)
- if (CharOperation.equals(element, elements[i]))
- return true;
- return false;
- }
-
- public char[] elementAt(int index) {
- return elements[index];
- }
-
- public char[] remove(char[] element) {
- // assumes only one occurrence of the element exists
- for (int i = size; --i >= 0;)
- if (element == elements[i]) {
- // shift the remaining elements down one spot
- System.arraycopy(elements, i + 1, elements, i, --size - i);
- elements[size] = null;
- return element;
- }
- return null;
- }
-
- public void removeAll() {
- for (int i = size; --i >= 0;)
- elements[i] = null;
- size = 0;
+public SimpleNameVector() {
+ maxSize = INITIAL_SIZE;
+ size = 0;
+ elements = new char[maxSize][];
+}
+public void add(char[] newElement) {
+ if (size == maxSize) // knows that size starts <= maxSize
+ System.arraycopy(elements, 0, (elements = new char[maxSize *= 2][]), 0, size);
+ elements[size++] = newElement;
+}
+public void addAll(char[][] newElements) {
+ if (size + newElements.length >= maxSize) {
+ maxSize = size + newElements.length; // assume no more elements will be added
+ System.arraycopy(elements, 0, (elements = new char[maxSize][]), 0, size);
}
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < size; i++) {
- buffer.append(elements[i]).append("\n");
+ System.arraycopy(newElements, 0, elements, size, newElements.length);
+ size += newElements.length;
+}
+public boolean contains(char[] element) {
+ for (int i = size; --i >= 0;)
+ if (CharOperation.equals(element, elements[i]))
+ return true;
+ return false;
+}
+public char[] elementAt(int index) {
+ return elements[index];
+}
+public char[] remove(char[] element) {
+ // assumes only one occurrence of the element exists
+ for (int i = size; --i >= 0;)
+ if (element == elements[i]) {
+ // shift the remaining elements down one spot
+ System.arraycopy(elements, i + 1, elements, i, --size - i);
+ elements[size] = null;
+ return element;
}
- return buffer.toString();
+ return null;
+}
+public void removeAll() {
+ for (int i = size; --i >= 0;)
+ elements[i] = null;
+ size = 0;
+}
+public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < size; i++) {
+ buffer.append(elements[i]).append("\n");
}
-
+ return buffer.toString();
+}
}

Back to the top