Summary: Let's rewrite these stuff in Java!
Revise the Java version of markov
to use an array instead of a Vector
for the prefix in the State
class.
Answer: An array makes more sense than Vector
, because the size is fixed and known when the object is instantiated.
Therefore, we don't need data struct that can grow and shrink dinamically.
Changes applied in this commit.
BONUS: Refactor the Java code to use up-to-data structures and practices:
- Generics -
Map<Prefix, Vector<String>>
instead ofHashtable
- Remove use of deprecated constructor of
StreamTokenizer
- Static constructor, instead of constructors with fields that differ from the fields of the class
Changes applied in this commit.