diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-01-22 13:52:24 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-01-22 13:52:24 +0100 |
commit | 1f2865c97efe67f6f54151c26990226063c85d26 (patch) | |
tree | 6ba3d35da902a937ca3f033d238ef24046a4ffb4 /vespajlib/src | |
parent | 9628d47ea6bb4ea7481354320bc8ba78b0425c4a (diff) |
Don't constrain groups to 1 if group-size is set
Diffstat (limited to 'vespajlib/src')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/collections/IntRange.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/IntRange.java b/vespajlib/src/main/java/com/yahoo/collections/IntRange.java index e2a61688278..c1159357e08 100644 --- a/vespajlib/src/main/java/com/yahoo/collections/IntRange.java +++ b/vespajlib/src/main/java/com/yahoo/collections/IntRange.java @@ -38,6 +38,13 @@ public class IntRange { return true; } + /** Returns the given value adjusted minimally to fit within this range. */ + public int fit(int value) { + if (from.isPresent() && value < from.getAsInt()) return from.getAsInt(); + if (to.isPresent() && value > to.getAsInt()) return to.getAsInt(); + return value; + } + @Override public boolean equals(Object o) { if (this == o) return true; |