Remove redundant generic type arguments.

This commit is contained in:
Gary Gregory 2020-01-26 17:23:41 -05:00
parent 5639a5d790
commit 1d26ffda93
10 changed files with 30 additions and 30 deletions

View File

@ -61,8 +61,8 @@ public class CountingBloomFilter extends AbstractBloomFilter {
public CountingBloomFilter(Hasher hasher, Shape shape) {
super(shape);
verifyHasher(hasher);
counts = new TreeMap<Integer, Integer>();
Set<Integer> idxs = new HashSet<Integer>();
counts = new TreeMap<>();
Set<Integer> idxs = new HashSet<>();
hasher.getBits(shape).forEachRemaining((IntConsumer) idxs::add);
idxs.stream().forEach(idx -> counts.put(idx, 1));
}
@ -74,7 +74,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
*/
public CountingBloomFilter(Shape shape) {
super(shape);
this.counts = new TreeMap<Integer, Integer>();
this.counts = new TreeMap<>();
}
/**
@ -111,7 +111,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
*/
public Stream<Map.Entry<Integer, Integer>> getCounts() {
return counts.entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<Integer, Integer>(e.getKey(), e.getValue()));
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue()));
}
@Override
@ -200,7 +200,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
*/
public void remove(Hasher hasher) {
verifyHasher( hasher );
Set<Integer> lst = new HashSet<Integer>();
Set<Integer> lst = new HashSet<>();
hasher.getBits(getShape()).forEachRemaining( (Consumer<Integer>)lst::add );
remove(lst.stream());
}
@ -262,7 +262,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
@Override
public int andCardinality(BloomFilter other) {
if (other instanceof CountingBloomFilter) {
Set<Integer> result = new HashSet<Integer>( counts.keySet());
Set<Integer> result = new HashSet<>( counts.keySet());
result.retainAll( ((CountingBloomFilter)other).counts.keySet() );
return result.size();
}

View File

@ -112,7 +112,7 @@ public class HasherBloomFilter extends AbstractBloomFilter {
@Override
public void merge(Hasher hasher) {
verifyHasher(hasher);
IteratorChain<Integer> iter = new IteratorChain<Integer>(this.hasher.getBits(getShape()),
IteratorChain<Integer> iter = new IteratorChain<>(this.hasher.getBits(getShape()),
hasher.getBits(getShape()));
this.hasher = new StaticHasher(iter, getShape());
}
@ -125,7 +125,7 @@ public class HasherBloomFilter extends AbstractBloomFilter {
@Override
public boolean contains(Hasher hasher) {
verifyHasher(hasher);
Set<Integer> set = new TreeSet<Integer>();
Set<Integer> set = new TreeSet<>();
hasher.getBits(getShape()).forEachRemaining((IntConsumer) idx -> {
set.add(idx);
});

View File

@ -46,7 +46,7 @@ public class DynamicHasher implements Hasher {
* @param buffers the byte buffers that will be hashed.
*/
public DynamicHasher(HashFunction function, List<byte[]> buffers) {
this.buffers = new ArrayList<byte[]>(buffers);
this.buffers = new ArrayList<>(buffers);
this.function = function;
}
@ -143,7 +143,7 @@ public class DynamicHasher implements Hasher {
*/
public Builder(HashFunction function) {
this.function = function;
this.buffers = new ArrayList<byte[]>();
this.buffers = new ArrayList<>();
}

View File

@ -79,7 +79,7 @@ public final class StaticHasher implements Hasher {
*/
public StaticHasher(Iterator<Integer> iter, Shape shape) {
this.shape = shape;
Set<Integer> workingValues = new TreeSet<Integer>();
Set<Integer> workingValues = new TreeSet<>();
iter.forEachRemaining( idx -> {
if (idx >= this.shape.getNumberOfBits())
{

View File

@ -64,7 +64,7 @@ public class TransformedSortedBagTest<T> extends AbstractSortedBagTest<T> {
}
public void testTransformedBag_decorateTransform() {
final TreeBag<T> originalBag = new TreeBag<T>();
final TreeBag<T> originalBag = new TreeBag<>();
final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (final Object el : els) {
originalBag.add((T) el);

View File

@ -377,7 +377,7 @@ public abstract class AbstractBloomFilterTest {
AbstractBloomFilter filter = createEmptyFilter(shape);
assertFalse(filter.isFull());
List<Integer> values = new ArrayList<Integer>(shape.getNumberOfBits());
List<Integer> values = new ArrayList<>(shape.getNumberOfBits());
for (int i = 0; i < shape.getNumberOfBits(); i++) {
values.add(i);
}

View File

@ -72,7 +72,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
*/
@Test
public void ConstructorTest_Map_CountsTest() {
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
Map<Integer,Integer> map = new HashMap<>();
for (int i =0;i<17;i++)
{
map.put( i, 1 );
@ -137,7 +137,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get());
assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get());
Map<Integer, Integer> m = new HashMap<Integer, Integer>();
Map<Integer, Integer> m = new HashMap<>();
bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue()));
for (int i=0;i<29;i++)
{
@ -177,7 +177,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get());
assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get());
Map<Integer, Integer> m = new HashMap<Integer, Integer>();
Map<Integer, Integer> m = new HashMap<>();
bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue()));
for (int i=0;i<29;i++)
{
@ -217,7 +217,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get());
assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get());
Map<Integer, Integer> m = new HashMap<Integer, Integer>();
Map<Integer, Integer> m = new HashMap<>();
bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue()));
for (int i=0;i<29;i++)
{
@ -243,7 +243,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
CountingBloomFilter bf = createFilter(hasher, shape);
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
Map<Integer,Integer> map = new HashMap<>();
bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue()));
map.put(1, Integer.MAX_VALUE );
@ -276,7 +276,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1
};
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
Map<Integer,Integer> map = new HashMap<>();
for (int i=1;i<values.length;i++)
{
map.put( i, values[i] );
@ -290,7 +290,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
bf.remove( bf2 );
assertEquals( 17, bf.cardinality() );
Map<Integer,Integer> map2 = new HashMap<Integer,Integer>();
Map<Integer,Integer> map2 = new HashMap<>();
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue()));
for (int i = 11; i<values.length; i++ )
@ -311,7 +311,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1
};
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
Map<Integer,Integer> map = new HashMap<>();
for (int i=1;i<values.length;i++)
{
map.put( i, values[i] );
@ -325,7 +325,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
bf.remove( bf2 );
assertEquals( 17, bf.cardinality() );
Map<Integer,Integer> map2 = new HashMap<Integer,Integer>();
Map<Integer,Integer> map2 = new HashMap<>();
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue()));
for (int i = 11; i<values.length; i++ )
@ -348,7 +348,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
CountingBloomFilter bf = createFilter(hasher, shape);
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
Map<Integer,Integer> map = new HashMap<>();
bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue()));
map.remove(1);
@ -381,7 +381,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1
};
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
Map<Integer,Integer> map = new HashMap<>();
for (int i=1;i<values.length;i++)
{
map.put( i, values[i] );
@ -395,7 +395,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
bf.remove( hasher );
assertEquals( 17, bf.cardinality() );
Map<Integer,Integer> map2 = new HashMap<Integer,Integer>();
Map<Integer,Integer> map2 = new HashMap<>();
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue()));
for (int i = 11; i<values.length; i++ )

