CloneSet78


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
96240.976compilation_unit
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
19611
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
29611
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
Clone Instance
1
Line Count
96
Source Line
11
Source File
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java

/*******************************************************************************
 * Copyright (c) 2000, 2006 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.compiler.util;

import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;

public final class HashtableOfPackage {
        // to avoid using Enumerations, walk the individual tables skipping nulls
        public char[] keyTable[];

        public PackageBinding valueTable[];

        public int elementSize; // number of elements in the table

        int threshold;

public HashtableOfPackage() {
        this(3); // usually not very large
}

public HashtableOfPackage(int size) {
        this.elementSize = 0;
        this.threshold = size; // size represents the expected number of elements
        int extraRoom = (int) (size * 1.75F);
        if (this.threshold == extraRoom)
                extraRoom++;
        this.keyTable = new char[extraRoom][];
        this.valueTable = new PackageBinding[extraRoom];
}

public boolean containsKey(char[] key) {
        int length = keyTable.length,
                index = CharOperation.hashCode(key) % length;
        int keyLength = key.length;
        char[] currentKey;
        while ((currentKey = keyTable[index]) != null) {
                if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
                        return true;
                if ( ++index == length) {
                        index = 0;
                }
        }
        return false;
}

public PackageBinding get(char[] key) {
        int length = keyTable.length,
                index = CharOperation.hashCode(key) % length;
        int keyLength = key.length;
        char[] currentKey;
        while ((currentKey = keyTable[index]) != null) {
                if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
                        return valueTable[index];
                if ( ++index == length) {
                        index = 0;
                }
        }
        return null;
}

public PackageBinding put(char[] key, PackageBinding value) {
        int length = keyTable.length,
                index = CharOperation.hashCode(key) % length;
        int keyLength = key.length;
        char[] currentKey;
        while ((currentKey = keyTable[index]) != null) {
                if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
                        return valueTable[index] = value;
                if ( ++index == length) {
                        index = 0;
                }
        }
        keyTable[index] = key;
        valueTable[index] = value;

        // assumes the threshold is never equal to the size of the table
        if ( ++elementSize > threshold)
                rehash();
        return value;
}

private void rehash() {
        HashtableOfPackage newHashtable = new HashtableOfPackage(elementSize * 2); // double the number of expected elements
        char[] currentKey;
        for (int i = keyTable.length; --i >= 0;)
                if ((currentKey = keyTable[i]) != null)
                        newHashtable.put(currentKey, valueTable[i]);

        this.keyTable = newHashtable.keyTable;
        this.valueTable = newHashtable.valueTable;
        this.threshold = newHashtable.threshold;
}

public int size() {
        return elementSize;
}

public String toString() {
        String s = ""; //$NON-NLS-1$
        PackageBinding pkg;
        for (int i = 0, length = valueTable.length; i < length; i++)
                if ((pkg = valueTable[i]) != null)
                        s += pkg.toString() + "\n"; //$NON-NLS-1$
        return s;
}
}




Clone Instance
2
Line Count
96
Source Line
11
Source File
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java

/*******************************************************************************
 * Copyright (c) 2000, 2006 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.compiler.util;

import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;

public final class HashtableOfType {
        // to avoid using Enumerations, walk the individual tables skipping nulls
        public char[] keyTable[];

        public ReferenceBinding valueTable[];

        public int elementSize; // number of elements in the table

        int threshold;

public HashtableOfType() {
        this(3);
}

public HashtableOfType(int size) {
        this.elementSize = 0;
        this.threshold = size; // size represents the expected number of elements
        int extraRoom = (int) (size * 1.75F);
        if (this.threshold == extraRoom)
                extraRoom++;
        this.keyTable = new char[extraRoom][];
        this.valueTable = new ReferenceBinding[extraRoom];
}

public boolean containsKey(char[] key) {
        int length = keyTable.length,
                index = CharOperation.hashCode(key) % length;
        int keyLength = key.length;
        char[] currentKey;
        while ((currentKey = keyTable[index]) != null) {
                if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
                        return true;
                if ( ++index == length) {
                        index = 0;
                }
        }
        return false;
}

public ReferenceBinding get(char[] key) {
        int length = keyTable.length,
                index = CharOperation.hashCode(key) % length;
        int keyLength = key.length;
        char[] currentKey;
        while ((currentKey = keyTable[index]) != null) {
                if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
                        return valueTable[index];
                if ( ++index == length) {
                        index = 0;
                }
        }
        return null;
}

public ReferenceBinding put(char[] key, ReferenceBinding value) {
        int length = keyTable.length,
                index = CharOperation.hashCode(key) % length;
        int keyLength = key.length;
        char[] currentKey;
        while ((currentKey = keyTable[index]) != null) {
                if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
                        return valueTable[index] = value;
                if ( ++index == length) {
                        index = 0;
                }
        }
        keyTable[index] = key;
        valueTable[index] = value;

        // assumes the threshold is never equal to the size of the table
        if ( ++elementSize > threshold)
                rehash();
        return value;
}

private void rehash() {
        HashtableOfType newHashtable = new HashtableOfType(elementSize < 100 ? 100:  elementSize * 2); // double the number of expected elements
        char[] currentKey;
        for (int i = keyTable.length; --i >= 0;)
                if ((currentKey = keyTable[i]) != null)
                        newHashtable.put(currentKey, valueTable[i]);

        this.keyTable = newHashtable.keyTable;
        this.valueTable = newHashtable.valueTable;
        this.threshold = newHashtable.threshold;
}

public int size() {
        return elementSize;
}

public String toString() {
        String s = ""; //$NON-NLS-1$
        ReferenceBinding type;
        for (int i = 0, length = valueTable.length; i < length; i++)
                if ((type = valueTable[i]) != null)
                        s += type.toString() + "\n"; //$NON-NLS-1$
        return s;
}
}




Clone AbstractionParameter Count: 4Parameter Bindings

/*******************************************************************************
 * Copyright (c) 2000, 2006 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.compiler.util;

import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup. [[#variablea53ab7e0]];

public final class [[#variablea53ab740]]{
  // to avoid using Enumerations, walk the individual tables skipping nulls
  public char[] keyTable[];

  public [[#variablea53ab7e0]] valueTable[];

  public int elementSize; // number of elements in the table

  int threshold;

  public [[#variablea53ab740]]() {
    this(3); // usually not very large
  }

  public [[#variablea53ab740]](int size) {
    this.elementSize = 0;
    this.threshold = size; // size represents the expected number of elements
    int extraRoom = (int) (size * 1.75F);
    if (this.threshold == extraRoom)
      extraRoom++;
    this.keyTable = new char[extraRoom][];
    this.valueTable = new [[#variablea53ab7e0]][extraRoom];
  }

  public boolean containsKey(char[] key) {
    int length = keyTable.length, index = CharOperation.hashCode(key) % length;
    int keyLength = key.length;
    char[] currentKey;
    while ((currentKey = keyTable[index]) != null) {
      if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
        return true;
      if ( ++index == length) {
        index = 0;
      }
    }
    return false;
  }

  public [[#variablea53ab7e0]] get(char[] key) {
    int length = keyTable.length, index = CharOperation.hashCode(key) % length;
    int keyLength = key.length;
    char[] currentKey;
    while ((currentKey = keyTable[index]) != null) {
      if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
        return valueTable[index];
      if ( ++index == length) {
        index = 0;
      }
    }
    return null;
  }

  public [[#variablea53ab7e0]] put(char[] key, [[#variablea53ab7e0]] value) {
    int length = keyTable.length, index = CharOperation.hashCode(key) % length;
    int keyLength = key.length;
    char[] currentKey;
    while ((currentKey = keyTable[index]) != null) {
      if (currentKey.length == keyLength && CharOperation.equals(currentKey, key))
        return valueTable[index] = value;
      if ( ++index == length) {
        index = 0;
      }
    }
    keyTable[index] = key;
    valueTable[index] = value;
    // assumes the threshold is never equal to the size of the table
    if ( ++elementSize > threshold)
      rehash();
    return value;
  }

  private void rehash() {
     [[#variablea53ab740]] newHashtable = new [[#variablea53ab740]]( [[#variablea53ab6c0]]); // double the number of expected elements
    char[] currentKey;
    for (int i = keyTable.length; --i >= 0;)
      if ((currentKey = keyTable[i]) != null)
        newHashtable.put(currentKey, valueTable[i]);
    this.keyTable = newHashtable.keyTable;
    this.valueTable = newHashtable.valueTable;
    this.threshold = newHashtable.threshold;
  }

  public int size() {
    return elementSize;
  }

  public String toString() {
    String s = ""; //$NON-NLS-1$
     [[#variablea53ab7e0]]  [[#variablea53ab520]];
    for (int i = 0, length = valueTable.length; i < length; i++)
      if (( [[#variablea53ab520]]= valueTable[i]) != null)
        s += [[#variablea53ab520]].toString() + "\n"; //$NON-NLS-1$
    return s;
  }
}


 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#a53ab7e0]]
PackageBinding 
12[[#a53ab7e0]]
ReferenceBinding 
21[[#a53ab740]]
HashtableOfPackage 
22[[#a53ab740]]
HashtableOfType 
31[[#a53ab6c0]]
elementSize * 2 
32[[#a53ab6c0]]
elementSize < 100 ? 100: elementSize * 2 
41[[#a53ab520]]
pkg 
42[[#a53ab520]]
type