From df9ff7f340a5ab4e07efc613f5f264eeae63d4c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Jul 2014 16:06:47 +0200 Subject: Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) - Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines --- .../com/jogamp/common/util/IntIntHashMapTest.java | 90 +++++++++++----------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'src/junit/com/jogamp/common/util/IntIntHashMapTest.java') diff --git a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java index fa56d3d..ac009cb 100644 --- a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -46,7 +46,7 @@ import static java.lang.System.*; /** * * @author Michael Bien - * @author Sven Gothel + * @author Sven Gothel */ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -86,20 +86,20 @@ public class IntIntHashMapTest { assertEquals(map.size(), intmap.size()); - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertEquals((int)entry.getValue(), intmap.remove(entry.getKey())); assertEquals(map.size() - i - 1, intmap.size()); i++; } } - + @Test public void iteratorTest() { @@ -108,14 +108,14 @@ public class IntIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); int n = 0; while (iterator.hasNext()) { - IntIntHashMap.Entry entry = iterator.next(); + final IntIntHashMap.Entry entry = iterator.next(); assertNotNull(entry); n++; } @@ -129,33 +129,33 @@ public class IntIntHashMapTest { public void cloneTest() { final int smallSize = iterations / 4 ; - + final IntIntHashMap intmap = new IntIntHashMap( smallSize + smallSize / 4, 0.75f); intmap.setKeyNotFoundValue(-1); - + for (int i = 0; i < smallSize; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } assertEquals(intmap.size(), smallSize); - + final IntIntHashMap intmapCopy = (IntIntHashMap) intmap.clone(); - + assertEquals(intmap.size(), intmapCopy.size()); assertEquals(intmap.getKeyNotFoundValue(), intmapCopy.getKeyNotFoundValue()); - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator iteratorCopy = intmapCopy.iterator(); + final Iterator iteratorCopy = intmapCopy.iterator(); assertNotNull(iteratorCopy); assertTrue(iteratorCopy.hasNext()); - + int n = 0; while (iterator.hasNext()) { assertTrue(iteratorCopy.hasNext()); - IntIntHashMap.Entry entry = iterator.next(); - IntIntHashMap.Entry entryCopy = iteratorCopy.next(); + final IntIntHashMap.Entry entry = iterator.next(); + final IntIntHashMap.Entry entryCopy = iteratorCopy.next(); assertNotNull(entry); assertNotNull(entryCopy); assertEquals(entry.key, entryCopy.key); @@ -173,45 +173,45 @@ public class IntIntHashMapTest { assertTrue(intmapCopy.containsValue(pairs.values[i])); assertTrue(intmapCopy.containsKey(pairs.keys[i])); } - + // out.println(intmap); } @Test public void capacityTest() { - final int fixedSize = 16; - final int capacity = 32; - + final int fixedSize = 16; + final int capacity = 32; + final IntIntHashMap intmap = new IntIntHashMap( capacity, 0.75f); intmap.setKeyNotFoundValue(-1); - - assertEquals(intmap.capacity(), capacity); + + assertEquals(intmap.capacity(), capacity); for (int i = 0; i < fixedSize; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } assertEquals(intmap.size(), fixedSize); assertEquals(intmap.capacity(), capacity); - + final IntIntHashMap intmapCopy = (IntIntHashMap) intmap.clone(); - + assertEquals(intmap.size(), intmapCopy.size()); assertEquals(intmap.capacity(), intmapCopy.capacity()); assertEquals(intmap.getKeyNotFoundValue(), intmapCopy.getKeyNotFoundValue()); - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator iteratorCopy = intmapCopy.iterator(); + final Iterator iteratorCopy = intmapCopy.iterator(); assertNotNull(iteratorCopy); assertTrue(iteratorCopy.hasNext()); - + int n = 0; while (iterator.hasNext()) { assertTrue(iteratorCopy.hasNext()); - IntIntHashMap.Entry entry = iterator.next(); - IntIntHashMap.Entry entryCopy = iteratorCopy.next(); + final IntIntHashMap.Entry entry = iterator.next(); + final IntIntHashMap.Entry entryCopy = iteratorCopy.next(); assertNotNull(entry); assertNotNull(entryCopy); assertEquals(entry.key, entryCopy.key); @@ -231,7 +231,7 @@ public class IntIntHashMapTest { assertTrue(intmapCopy.containsValue(pairs.values[i])); assertTrue(intmapCopy.containsKey(pairs.keys[i])); } - + // out.println(intmap); } @@ -242,7 +242,7 @@ public class IntIntHashMapTest { benchmark(false); } - void benchmark(boolean warmup) { + void benchmark(final boolean warmup) { // simple benchmark final IntIntHashMap intmap = new IntIntHashMap(1024); @@ -256,14 +256,14 @@ public class IntIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - long intmapPutTime = (nanoTime() - time); + final long intmapPutTime = (nanoTime() - time); out.println(" iimap: " + intmapPutTime/1000000.0f+"ms"); time = nanoTime(); for (int i = 0; i < iterations; i++) { map.put(pairs.keys[i], pairs.values[i]); } - long mapPutTime = (nanoTime() - time); + final long mapPutTime = (nanoTime() - time); out.println(" map: " + mapPutTime/1000000.0f+"ms"); @@ -273,14 +273,14 @@ public class IntIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.get(pairs.keys[i]); } - long intmapGetTime = (nanoTime() - time); + final long intmapGetTime = (nanoTime() - time); out.println(" iimap: " + intmapGetTime/1000000.0f+"ms"); time = nanoTime(); for (int i = 0; i < iterations; i++) { map.get(pairs.keys[i]); } - long mapGetTime = (nanoTime() - time); + final long mapGetTime = (nanoTime() - time); out.println(" map: " + mapGetTime/1000000.0f+"ms"); @@ -291,7 +291,7 @@ public class IntIntHashMapTest { intmap.remove(pairs.keys[i]); } assertEquals(0, intmap.size()); - long intmapRemoveTime = (nanoTime() - time); + final long intmapRemoveTime = (nanoTime() - time); out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms"); time = nanoTime(); @@ -299,7 +299,7 @@ public class IntIntHashMapTest { map.remove(pairs.keys[i]); } assertEquals(0, map.size()); - long mapRemoveTime = (nanoTime() - time); + final long mapRemoveTime = (nanoTime() - time); out.println(" map: " + mapRemoveTime/1000000.0f+"ms"); if(!warmup) { @@ -312,7 +312,7 @@ public class IntIntHashMapTest { } } - public static void main(String args[]) throws IOException { + public static void main(final String args[]) throws IOException { org.junit.runner.JUnitCore.main(IntIntHashMapTest.class.getName()); } -- cgit v1.2.3