View File

@ -124,9 +124,9 @@ public class CommonComparatorTest {
@Test
public void testSortOrder() {
// in this test the signature is the position in the final collection for the ID
TreeSet<HashFunctionIdentity> result = new TreeSet<HashFunctionIdentity>(
TreeSet<HashFunctionIdentity> result = new TreeSet<>(
HashFunctionIdentity.COMMON_COMPARATOR);
List<HashFunctionIdentity> collection = new ArrayList<HashFunctionIdentity>();
List<HashFunctionIdentity> collection = new ArrayList<>();
collection
.add(new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED, ProcessType.CYCLIC, 0));

View File

@ -127,8 +127,8 @@ public class DeepComparatorTest {
@Test
public void testSortOrder() {
// in this test the signature is the position in the final collection for the ID
TreeSet<HashFunctionIdentity> result = new TreeSet<HashFunctionIdentity>(HashFunctionIdentity.DEEP_COMPARATOR);
List<HashFunctionIdentity> collection = new ArrayList<HashFunctionIdentity>();
TreeSet<HashFunctionIdentity> result = new TreeSet<>(HashFunctionIdentity.DEEP_COMPARATOR);
List<HashFunctionIdentity> collection = new ArrayList<>();
collection
.add(new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED, ProcessType.CYCLIC, 0));

View File

@ -325,7 +325,7 @@ public class StaticHasherTest {
*/
@Test
public void testIsEmpty() {
List<Integer> lst = new ArrayList<Integer>();
List<Integer> lst = new ArrayList<>();
StaticHasher hasher = new StaticHasher(lst.iterator(), shape);