Package application.model.database
Class SSSSSReader
java.lang.Object
application.model.database.DatabaseReader
application.model.database.SSSSSReader
public class SSSSSReader extends DatabaseReader
Reads the Smallest Spaceship Supporting Specific Speeds (5S) database.
Assumes the database is sorted by period in ascending order and displacement by descending order.
Example Usage:
Example Usage:
SSSSSReader reader = new SSSSSReader(new File("5s.sss.txt")) // Will probably return NullPointerException until that elusive ship is found System.out.println(Utils.fullRLE(reader.getShipBySpeed("(7, 1)c/8")))
-
Constructor Summary
Constructors Constructor Description SSSSSReader(java.io.File file)
Constructs the reader -
Method Summary
Modifier and Type Method Description Spaceship
getShipBySpeed(int period, int dx, int dy)
Gets an spaceship in the database by its speed / velocity Uses binary search for speed.
-
Constructor Details
-
SSSSSReader
public SSSSSReader(java.io.File file) throws java.io.IOExceptionConstructs the reader- Parameters:
file
- The file where the database is stored- Throws:
java.io.IOException
- Thrown if there is an IOException while reading the file
-
-
Method Details
-
getShipBySpeed
Gets an spaceship in the database by its speed / velocity Uses binary search for speed.- Parameters:
period
- The period of the spaceshipdx
- The x displacement of the spaceshipdy
- The y displacement of the spaceship- Returns:
- Returns the spaceship speed
-