Skip to content

Commit bde45d1

Browse files
committed
ForgetfulMap
1 parent 135198c commit bde45d1

File tree

6 files changed

+508
-16
lines changed

6 files changed

+508
-16
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.ojalgo</groupId>
44
<artifactId>ojalgo</artifactId>
5-
<version>55.0.1</version>
5+
<version>55.0.2-SNAPSHOT</version>
66
<name>ojAlgo</name>
77
<description>oj! Algorithms - ojAlgo - is Open Source Java code that has to do with mathematics, linear algebra and optimisation.</description>
88
<packaging>jar</packaging>

src/main/java/org/ojalgo/concurrent/DaemonPoolExecutor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static ExecutorService newSingleThreadExecutor(final String name) {
8686
/**
8787
* Like {@link Executors#newSingleThreadScheduledExecutor()} but with identifiable (daemon) threads
8888
*/
89-
public static ExecutorService newSingleThreadScheduledExecutor(final String name) {
89+
public static ScheduledExecutorService newSingleThreadScheduledExecutor(final String name) {
9090
return Executors.newSingleThreadScheduledExecutor(DaemonPoolExecutor.newThreadFactory(name));
9191
}
9292

src/main/java/org/ojalgo/type/CalendarDate.java

+22-12
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ default CalendarDate adjustInto(final CalendarDate temporal) {
8383
default long adjustInto(final long epochMilli) {
8484
long duration = this.toDurationInMillis();
8585
long half = duration / 2L;
86-
return ((epochMilli / duration) * duration) + half;
86+
return epochMilli / duration * duration + half;
8787
}
8888

8989
/**
@@ -95,10 +95,12 @@ default long toDurationInNanos() {
9595
return this.toDurationInMillis() * NANOS_PER_MILLIS;
9696
}
9797

98+
@Override
9899
default long toIndex(final CalendarDate key) {
99100
return this.adjustInto(key.millis);
100101
}
101102

103+
@Override
102104
default CalendarDate toKey(final long index) {
103105
return new CalendarDate(index);
104106
}
@@ -120,7 +122,7 @@ public static CalendarDate from(final TemporalAccessor temporal) {
120122
try {
121123
long tmpSeconds = temporal.getLong(ChronoField.INSTANT_SECONDS);
122124
int tmpMillisOfSecond = temporal.get(ChronoField.MILLI_OF_SECOND);
123-
return new CalendarDate((tmpSeconds * MILLIS_PER_SECOND) + tmpMillisOfSecond);
125+
return new CalendarDate(tmpSeconds * MILLIS_PER_SECOND + tmpMillisOfSecond);
124126
} catch (DateTimeException ex) {
125127
throw new DateTimeException("Unable to obtain CalendarDate from TemporalAccessor: " + temporal + " of type " + temporal.getClass().getName(),
126128
ex);
@@ -232,7 +234,7 @@ static long millis(final TemporalAccessor temporal) {
232234
try {
233235
long tmpSeconds = temporal.getLong(ChronoField.INSTANT_SECONDS);
234236
int tmpMillisOfSecond = temporal.get(ChronoField.MILLI_OF_SECOND);
235-
return (tmpSeconds * MILLIS_PER_SECOND) + tmpMillisOfSecond;
237+
return tmpSeconds * MILLIS_PER_SECOND + tmpMillisOfSecond;
236238
} catch (DateTimeException ex) {
237239
throw new DateTimeException("No millis!");
238240
}
@@ -312,11 +314,12 @@ public <T extends Temporal> T adjustInto(final T temporal) {
312314
return (T) this;
313315
} else {
314316
long seconds = millis / MILLIS_PER_SECOND;
315-
long nanos = (millis % MILLIS_PER_SECOND) * (NANOS_PER_SECOND / MILLIS_PER_SECOND);
317+
long nanos = millis % MILLIS_PER_SECOND * (NANOS_PER_SECOND / MILLIS_PER_SECOND);
316318
return (T) temporal.with(INSTANT_SECONDS, seconds).with(NANO_OF_SECOND, nanos);
317319
}
318320
}
319321

322+
@Override
320323
public int compareTo(final CalendarDate ref) {
321324
return Long.signum(millis - ref.millis);
322325
}
@@ -326,7 +329,7 @@ public boolean equals(final Object obj) {
326329
if (this == obj) {
327330
return true;
328331
}
329-
if ((obj == null) || !(obj instanceof CalendarDate)) {
332+
if (obj == null || !(obj instanceof CalendarDate)) {
330333
return false;
331334
}
332335
CalendarDate other = (CalendarDate) obj;
@@ -344,6 +347,7 @@ public CalendarDate filter(final CalendarDateUnit resolution) {
344347
}
345348
}
346349

350+
@Override
347351
public long getLong(final TemporalField field) {
348352
if (field instanceof ChronoField) {
349353
if (field == ChronoField.INSTANT_SECONDS) {
@@ -358,29 +362,32 @@ public long getLong(final TemporalField field) {
358362

359363
@Override
360364
public int hashCode() {
361-
return (int) (millis ^ (millis >>> 32));
365+
return (int) (millis ^ millis >>> 32);
362366
}
363367

368+
@Override
364369
public boolean isSupported(final TemporalField field) {
365370
if (field instanceof ChronoField) {
366-
return (field == ChronoField.INSTANT_SECONDS) || (field == ChronoField.MILLI_OF_SECOND);
371+
return field == ChronoField.INSTANT_SECONDS || field == ChronoField.MILLI_OF_SECOND;
367372
} else {
368373
return field.isSupportedBy(this);
369374
}
370375
}
371376

377+
@Override
372378
public boolean isSupported(final TemporalUnit unit) {
373379
if (unit instanceof CalendarDateUnit) {
374380
return true;
375381
} else if (unit instanceof ChronoUnit) {
376-
return unit.isTimeBased() || (unit == ChronoUnit.DAYS);
382+
return unit.isTimeBased() || unit == ChronoUnit.DAYS;
377383
} else if (unit != null) {
378384
return unit.isSupportedBy(this);
379385
} else {
380386
return false;
381387
}
382388
}
383389

390+
@Override
384391
public Temporal plus(final long amountToAdd, final TemporalUnit unit) {
385392
if (unit instanceof CalendarDateUnit) {
386393
return this.step((int) amountToAdd, (CalendarDateUnit) unit);
@@ -403,7 +410,7 @@ public CalendarDate step(final CalendarDateUnit aStepUnit) {
403410
}
404411

405412
public CalendarDate step(final int aStepCount, final CalendarDateUnit aStepUnit) {
406-
return new CalendarDate(millis + (aStepCount * aStepUnit.toDurationInMillis()));
413+
return new CalendarDate(millis + aStepCount * aStepUnit.toDurationInMillis());
407414
}
408415

409416
public Calendar toCalendar() {
@@ -456,7 +463,7 @@ public LocalTime toLocalTime(final ZoneOffset offset) {
456463
int tmpNanos = (int) Math.floorMod(millis, MILLIS_PER_SECOND);
457464
long tmpLocalSeconds = tmpSeconds + offset.getTotalSeconds();
458465
int tmpSecondOfDay = (int) Math.floorMod(tmpLocalSeconds, CalendarDate.SECONDS_PER_DAY);
459-
int tmpNanoOfDay = (tmpSecondOfDay * CalendarDate.NANOS_PER_SECOND) + tmpNanos;
466+
int tmpNanoOfDay = tmpSecondOfDay * CalendarDate.NANOS_PER_SECOND + tmpNanos;
460467
return LocalTime.ofNanoOfDay(tmpNanoOfDay);
461468
}
462469

@@ -473,6 +480,7 @@ public ZonedDateTime toZonedDateTime(final ZoneOffset offset) {
473480
return ZonedDateTime.of(this.toLocalDateTime(offset), offset);
474481
}
475482

483+
@Override
476484
public long until(final Temporal endExclusive, final TemporalUnit unit) {
477485
if (unit instanceof CalendarDateUnit) {
478486
return ((CalendarDateUnit) unit).count(millis, CalendarDate.millis(endExclusive));
@@ -483,18 +491,20 @@ public long until(final Temporal endExclusive, final TemporalUnit unit) {
483491
}
484492
}
485493

494+
@Override
486495
public CalendarDate with(final TemporalAdjuster adjuster) {
487496
return (CalendarDate) Temporal.super.with(adjuster);
488497
}
489498

499+
@Override
490500
public CalendarDate with(final TemporalField field, final long newValue) {
491501
if (field instanceof ChronoField) {
492502
if (field == ChronoField.INSTANT_SECONDS) {
493503
long tmpMillisOfSecond = millis % MILLIS_PER_SECOND;
494-
return new CalendarDate((newValue * MILLIS_PER_SECOND) + tmpMillisOfSecond);
504+
return new CalendarDate(newValue * MILLIS_PER_SECOND + tmpMillisOfSecond);
495505
} else if (field == ChronoField.MILLI_OF_SECOND) {
496506
long tmpSeconds = millis / MILLIS_PER_SECOND;
497-
return new CalendarDate((tmpSeconds * MILLIS_PER_SECOND) + newValue);
507+
return new CalendarDate(tmpSeconds * MILLIS_PER_SECOND + newValue);
498508
} else {
499509
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
500510
}

0 commit comments

Comments
 (0)