Created
September 18, 2014 13:47
-
-
Save jottinger/92feb42c4992377419f6 to your computer and use it in GitHub Desktop.
Nepherus' homework, except it won't help since I used java collections, because it's java
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 Iterate { | |
public static void main(String[] args) { | |
new Iterate().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; | |
BitSet bits=new BitSet(); | |
while(scanner.hasNext()) { | |
int i=scanner.nextInt(); | |
bits.set(i); | |
counter++; | |
} | |
for (int i = bits.nextClearBit(999999); i >= 0; i = bits.nextSetBit(i+1)) { | |
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