Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Jan 10, 2019
1 parent 2fd5929 commit 8429a77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public IntArrayCountFingerprint() {
}

public IntArrayCountFingerprint(Map<String, Integer> rawFingerprint) {
Map<Integer, Integer> hashedFP = new HashMap<Integer, Integer>();
Map<Integer, Integer> hashedFP = new HashMap<>();
for (String key : rawFingerprint.keySet()) {
Integer hashedKey = key.hashCode();
Integer count = hashedFP.get(hashedKey);
Expand All @@ -61,7 +61,7 @@ public IntArrayCountFingerprint(Map<String, Integer> rawFingerprint) {
}
hashedFP.put(hashedKey, count + rawFingerprint.get(key));
}
List<Integer> keys = new ArrayList<Integer>(hashedFP.keySet());
List<Integer> keys = new ArrayList<>(hashedFP.keySet());
Collections.sort(keys);
hitHashes = new int[keys.size()];
numOfHits = new int[keys.size()];
Expand All @@ -78,8 +78,8 @@ public IntArrayCountFingerprint(Map<String, Integer> rawFingerprint) {
* and if <code>behaveAsBitFingerprint</code> make it only return 0 or 1
* as count thus behaving like a bit finger print.
*
* @param rawFingerprint
* @param behaveAsBitFingerprint
* @param rawFingerprint the raw fp
* @param behaveAsBitFingerprint whether to behave as binary fp or not
*/
public IntArrayCountFingerprint(Map<String, Integer> rawFingerprint, boolean behaveAsBitFingerprint) {
this(rawFingerprint);
Expand All @@ -88,7 +88,7 @@ public IntArrayCountFingerprint(Map<String, Integer> rawFingerprint, boolean beh

@Override
public long size() {
return 4294967296l;
return 4294967296L;
}

@Override
Expand All @@ -111,7 +111,7 @@ public int numOfPopulatedbins() {

@Override
public void merge(ICountFingerprint fp) {
Map<Integer, Integer> newFp = new HashMap<Integer, Integer>();
Map<Integer, Integer> newFp = new HashMap<>();
for (int i = 0; i < hitHashes.length; i++) {
newFp.put(hitHashes[i], numOfHits[i]);
}
Expand All @@ -122,7 +122,7 @@ public void merge(ICountFingerprint fp) {
}
newFp.put(fp.getHash(i), count + fp.getCount(i));
}
List<Integer> keys = new ArrayList<Integer>(newFp.keySet());
List<Integer> keys = new ArrayList<>(newFp.keySet());
Collections.sort(keys);
hitHashes = new int[keys.size()];
numOfHits = new int[keys.size()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public int cardinality() {

@Override
public long size() {
return 4294967296l;
return 4294967296L;
}

@Override
Expand All @@ -99,7 +99,7 @@ public void and(IBitFingerprint fingerprint) {
}

public void and(IntArrayFingerprint fingerprint) {
List<Integer> tmp = new ArrayList<Integer>();
List<Integer> tmp = new ArrayList<>();
int i = 0;
int j = 0;
while (i < trueBits.length && j < fingerprint.trueBits.length) {
Expand Down Expand Up @@ -135,9 +135,9 @@ public void or(IBitFingerprint fingerprint) {
}

public void or(IntArrayFingerprint fingerprint) {
Set<Integer> tmp = new HashSet<Integer>();
for (int i = 0; i < trueBits.length; i++) {
tmp.add(trueBits[i]);
Set<Integer> tmp = new HashSet<>();
for (int trueBit : trueBits) {
tmp.add(trueBit);
}
for (int i = 0; i < fingerprint.trueBits.length; i++) {
tmp.add(fingerprint.trueBits[i]);
Expand Down Expand Up @@ -203,8 +203,7 @@ public boolean equals(Object obj) {
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
IntArrayFingerprint other = (IntArrayFingerprint) obj;
if (!Arrays.equals(trueBits, other.trueBits)) return false;
return true;
return Arrays.equals(trueBits, other.trueBits);
}

@Override
Expand Down

0 comments on commit 8429a77

Please sign in to comment.