Skip to content

Commit

Permalink
Use existing Integer objects for HashMaps and HashSets in ClusterDete…
Browse files Browse the repository at this point in the history
…ction.java
  • Loading branch information
MartinGuehmann committed Oct 7, 2020
1 parent 70f12f9 commit 5d82e11
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/clans/algorithms/ClusterDetection.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,7 @@ static int getmaxatt(Vector<Integer> invec, MinimalAttractionValue[] attvals) {
HashMap<Integer, Integer> tmphash = new HashMap<Integer, Integer>(elements);
float[] sumvals = new float[elements];
for (int i = 0; i < elements; i++) {
tmphash.put(invec.elementAt(i).intValue(),
new Integer(i));
tmphash.put(invec.elementAt(i), new Integer(i));
sumvals[i] = 0;
}// end for i
float maxval = 0;
Expand Down Expand Up @@ -612,7 +611,7 @@ static void getcluster(int seed, Vector<Integer> basevec, MinimalAttractionValue
// split one cluster off basevec and put the representatives in currvec
// System.out.println("seed "+seed);//("in getcluster for seed "+seed);//"seed="+seed);
currvec.add(basevec.remove(seed));
int seednum = currvec.elementAt(0).intValue();
Integer seednum = currvec.elementAt(0);
HashSet<Integer> tmphash = new HashSet<Integer>();
tmphash.add(seednum);
// now add all those values with attraction to currvec greater than to
Expand Down Expand Up @@ -647,7 +646,7 @@ static void getcluster(int seed, Vector<Integer> basevec, MinimalAttractionValue
// System.out.println("elements="+elements+" maxnum="+maxnum+" maxatt="+maxatt);
if (maxnum > -1) {
if (limit < maxatt) {
tmphash.add(basevec.elementAt(maxnum).intValue());
tmphash.add(basevec.elementAt(maxnum));
currvec.addElement(basevec.remove(maxnum));
elements--;
foundnew = true;
Expand Down Expand Up @@ -692,7 +691,7 @@ static float getavgatt(Vector<Integer> invec, MinimalAttractionValue[] attvals)
int elements = invec.size();
HashSet<Integer> tmphash = new HashSet<Integer>(elements);
for (int i = 0; i < elements; i++) {
tmphash.add(invec.elementAt(i).intValue());
tmphash.add(invec.elementAt(i));
}// end for i
int attnum = attvals.length;
float sumval = 0;
Expand All @@ -716,7 +715,7 @@ static float getvaratt(Vector<Integer> invec, MinimalAttractionValue[] attvals,
int elements = invec.size();
HashSet<Integer> tmphash = new HashSet<Integer>(elements);
for (int i = 0; i < elements; i++) {
tmphash.add(invec.elementAt(i).intValue());
tmphash.add(invec.elementAt(i));
}// end for i
int attnum = attvals.length;
float sumval = 0;
Expand Down

0 comments on commit 5d82e11

Please sign in to comment.