Package com.zybooks.dsaj.map
Class CostPerformanceDatabase
java.lang.Object
com.zybooks.dsaj.map.CostPerformanceDatabase
Maintains a database of maximal (cost,performance) pairs.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
CostPerformanceDatabase
public CostPerformanceDatabase()Constructs an initially empty database.
-
-
Method Details
-
best
Returns the (cost,performance) entry with largest cost not exceeding c. (or null if no entry exist with cost c or less).- Parameters:
c
- an upper limit on the desired cost
-
add
public void add(int c, int p) Add a new entry with given cost c and performance p.- Parameters:
c
- the cost of the new entryp
- the performance of the new entry
-
toString
Returns a string representation of the entry (for debugging use). -
main
-