This is an automated email from the ASF dual-hosted git repository. dcapwell pushed a commit to branch CASSANDRA-20156 in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git
commit 0bbbf1855714d4c65c43dd516cbd1d74baae0859 Author: David Capwell <[email protected]> AuthorDate: Thu Dec 19 23:02:04 2024 -0800 allow LinkedHashSet to processed as a ordered set --- accord-core/src/main/java/accord/utils/RandomSource.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/accord-core/src/main/java/accord/utils/RandomSource.java b/accord-core/src/main/java/accord/utils/RandomSource.java index 4be82265..ddba6237 100644 --- a/accord-core/src/main/java/accord/utils/RandomSource.java +++ b/accord-core/src/main/java/accord/utils/RandomSource.java @@ -21,6 +21,7 @@ package accord.utils; import java.util.ArrayList; import java.util.Comparator; import java.util.EnumSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Random; import java.util.Set; @@ -295,6 +296,12 @@ public interface RandomSource return Iterables.get(set, offset); } + default <T> T pickOrderedSet(LinkedHashSet<T> set) + { + int offset = nextInt(0, set.size()); + return Iterables.get(set, offset); + } + default <T extends Enum<T>> T pickOrderedSet(EnumSet<T> set) { int offset = nextInt(0, set.size()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
