1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.technical
21 import scala.util.Random
22 
23 object MakeRandom {
24   private val random: Random = new Random(System.nanoTime())
25 
26   def setSeed(seed: Long): Unit = {
27     random.setSeed(seed)
28   }
29 
30   def nextInt(n: Int): Int = {
31     random.nextInt(n)
32   }
33 
34   def nextInt(): Int = {
35     random.nextInt()
36   }
37 
38   def nextDouble(): Double = {
39     random.nextDouble()
40   }
41 
42   def nextString(length: Int): String = {
43     random.nextString(length)
44   }
45 
46   def shuffleSeq[T](seq: Seq[T]): Seq[T] = {
47     random.shuffle(seq)
48   }
49 }
Line Stmt Id Pos Tree Symbol Tests Code
24 112 864 - 881 Apply java.lang.System.nanoTime org.make.api.proposal.proposalservicetest,org.make.api.proposal.proposalapitest,org.make.api.sequence.selectionalgorithmtest,org.make.api.proposal.proposalscorertest java.lang.System.nanoTime()
24 43 853 - 882 Apply scala.util.Random.<init> org.make.api.proposal.proposalservicetest,org.make.api.proposal.proposalapitest,org.make.api.sequence.selectionalgorithmtest,org.make.api.proposal.proposalscorertest new scala.util.Random(java.lang.System.nanoTime())
27 263 924 - 944 Apply scala.util.Random.setSeed org.make.api.sequence.sequencesimulationtest,org.make.api.sequence.selectionalgorithmtest MakeRandom.this.random.setSeed(seed)
31 130 985 - 1002 Apply scala.util.Random.nextInt org.make.api.proposal.proposalscorertest MakeRandom.this.random.nextInt(n)
35 1 1037 - 1053 Apply scala.util.Random.nextInt org.make.api.proposal.proposalservicetest,org.make.api.proposal.proposalapitest MakeRandom.this.random.nextInt()
39 217 1094 - 1113 Apply scala.util.Random.nextDouble org.make.api.sequence.sequencesimulationtest MakeRandom.this.random.nextDouble()
43 147 1165 - 1190 Apply scala.util.Random.nextString MakeRandom.this.random.nextString(length)
47 39 1259 - 1259 TypeApply scala.collection.BuildFromLowPriority2.buildFromIterableOps org.make.api.sequence.selectionalgorithmtest collection.this.BuildFrom.buildFromIterableOps[Seq, T, T]
47 239 1245 - 1264 ApplyToImplicitArgs scala.util.Random.shuffle org.make.api.sequence.selectionalgorithmtest MakeRandom.this.random.shuffle[T, Seq[T]](seq)(collection.this.BuildFrom.buildFromIterableOps[Seq, T, T])