| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 183 | 2 | 3 | 0.967 | class_body_declarations[10] |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 179 | 251 | plugins/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/CustomHashtable.java |
| 2 | 183 | 219 | plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/CustomHashtable.java |
| ||||
/**
* Answers the stored key that is equal to the specified key.
*
* @param key the key to search
* @return the stored key, or null if the specified key does not exist
*/
public Object getKey(Object key) {
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null) {
if (keyEquals(key, entry.key))
return entry.key;
entry = entry.next;
}
return null;
}
private HashMapEntry getEntry(Object key) {
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null) {
if (keyEquals(key, entry.key))
return entry;
entry = entry.next;
}
return null;
}
/**
* Answers the hash code for the given key.
*/
private int hashCode(Object key) {
if (comparer == null)
return key.hashCode();
else
return comparer.hashCode(key);
}
/**
* Compares two keys for equality.
*/
private boolean keyEquals(Object a, Object b) {
if (comparer == null)
return a.equals(b);
else
return comparer.equals(a, b);
}
/**
* Answers an Enumeration on the keys of this Hashtable. The results of the
* Enumeration may be affected if the contents of this Hashtable are
* modified.
*
* @return an Enumeration of the keys of this Hashtable
*/
public Enumeration keys() {
if (elementCount == 0)
return emptyEnumerator;
return new HashEnumerator(true);
}
/**
* Associate the specified value with the specified key in this Hashtable.
* If the key already exists, the old value is replaced. The key and value
* cannot be null.
*
* @param key the key to add
* @param value the value to add
* @return the old value associated with the specified key, null if the key
* did not exist
*/
public Object put(Object key, Object value) {
if (key != null && value != null) {
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null && ! keyEquals(key, entry.key))
entry = entry.next;
if (entry == null) {
if ( ++elementCount > threshold) {
rehash();
index = (hashCode(key)& 0x7fffffff) % elementData.length;
}
if (index < firstSlot)
firstSlot = index;
if (index > lastSlot)
lastSlot = index;
entry = new HashMapEntry(key, value);
entry.next = elementData[index];
elementData[index] = entry;
return null;
}
Object result = entry.value;
entry.key = key; // important to avoid hanging onto keys that are
// equal but "old" -- see bug 30607
entry.value = value;
return result;
}
else throw new NullPointerException();
}
/**
* Increases the capacity of this Hashtable. This method is sent when the
* size of this Hashtable exceeds the load factor.
*/
private void rehash() {
int length = elementData.length << 1;
if (length == 0)
length = 1;
firstSlot = length;
lastSlot = - 1;
HashMapEntry[] newData = new HashMapEntry[length];
for (int i = elementData.length; --i >= 0;) {
HashMapEntry entry = elementData[i];
while (entry != null) {
int index = (hashCode(entry.key)& 0x7fffffff) % length;
if (index < firstSlot)
firstSlot = index;
if (index > lastSlot)
lastSlot = index;
HashMapEntry next = entry.next;
entry.next = newData[index];
newData[index] = entry;
entry = next;
}
}
elementData = newData;
computeMaxSize();
}
/**
* Remove the key/value pair with the specified key from this Hashtable.
*
* @param key the key to remove
* @return the value associated with the specified key, null if the
* specified key did not exist
*/
public Object remove(Object key) {
HashMapEntry last = null;
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null && ! keyEquals(key, entry.key)) {
last = entry;
entry = entry.next;
}
if (entry != null) {
if (last == null)
elementData[index] = entry.next;
else
last.next = entry.next;
elementCount--;
return entry.value;
}
return null;
}
/**
* Answers the number of key/value pairs in this Hashtable.
*
* @return the number of key/value pairs in this Hashtable
*/
public int size() {
return elementCount;
}
/**
* Answers the string representation of this Hashtable.
*
* @return the string representation of this Hashtable
*/
public String toString() {
if (size() == 0)
return "{}"; //$NON-NLS-1$
StringBuffer buffer = new StringBuffer();
buffer.append('{');
for (int i = elementData.length; --i >= 0;) {
HashMapEntry entry = elementData[i];
if (entry != null)
entry.appendToStringWithCommaNL(buffer);
}
// Remove the last ", "
if (elementCount > 0)
buffer.setLength(buffer.length() - 2);
buffer.append('}');
return buffer.toString();
}
|
| ||||
/**
* Answers the value associated with the specified key in
* this Hashtable.
*
* @param key the key of the value returned
* @return the value associated with the specified key, null if the specified key
* does not exist
*/
public Object get(Object key) {
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null) {
if (keyEquals(key, entry.key))
return entry.value;
entry = entry.next;
}
return null;
}
private HashMapEntry getEntry(Object key) {
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null) {
if (keyEquals(key, entry.key))
return entry;
entry = entry.next;
}
return null;
}
/**
* Answers the hash code for the given key.
*/
private int hashCode(Object key) {
if (comparer == null)
return key.hashCode();
else
return comparer.hashCode(key);
}
/**
* Compares two keys for equality.
*/
private boolean keyEquals(Object a, Object b) {
if (comparer == null)
return a.equals(b);
else
return comparer.equals(a, b);
}
/**
* Answers an Enumeration on the keys of this Hashtable. The
* results of the Enumeration may be affected if the contents
* of this Hashtable are modified.
*
* @return an Enumeration of the keys of this Hashtable
*/
public Enumeration keys() {
if (elementCount == 0)
return emptyEnumerator;
return new HashEnumerator(true);
}
/**
* Associate the specified value with the specified key in this Hashtable.
* If the key already exists, the old value is replaced. The key and value
* cannot be null.
*
* @param key the key to add
* @param value the value to add
* @return the old value associated with the specified key, null if the key did
* not exist
*/
public Object put(Object key, Object value) {
if (key != null && value != null) {
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null && !keyEquals(key, entry.key))
entry = entry.next;
if (entry == null) {
if ( ++elementCount > threshold) {
rehash();
index = (hashCode(key)& 0x7fffffff) % elementData.length;
}
if (index < firstSlot)
firstSlot = index;
if (index > lastSlot)
lastSlot = index;
entry = new HashMapEntry(key, value);
entry.next = elementData[index];
elementData[index] = entry;
return null;
}
Object result = entry.value;
entry.key = key; // important to avoid hanging onto keys that are equal but "old" -- see bug 30607
entry.value = value;
return result;
}
else throw new NullPointerException();
}
/**
* Increases the capacity of this Hashtable. This method is sent when
* the size of this Hashtable exceeds the load factor.
*/
private void rehash() {
int length = elementData.length << 1;
if (length == 0)
length = 1;
firstSlot = length;
lastSlot = -1;
HashMapEntry[] newData = new HashMapEntry[length];
for (int i = elementData.length; --i >= 0;) {
HashMapEntry entry = elementData[i];
while (entry != null) {
int index = (hashCode(entry.key)& 0x7fffffff) % length;
if (index < firstSlot)
firstSlot = index;
if (index > lastSlot)
lastSlot = index;
HashMapEntry next = entry.next;
entry.next = newData[index];
newData[index] = entry;
entry = next;
}
}
elementData = newData;
computeMaxSize();
}
/**
* Remove the key/value pair with the specified key from this Hashtable.
*
* @param key the key to remove
* @return the value associated with the specified key, null if the specified key
* did not exist
*/
public Object remove(Object key) {
HashMapEntry last = null;
int index = (hashCode(key)& 0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null && !keyEquals(key, entry.key)) {
last = entry;
entry = entry.next;
}
if (entry != null) {
if (last == null)
elementData[index] = entry.next;
else
last.next = entry.next;
elementCount--;
return entry.value;
}
return null;
}
/**
* Answers the number of key/value pairs in this Hashtable.
*
* @return the number of key/value pairs in this Hashtable
*/
public int size() {
return elementCount;
}
/**
* Answers the string representation of this Hashtable.
*
* @return the string representation of this Hashtable
*/
public String toString() {
if (size() == 0)
return "{}"; //$NON-NLS-1$
StringBuffer buffer = new StringBuffer();
buffer.append('{');
for (int i = elementData.length; --i >= 0;) {
HashMapEntry entry = elementData[i];
while (entry != null) {
buffer.append(entry.key);
buffer.append('=');
buffer.append(entry.value);
buffer.append(", "); //$NON-NLS-1$
entry = entry.next;
}
}
// Remove the last ", "
if (elementCount > 0)
buffer.setLength(buffer.length() - 2);
buffer.append('}');
return buffer.toString();
}
|
| |||
/**
* Answers the value associated with the specified key in
* this Hashtable.
*
* @param key the key of the value returned
* @return the value associated with the specified key, null if the specified key
* does not exist
*/
/**
* Answers the stored key that is equal to the specified key.
*
* @param key the key to search
* @return the stored key, or null if the specified key does not exist
*/
public Object [[#variable5e5e6ae0]](Object key) {
int index = (hashCode(key)&0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null) {
if (keyEquals(key, entry.key))
return entry. [[#variableb4c4f1e0]];
entry = entry.next;
}
return null;
}
private HashMapEntry getEntry(Object key) {
int index = (hashCode(key)&0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null) {
if (keyEquals(key, entry.key))
return entry;
entry = entry.next;
}
return null;
}
/**
* Answers the hash code for the given key.
*/
/**
* Answers the hash code for the given key.
*/
private int hashCode(Object key) {
if (comparer == null)
return key.hashCode();
else
return comparer.hashCode(key);
}
/**
* Compares two keys for equality.
*/
/**
* Compares two keys for equality.
*/
private boolean keyEquals(Object a, Object b) {
if (comparer == null)
return a.equals(b);
else
return comparer.equals(a, b);
}
/**
* Answers an Enumeration on the keys of this Hashtable. The
* results of the Enumeration may be affected if the contents
* of this Hashtable are modified.
*
* @return an Enumeration of the keys of this Hashtable
*/
/**
* Answers an Enumeration on the keys of this Hashtable. The results of the
* Enumeration may be affected if the contents of this Hashtable are
* modified.
*
* @return an Enumeration of the keys of this Hashtable
*/
public Enumeration keys() {
if (elementCount == 0)
return emptyEnumerator;
return new HashEnumerator(true);
}
/**
* Associate the specified value with the specified key in this Hashtable.
* If the key already exists, the old value is replaced. The key and value
* cannot be null.
*
* @param key the key to add
* @param value the value to add
* @return the old value associated with the specified key, null if the key did
* not exist
*/
/**
* Associate the specified value with the specified key in this Hashtable.
* If the key already exists, the old value is replaced. The key and value
* cannot be null.
*
* @param key the key to add
* @param value the value to add
* @return the old value associated with the specified key, null if the key
* did not exist
*/
public Object put(Object key, Object value) {
if (key != null && value != null) {
int index = (hashCode(key)&0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null && !keyEquals(key, entry.key))
entry = entry.next;
if (entry == null) {
if ( ++elementCount > threshold) {
rehash();
index = (hashCode(key)&0x7fffffff) % elementData.length;
}
if (index < firstSlot)
firstSlot = index;
if (index > lastSlot)
lastSlot = index;
entry = new HashMapEntry(key, value);
entry.next = elementData[index];
elementData[index] = entry;
return null;
}
Object result = entry.value;
entry.key = key; // important to avoid hanging onto keys that are equal but "old" -- see bug 30607 // important to avoid hanging onto keys that are
// equal but "old" -- see bug 30607
entry.value = value;
return result;
}
else
throw new NullPointerException();
}
/**
* Increases the capacity of this Hashtable. This method is sent when
* the size of this Hashtable exceeds the load factor.
*/
/**
* Increases the capacity of this Hashtable. This method is sent when the
* size of this Hashtable exceeds the load factor.
*/
private void rehash() {
int length = elementData.length << 1;
if (length == 0)
length = 1;
firstSlot = length;
lastSlot = -1;
HashMapEntry[] newData = new HashMapEntry[length];
for (int i = elementData.length; --i >= 0;) {
HashMapEntry entry = elementData[i];
while (entry != null) {
int index = (hashCode(entry.key)&0x7fffffff) % length;
if (index < firstSlot)
firstSlot = index;
if (index > lastSlot)
lastSlot = index;
HashMapEntry next = entry.next;
entry.next = newData[index];
newData[index] = entry;
entry = next;
}
}
elementData = newData;
computeMaxSize();
}
/**
* Remove the key/value pair with the specified key from this Hashtable.
*
* @param key the key to remove
* @return the value associated with the specified key, null if the specified key
* did not exist
*/
/**
* Remove the key/value pair with the specified key from this Hashtable.
*
* @param key the key to remove
* @return the value associated with the specified key, null if the
* specified key did not exist
*/
public Object remove(Object key) {
HashMapEntry last = null;
int index = (hashCode(key)&0x7fffffff) % elementData.length;
HashMapEntry entry = elementData[index];
while (entry != null && !keyEquals(key, entry.key)) {
last = entry;
entry = entry.next;
}
if (entry != null) {
if (last == null)
elementData[index] = entry.next;
else
last.next = entry.next;
elementCount--;
return entry.value;
}
return null;
}
/**
* Answers the number of key/value pairs in this Hashtable.
*
* @return the number of key/value pairs in this Hashtable
*/
/**
* Answers the number of key/value pairs in this Hashtable.
*
* @return the number of key/value pairs in this Hashtable
*/
public int size() {
return elementCount;
}
/**
* Answers the string representation of this Hashtable.
*
* @return the string representation of this Hashtable
*/
/**
* Answers the string representation of this Hashtable.
*
* @return the string representation of this Hashtable
*/
public String toString() {
if (size() == 0)
return "{}"; //$NON-NLS-1$
StringBuffer buffer = new StringBuffer();
buffer.append('{');
for (int i = elementData.length; --i >= 0;) {
HashMapEntry entry = elementData[i];
[[#variableb4c4f180]]
}
// Remove the last ", "
if (elementCount > 0)
buffer.setLength(buffer.length() - 2);
buffer.append('}');
return buffer.toString();
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#5e5e6ae0]] | get |
| 1 | 2 | [[#5e5e6ae0]] | getKey |
| 2 | 1 | [[#b4c4f1e0]] | value |
| 2 | 2 | [[#b4c4f1e0]] | key |
| 3 | 1 | [[#b4c4f180]] | while (entry != null) {
buffer.append(entry.key);
buffer.append('=');
buffer.append(entry.value);
buffer.append(", "); //$NON-NLS-1$
entry = entry.next;
} |
| 3 | 2 | [[#b4c4f180]] | if (entry != null) entry.appendToStringWithCommaNL(buffer); |