Java Code Examples for org.eclipse.jdt.core.compiler.CharOperation#hashCode()

The following examples show how to use org.eclipse.jdt.core.compiler.CharOperation#hashCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CharArrayCache.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Puts the specified element into the hashtable if it wasn't there already,
 * using the specified key.  The element may be retrieved by doing a get() with the same key.
 * The key and the element cannot be null.
 *
 * @param key the given key in the hashtable
 * @param value the given value
 * @return int the old value of the key, or -value if it did not have one.
 */
public int putIfAbsent(char[] key, int value) {
	int length = this.keyTable.length, index = CharOperation.hashCode(key) % length;
	while (this.keyTable[index] != null) {
		if (CharOperation.equals(this.keyTable[index], key))
			return this.valueTable[index];
		if (++index == length) { // faster than modulo
			index = 0;
		}
	}
	this.keyTable[index] = key;
	this.valueTable[index] = value;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold)
		rehash();
	return -value; // negative when added (value is assumed to be > 0)
}
 
Example 2
Source File: SimpleSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public char[] remove(char[] object) {
	int length = this.values.length;
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;
	char[] current;
	while ((current = this.values[index]) != null) {
		if (CharOperation.equals(current, object)) {
			this.elementSize--;
			char[] oldValue = this.values[index];
			this.values[index] = null;
			if (this.values[index + 1 == length ? 0 : index + 1] != null)
				rehash(); // only needed if a possible collision existed
			return oldValue;
		}
		if (++index == length) index = 0;
	}
	return null;
}
 
Example 3
Source File: HashtableOfObject.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Object removeKey(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) {
			Object value = this.valueTable[index];
			this.elementSize--;
			this.keyTable[index] = null;
			this.valueTable[index] = null;
			rehash();
			return value;
		}
		if (++index == length) {
			index = 0;
		}
	}
	return null;
}
 
Example 4
Source File: HashtableOfType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public ReferenceBinding put(char[] key, ReferenceBinding value) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index] = value;
		if (++index == length) {
			index = 0;
		}
	}
	this.keyTable[index] = key;
	this.valueTable[index] = value;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold)
		rehash();
	return value;
}
 
Example 5
Source File: HashtableOfPackage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public PackageBinding put(char[] key, PackageBinding value) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index] = value;
		if (++index == length) {
			index = 0;
		}
	}
	this.keyTable[index] = key;
	this.valueTable[index] = value;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold)
		rehash();
	return value;
}
 
Example 6
Source File: WeakHashSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public char[] remove(char[] array) {
	cleanupGarbageCollectedValues();
	int valuesLength = this.values.length;
	int index = (CharOperation.hashCode(array) & 0x7FFFFFFF) % valuesLength;
	HashableWeakReference currentValue;
	while ((currentValue = this.values[index]) != null) {
		char[] referent;
		if (CharOperation.equals(array, referent = (char[]) currentValue.get())) {
			this.elementSize--;
			this.values[index] = null;
			rehash();
			return referent;
		}
		if (++index == valuesLength) {
			index = 0;
		}
	}
	return null;
}
 
Example 7
Source File: WeakHashSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public char[] get(char[] array) {
	cleanupGarbageCollectedValues();
	int valuesLength = this.values.length;
	int index = (CharOperation.hashCode(array) & 0x7FFFFFFF) % valuesLength;
	HashableWeakReference currentValue;
	while ((currentValue = this.values[index]) != null) {
		char[] referent;
		if (CharOperation.equals(array, referent = (char[]) currentValue.get())) {
			return referent;
		}
		if (++index == valuesLength) {
			index = 0;
		}
	}
	return null;
}
 
Example 8
Source File: WeakHashSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public char[] add(char[] array) {
	cleanupGarbageCollectedValues();
	int valuesLength = this.values.length,
		index = (CharOperation.hashCode(array) & 0x7FFFFFFF) % valuesLength;
	HashableWeakReference currentValue;
	while ((currentValue = this.values[index]) != null) {
		char[] referent;
		if (CharOperation.equals(array, referent = (char[]) currentValue.get())) {
			return referent;
		}
		if (++index == valuesLength) {
			index = 0;
		}
	}
	this.values[index] = new HashableWeakReference(array, this.referenceQueue);

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold)
		rehash();

	return array;
}
 
Example 9
Source File: HashtableOfObject.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Object put(char[] key, Object value) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index] = value;
		if (++index == length) {
			index = 0;
		}
	}
	this.keyTable[index] = key;
	this.valueTable[index] = value;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold)
		rehash();
	return value;
}
 
Example 10
Source File: HashtableOfType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public ReferenceBinding get(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index];
		if (++index == length) {
			index = 0;
		}
	}
	return null;
}
 
Example 11
Source File: HashtableOfObject.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean containsKey(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return true;
		if (++index == length) {
			index = 0;
		}
	}
	return false;
}
 
Example 12
Source File: HashtableOfIntValues.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean containsKey(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return true;
		if (++index == length) {
			index = 0;
		}
	}
	return false;
}
 
Example 13
Source File: HashtableOfType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean containsKey(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return true;
		if (++index == length) {
			index = 0;
		}
	}
	return false;
}
 
Example 14
Source File: HashtableOfPackage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean containsKey(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return true;
		if (++index == length) {
			index = 0;
		}
	}
	return false;
}
 
Example 15
Source File: SimpleSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public char[] get(char[] object) {
	int length = this.values.length;
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;
	char[] current;
	while ((current = this.values[index]) != null) {
		if (CharOperation.equals(current, object)) return current;
		if (++index == length) index = 0;
	}
	this.values[index] = object;

	// assumes the threshold is never equal to the size of the table
	if (++this.elementSize > this.threshold) rehash();
	return object;
}
 
Example 16
Source File: SimpleSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean includes(char[] object) {
	int length = this.values.length;
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;
	char[] current;
	while ((current = this.values[index]) != null) {
		if (CharOperation.equals(current, object)) return true;
		if (++index == length) index = 0;
	}
	return false;
}
 
Example 17
Source File: HashtableOfIntValues.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public int get(char[] key) {
	int length = this.keyTable.length,
		index = CharOperation.hashCode(key) % length;
	int keyLength = key.length;
	char[] currentKey;
	while ((currentKey = this.keyTable[index]) != null) {
		if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
			return this.valueTable[index];
		if (++index == length) {
			index = 0;
		}
	}
	return NO_VALUE;
}
 
Example 18
Source File: MethodInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public int hashCode() {
	return CharOperation.hashCode(getSelector()) + CharOperation.hashCode(getMethodDescriptor());
}
 
Example 19
Source File: WeakHashSetOfCharArray.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public HashableWeakReference(char[] referent, ReferenceQueue queue) {
	super(referent, queue);
	this.hashCode = CharOperation.hashCode(referent);
}
 
Example 20
Source File: AccessRule.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public int hashCode() {
	return this.problemId * 17 + CharOperation.hashCode(this.pattern);
}