-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add the concurrent usage collector (#800)
- Renamed the consecutive interval collector to the connected range collector and move it to core. - Added methods for finding maximum and minimum connected ranges. - Fixed bugs relating to duplicate ranges. - Added docs.
- Loading branch information
1 parent
e7f9bb2
commit d5f1d06
Showing
53 changed files
with
2,284 additions
and
1,717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/ConnectedRange.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ai.timefold.solver.core.api.score.stream.common; | ||
|
||
/** | ||
* Represents a collection of ranges that are connected, meaning | ||
* the union of all the ranges results in the range | ||
* [{@link #getStart()}, {@link #getEnd()}) without gaps. | ||
* | ||
* @param <Range_> The type of range in the collection. | ||
* @param <Point_> The type of the start and end points for each range. | ||
* @param <Difference_> The type of difference between start and end points. | ||
*/ | ||
public interface ConnectedRange<Range_, Point_ extends Comparable<Point_>, Difference_ extends Comparable<Difference_>> | ||
extends Iterable<Range_> { | ||
/** | ||
* Get the number of ranges contained by this {@link ConnectedRange}. | ||
* | ||
* @return never null, the number of ranges contained by this {@link ConnectedRange}. | ||
*/ | ||
int getContainedRangeCount(); | ||
|
||
/** | ||
* True if this {@link ConnectedRange} has at least one pair of | ||
* ranges that overlaps each other, false otherwise. | ||
* | ||
* @return never null, true iff there at least one pair of overlapping ranges in this {@link ConnectedRange}. | ||
*/ | ||
boolean hasOverlap(); | ||
|
||
/** | ||
* Get the minimum number of overlapping ranges for any point contained by | ||
* this {@link ConnectedRange}. | ||
* | ||
* @return never null, the minimum number of overlapping ranges for any point | ||
* in this {@link ConnectedRange}. | ||
*/ | ||
int getMinimumOverlap(); | ||
|
||
/** | ||
* Get the maximum number of overlapping ranges for any point contained by | ||
* this {@link ConnectedRange}. | ||
* | ||
* @return never null, the maximum number of overlapping ranges for any point | ||
* in this {@link ConnectedRange}. | ||
*/ | ||
int getMaximumOverlap(); | ||
|
||
/** | ||
* Get the length of this {@link ConnectedRange}. | ||
* | ||
* @return The difference between {@link #getEnd()} and {@link #getStart()}. | ||
*/ | ||
Difference_ getLength(); | ||
|
||
/** | ||
* Gets the first start point represented by this {@link ConnectedRange}. | ||
* | ||
* @return never null, the first start point represented by this {@link ConnectedRange}. | ||
*/ | ||
Point_ getStart(); | ||
|
||
/** | ||
* Gets the last end point represented by this {@link ConnectedRange}. | ||
* | ||
* @return never null, the last end point represented by this {@link ConnectedRange}. | ||
*/ | ||
Point_ getEnd(); | ||
} |
23 changes: 23 additions & 0 deletions
23
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/ConnectedRangeChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ai.timefold.solver.core.api.score.stream.common; | ||
|
||
/** | ||
* Contains info regarding {@link ConnectedRange}s and {@link RangeGap}s for a collection of ranges. | ||
* | ||
* @param <Range_> The type of range in the collection. | ||
* @param <Point_> The type of the start and end points for each range. | ||
* @param <Difference_> The type of difference between start and end points. | ||
*/ | ||
public interface ConnectedRangeChain<Range_, Point_ extends Comparable<Point_>, Difference_ extends Comparable<Difference_>> { | ||
|
||
/** | ||
* @return never null, an iterable that iterates through the {@link ConnectedRange}s | ||
* contained in the collection in ascending order of their start points | ||
*/ | ||
Iterable<ConnectedRange<Range_, Point_, Difference_>> getConnectedRanges(); | ||
|
||
/** | ||
* @return never null, an iterable that iterates through the {@link RangeGap}s contained in | ||
* the collection in ascending order of their start points | ||
*/ | ||
Iterable<RangeGap<Point_, Difference_>> getGaps(); | ||
} |
Oops, something went wrong.