-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
18 additions
and
3 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
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* arithmetic with uninterpreted predicates. | ||
* <http://www.philipp.ruemmer.org/princess.shtml> | ||
* | ||
* Copyright (C) 2017 Philipp Ruemmer <[email protected]> | ||
* Copyright (C) 2017-2022 Philipp Ruemmer <[email protected]> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
|
@@ -63,6 +63,12 @@ abstract class RandomDataSource { | |
*/ | ||
def nextInt(bound : Int) : Int | ||
|
||
/** | ||
* Pick a random elements of the given sequence. | ||
*/ | ||
def pick[A](objects : IndexedSeq[A]) : A = | ||
objects(nextInt(objects.size)) | ||
|
||
/** | ||
* Shuffle the given sequence | ||
*/ | ||
|
@@ -79,6 +85,15 @@ abstract class RandomDataSource { | |
} | ||
} | ||
|
||
/** | ||
* Shuffle the given sequence | ||
*/ | ||
def shuffleSeq[A](seq : Seq[A]) : Seq[A] = { | ||
val buf = seq.toBuffer | ||
shuffle(buf) | ||
buf.toIndexedSeq | ||
} | ||
|
||
/** | ||
* Shuffle the given sequence, and return the new ordering | ||
*/ | ||
|