I'm working on a project that can generate an infinite amount of numbers
<More on this>
: Threading Isues With Fixed Thread Pool and Large Number of Tasks and I've been successful in solving the threading issues involved with it. Also, I've decided to store the results of the sequencer on the hard disk so I can compute more numbers (and make sure that they all converge to 1), I do this every time the HashMap
that is storing the results reaches 400,000
(a reasonable size on my computer, about 1GB/8GB) key/value pairs, then load in the next 400,000
. Assuming that the values are FinalSequencerReport
s, as the values get larger and larger tending towards ∞
the values stored should eventually exceed my RAM capacity, is there any way to get around this limitation (or even at what number I'll even encounter a situation where storing 400,000
instances will exceed my RAM capacity? Or a formula for any RAM capacity?) NOTE: inside the FinalSequencerReport
class there is a String
, it will always be empty.
Class being stored in the HashMap<BigInteger, FinalSequencerReport<BigInteger>>
:
public static final class FinalSequencerReport<T extends Number> extends SequencerReport<T> implements Comparable<FinalSequencerReport<T>> {
public static Comparator<? super FinalSequencerReport<? extends Number>> compareByInitialValue() {
return (FinalSequencerReport<? extends Number> o1, FinalSequencerReport<? extends Number> o2)
-> new BigInteger(o1.getInitialValue().toString()).compareTo(new BigInteger(o2.getInitialValue().toString()));
}
private final T initialValue;
private final String finalFormattedString;
public FinalSequencerReport(SequencerReport<T> finalReport, T initialValue) {
super(finalReport.getResult(), finalReport.getIterations(), finalReport.getSequence());
this.initialValue = initialValue;
this.finalFormattedString = "Initial Value: "
+ getInitialValue() + "\nFinal Value: " + getResult() + "\nIterations: "
+ getIterations() + "\nAlgebraic Sequence:\n" + getSequence();
}
public String getFinalFormattedString() {
return this.finalFormattedString;
}
public Number getInitialValue() {
return this.initialValue;
}
@Override
public int compareTo(FinalSequencerReport<T> o) {
return FinalSequencerReport.compareByInitialValue().compare(this, o);
}
}
public static class SequencerReport<T extends Number> {
private final T result, iterations;
private final String sequence;
public SequencerReport(T result, T iterations) {
this(result, iterations, "");
}
public SequencerReport(T result, T iterations, String sequence) {
this.result = result;
this.iterations = iterations;
this.sequence = sequence;
}
public T getResult() {
return this.result;
}
public T getIterations() {
return this.iterations;
}
public String getSequence() {
return this.sequence;
}
}