Created
September 18, 2014 14:18
-
-
Save jottinger/a7c104c6ed73a1154992 to your computer and use it in GitHub Desktop.
Iterating using an array, because whatever school Nepherus goes to teaches NOTHING worthwhile, apparently
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Iterate2 { | |
public static void main(String[] args) { | |
new Iterate2().run(); | |
} | |
public void run() { | |
long start = System.currentTimeMillis(); | |
InputStream in = this.getClass().getResourceAsStream("/numbers.txt"); | |
BufferedInputStream bis = new BufferedInputStream(in); | |
Scanner scanner = new Scanner(bis); | |
int counter = 0; | |
boolean[] bits = new boolean[1100000]; | |
while (scanner.hasNext()) { | |
int i = scanner.nextInt(); | |
bits[i] = true; | |
counter++; | |
} | |
for (int i = 1000000; i < 1100000; i++) { | |
if (bits[i]) { | |
System.out.println(i); | |
} | |
} | |
long end = System.currentTimeMillis(); | |
System.out.printf("%d entries processed in %d ms%n", counter, end - start); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment