Friday, January 20, 2012

Take Three - Java IO and Sorting

EDIT- 
Jan 21, 2012 
It was brought to my attention that there are libraries to implement different sorting algorithms.
I've decided NOT to reinvent the wheel (though I do intend to learn wheel-crafting in case I am ever in a jam).

C++ version of assignment :

  • HERE 
  • Tested with THIS text file
  • OUTPUT
  • Can sort by word count or alphabetical order  
NOTE:
Works on my machine, but compiling on trucks/moons doesn't work (doesn't recognize 'strtok' - scope issue? Perhaps there is an alternative? )


Main Resources :
fstream
STL Containers
STL Algorithms
Readtextfile
strtok
stringstream
convert-int-to-string

Looked At (Not so much used)
functors-and-their-uses
Bloom_filter
EmacsCheatSheet



TAKE THREE DRAFT:
So far, Version 3 on its way... Plus a few thoughts:

  • realized I forgot to print a file with the other versions. (Fixed it)
  • What's better?
    • sorting as you add data 
    • sorting after you've added all data
  • What about functors? 
    • make different functors for different algorithms?
    • switch functors and compare times? 

How can I add color.... hmmm.....

Resources :
http://en.wikipedia.org/wiki/Function_object
http://www.roseindia.net/java/beginners/java-write-to-file.shtml
http://en.wikipedia.org/wiki/Merge_sort

Looked At (not so much used)
http://en.wikipedia.org/wiki/First-class_function
http://docs.oracle.com/javase/tutorial/java/javaOO/innerclasses.html
http://docs.oracle.com/javase/6/docs/api/java/util/Comparator.html
http://docs.oracle.com/javase/tutorial/java/javaOO/innerclasses.html

No comments:

Post a Comment