CloneSet42


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
183230.967class_body_declarations[10]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1179251
plugins/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/CustomHashtable.java
2183219
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/CustomHashtable.java
Clone Instance
1
Line Count
179
Source Line
251
Source File
plugins/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/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();
        }


Clone Instance
2
Line Count
183
Source Line
219
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/CustomHashtable.java

    /**
     * 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();
    }


Clone AbstractionParameter Count: 3Parameter Bindings

/**
     * 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 Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#5e5e6ae0]]
get 
12[[#5e5e6ae0]]
getKey 
21[[#b4c4f1e0]]
value 
22[[#b4c4f1e0]]
key 
31[[#b4c4f180]]
while (entry != null) {
  buffer.append(entry.key);
  buffer.append('=');
  buffer.append(entry.value);
  buffer.append(", "); //$NON-NLS-1$
  entry = entry.next;
} 
32[[#b4c4f180]]
if (entry != null)
  entry.appendToStringWithCommaNL(buffer);