Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
package org.eclipse.jdt.internal.core.builder;
public class QualifiedNameSet {
// to avoid using Enumerations, walk the individual values skipping nulls
public char[][][] qualifiedNames;
public int elementSize// number of elements in the table
public int threshold;
public QualifiedNameSet(int size) {
	this. = 0;
	this. = size// size represents the expected number of elements
	int extraRoom = (int) (size * 1.5f);
	if (this. == extraRoom)
		extraRoom++;
	this. = new char[extraRoom][][];
public char[][] add(char[][] qualifiedName) {
	int qLength = qualifiedName.length;
	if (qLength == 0) return .;
	int length = this..length;
	int index = CharOperation.hashCode(qualifiedName[qLength - 1]) % length;
	char[][] current;
	while ((current = this.[index]) != null) {
		if (CharOperation.equals(currentqualifiedName)) return current;
		if (++index == lengthindex = 0;
	}
	this.[index] = qualifiedName;
	// assumes the threshold is never equal to the size of the table
	if (++this. > this.rehash();
	return qualifiedName;
private void rehash() {
	QualifiedNameSet newSet = new QualifiedNameSet(this. * 2); // double the number of expected elements
	char[][] current;
	for (int i = this..length; --i >= 0;)
		if ((current = this.[i]) != null)
			newSet.add(current);
	this. = newSet.qualifiedNames;
	this. = newSet.elementSize;
	this. = newSet.threshold;
public String toString() {
	String s = ""//$NON-NLS-1$
	char[][] qualifiedName;
	for (int i = 0, l = this..lengthi < li++)
		if ((qualifiedName = this.[i]) != null)
			s += CharOperation.toString(qualifiedName) + "\n"//$NON-NLS-1$
	return s;
New to GrepCode? Check out our FAQ X