This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e5e108ad allow LinkedHashSet to processed as a ordered set (#153)
e5e108ad is described below

commit e5e108adfeb817f899ca89507e8fa6bc0b191759
Author: dcapwell <[email protected]>
AuthorDate: Fri Jan 31 19:30:36 2025 -0800

    allow LinkedHashSet to processed as a ordered set (#153)
    
    patch by David Capwell; reviewed by Ariel Weisberg for CASSANDRA-20156
---
 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 dfd25d0f..f5d3e863 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]

Reply via email to