CloneSet103


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
89230.961compilation_unit
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
18911
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
29211
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfLong.java
Clone Instance
1
Line Count
89
Source Line
11
Source File
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.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;

 /**
  *     Hashtable for non-zero int keys.
  */

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

        public Object[] valueTable;

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

        int threshold;

public HashtableOfInt() {
        this(13);
}

public HashtableOfInt(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 int[extraRoom];
        this.valueTable = new Object[extraRoom];
}

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

public Object get(int key) {
        int length = keyTable.length, index = key % length;
        int currentKey;
        while ((currentKey = keyTable[index]) != 0) {
                if (currentKey == key)  return valueTable[index];
                if ( ++index == length) {
                        index = 0;
                }
        }
        return null;
}

public Object put(int key, Object value) {
        int length = keyTable.length, index = key % length;
        int currentKey;
        while ((currentKey = keyTable[index]) != 0) {
                if (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() {
        HashtableOfInt newHashtable = new HashtableOfInt(elementSize * 2); // double the number of expected elements
        int currentKey;
        for (int i = keyTable.length; --i >= 0;)
                if ((currentKey = keyTable[i]) != 0)
                        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$
        Object object;
        for (int i = 0, length = valueTable.length; i < length; i++)
                if ((object = valueTable[i]) != null)
                        s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
        return s;
}
}




Clone Instance
2
Line Count
92
Source Line
11
Source File
plugins/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfLong.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;

 /**
  *     Hashtable for non-zero long keys.
  */

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

        public Object[] valueTable;

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

        int threshold;

public HashtableOfLong() {
        this(13);
}

public HashtableOfLong(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 long[extraRoom];
        this.valueTable = new Object[extraRoom];
}

public boolean containsKey(long key) {
        int length = keyTable.length,
                index = ((int) (key >>> 32)) % length;
        long currentKey;
        while ((currentKey = keyTable[index]) != 0) {
                if (currentKey == key)
                        return true;
                if ( ++index == length) {
                        index = 0;
                }
        }
        return false;
}

public Object get(long key) {
        int length = keyTable.length,
                index = ((int) (key >>> 32)) % length;
        long currentKey;
        while ((currentKey = keyTable[index]) != 0) {
                if (currentKey == key)  return valueTable[index];
                if ( ++index == length) {
                        index = 0;
                }
        }
        return null;
}

public Object put(long key, Object value) {
        int length = keyTable.length,
                index = ((int) (key >>> 32)) % length;
        long currentKey;
        while ((currentKey = keyTable[index]) != 0) {
                if (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() {
        HashtableOfLong newHashtable = new HashtableOfLong(elementSize * 2); // double the number of expected elements
        long currentKey;
        for (int i = keyTable.length; --i >= 0;)
                if ((currentKey = keyTable[i]) != 0)
                        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$
        Object object;
        for (int i = 0, length = valueTable.length; i < length; i++)
                if ((object = valueTable[i]) != null)
                        s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
        return s;
}
}




Clone AbstractionParameter Count: 3Parameter 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;

/**
  *     Hashtable for non-zero int keys.
  */
/**
  *     Hashtable for non-zero long keys.
  */
public final class [[#variable780c2ac0]]{
  // to avoid using Enumerations, walk the individual tables skipping nulls
  public [[#variable780c2a60]][] keyTable;

  public Object[] valueTable;

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

  int threshold;

  public [[#variable780c2ac0]]() {
    this(13);
  }

  public [[#variable780c2ac0]](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 [[#variable780c2a60]][extraRoom];
    this.valueTable = new Object[extraRoom];
  }

  public boolean containsKey( [[#variable780c2a60]] key) {
    int length = keyTable.length, index = [[#variable780c2760]] % length;
     [[#variable780c2a60]] currentKey;
    while ((currentKey = keyTable[index]) != 0) {
      if (currentKey == key)
        return true;
      if ( ++index == length) {
        index = 0;
      }
    }
    return false;
  }

  public Object get( [[#variable780c2a60]] key) {
    int length = keyTable.length, index = [[#variable780c2760]] % length;
     [[#variable780c2a60]] currentKey;
    while ((currentKey = keyTable[index]) != 0) {
      if (currentKey == key)
        return valueTable[index];
      if ( ++index == length) {
        index = 0;
      }
    }
    return null;
  }

  public Object put( [[#variable780c2a60]] key, Object value) {
    int length = keyTable.length, index = [[#variable780c2760]] % length;
     [[#variable780c2a60]] currentKey;
    while ((currentKey = keyTable[index]) != 0) {
      if (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() {
     [[#variable780c2ac0]] newHashtable = new [[#variable780c2ac0]](elementSize * 2); // double the number of expected elements
     [[#variable780c2a60]] currentKey;
    for (int i = keyTable.length; --i >= 0;)
      if ((currentKey = keyTable[i]) != 0)
        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$
    Object object;
    for (int i = 0, length = valueTable.length; i < length; i++)
      if ((object = valueTable[i]) != null)
        s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
    return s;
  }
}


 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#780c2ac0]]
HashtableOfInt 
12[[#780c2ac0]]
HashtableOfLong 
21[[#780c2a60]]
int 
22[[#780c2a60]]
long 
31[[#780c2760]]
key 
32[[#780c2760]]
((int) (key >>> 32))