CloneSet162


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
62260.952class_body_declarations[4]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
162110
plugins/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/WeakHashSet.java
262112
plugins/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/WeakHashSetOfCharArray.java
Clone Instance
1
Line Count
62
Source Line
110
Source File
plugins/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/WeakHashSet.java

        private void cleanupGarbageCollectedValues() {
                HashableWeakReference toBeRemoved;
                while ((toBeRemoved = (HashableWeakReference) this.referenceQueue.poll()) != null) {
                        int hashCode = toBeRemoved.hashCode;
                        int valuesLength = this.values.length;
                        int index = (hashCode&  0x7fffffff) % valuesLength;
                        HashableWeakReference currentValue;
                        while ((currentValue = this.values[index]) != null) {
                                if (currentValue == toBeRemoved) {
                                        // replace the value at index with the last value with the same hash
                                        int sameHash = index;
                                        int current;
                                        while ((currentValue = this.values[current = (sameHash + 1) % valuesLength]) != null && currentValue.hashCode == hashCode)
                                                sameHash = current;
                                        this.values[index] = this.values[sameHash];
                                        this.values[sameHash] = null;
                                        this.elementSize--;
                                        break;
                                }
                                if ( ++index == valuesLength) {
                                        index = 0;
                                }
                        }
                }
        }

        public boolean contains(Object obj) {
                return get(obj) != null;
        }

        /*
         * Return the object that is in this set and that is equals to the given object.
         * Return null if not found.
         */
        public Object get(Object obj) {
                cleanupGarbageCollectedValues();
                int valuesLength = this.values.length;
                int index = (obj.hashCode()&  0x7fffffff) % valuesLength;
                HashableWeakReference currentValue;
                while ((currentValue = this.values[index]) != null) {
                        Object referent;
                        if (obj.equals(referent = currentValue.get())) {
                                return referent;
                        }
                        if ( ++index == valuesLength) {
                                index = 0;
                        }
                }
                return null;
        }

        private void rehash() {
                WeakHashSet newHashSet = new WeakHashSet(this.elementSize * 2);         // double the number of expected elements
                newHashSet.referenceQueue = this.referenceQueue;
                HashableWeakReference currentValue;
                for (int i = 0, length = this.values.length; i < length; i++)
                        if ((currentValue = this.values[i]) != null)
                                newHashSet.addValue(currentValue);

                this.values = newHashSet.values;
                this.threshold = newHashSet.threshold;
                this.elementSize = newHashSet.elementSize;
        }


Clone Instance
2
Line Count
62
Source Line
112
Source File
plugins/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/WeakHashSetOfCharArray.java

        private void cleanupGarbageCollectedValues() {
                HashableWeakReference toBeRemoved;
                while ((toBeRemoved = (HashableWeakReference) this.referenceQueue.poll()) != null) {
                        int hashCode = toBeRemoved.hashCode;
                        int valuesLength = this.values.length;
                        int index = (hashCode&  0x7fffffff) % valuesLength;
                        HashableWeakReference currentValue;
                        while ((currentValue = this.values[index]) != null) {
                                if (currentValue == toBeRemoved) {
                                        // replace the value at index with the last value with the same hash
                                        int sameHash = index;
                                        int current;
                                        while ((currentValue = this.values[current = (sameHash + 1) % valuesLength]) != null && currentValue.hashCode == hashCode)
                                                sameHash = current;
                                        this.values[index] = this.values[sameHash];
                                        this.values[sameHash] = null;
                                        this.elementSize--;
                                        break;
                                }
                                if ( ++index == valuesLength) {
                                        index = 0;
                                }
                        }
                }
        }

        public boolean contains(char[] array) {
                return get(array) != null;
        }

        /*
         * Return the char array that is in this set and that is equals to the given char array.
         * Return null if not found.
         */
        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;
        }

        private void rehash() {
                WeakHashSetOfCharArray newHashSet = new WeakHashSetOfCharArray(this.elementSize * 2);           // double the number of expected elements
                newHashSet.referenceQueue = this.referenceQueue;
                HashableWeakReference currentValue;
                for (int i = 0, length = this.values.length; i < length; i++)
                        if ((currentValue = this.values[i]) != null)
                                newHashSet.addValue(currentValue);

                this.values = newHashSet.values;
                this.threshold = newHashSet.threshold;
                this.elementSize = newHashSet.elementSize;
        }


Clone AbstractionParameter Count: 6Parameter Bindings

private void cleanupGarbageCollectedValues() {
  HashableWeakReference toBeRemoved;
  while ((toBeRemoved = (HashableWeakReference) this.referenceQueue.poll()) != null) {
    int hashCode = toBeRemoved.hashCode;
    int valuesLength = this.values.length;
    int index = (hashCode&0x7fffffff) % valuesLength;
    HashableWeakReference currentValue;
    while ((currentValue = this.values[index]) != null) {
      if (currentValue == toBeRemoved) {
        // replace the value at index with the last value with the same hash
        int sameHash = index;
        int current;
        while ((currentValue = this.values[current = (sameHash + 1) % valuesLength]) != null && currentValue.hashCode == hashCode)
          sameHash = current;
        this.values[index] = this.values[sameHash];
        this.values[sameHash] = null;
        this.elementSize--;
        break;
      }
      if ( ++index == valuesLength) {
        index = 0;
      }
    }
  }
}

public boolean contains( [[#variable5a203760]]  [[#variable5a203720]]) {
  return get( [[#variable5a203720]]) != null;
}

/*
         * Return the object that is in this set and that is equals to the given object.
         * Return null if not found.
         */
/*
         * Return the char array that is in this set and that is equals to the given char array.
         * Return null if not found.
         */
public [[#variable5a203760]] get( [[#variable5a203760]]  [[#variable5a203720]]) {
  cleanupGarbageCollectedValues();
  int valuesLength = this.values.length;
  int index = ( [[#variable5a203020]].hashCode [[#variable5a203640]]&0x7fffffff) % valuesLength;
  HashableWeakReference currentValue;
  while ((currentValue = this.values[index]) != null) {
     [[#variable5a203760]] referent;
    if ( [[#variable5a203020]].equals( [[#variable5a203480]])) {
      return referent;
    }
    if ( ++index == valuesLength) {
      index = 0;
    }
  }
  return null;
}

private void rehash() {
   [[#variable5a2034e0]] newHashSet = new [[#variable5a2034e0]](this.elementSize * 2); // double the number of expected elements
  newHashSet.referenceQueue = this.referenceQueue;
  HashableWeakReference currentValue;
  for (int i = 0, length = this.values.length; i < length; i++)
    if ((currentValue = this.values[i]) != null)
      newHashSet.addValue(currentValue);
  this.values = newHashSet.values;
  this.threshold = newHashSet.threshold;
  this.elementSize = newHashSet.elementSize;
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#5a203760]]
Object 
12[[#5a203760]]
char[] 
21[[#5a203720]]
obj 
22[[#5a203720]]
array 
31[[#5a203020]]
obj 
32[[#5a203020]]
CharOperation 
41[[#5a203640]]
() 
42[[#5a203640]]
(array) 
51[[#5a203480]]
referent = currentValue.get() 
52[[#5a203480]]
array, referent = (char[]) currentValue.get() 
61[[#5a2034e0]]
WeakHashSet 
62[[#5a2034e0]]
WeakHashSetOfCharArray