nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
27be776
)
lib: add an optimized `SequenceRead[E].rand`
author
Alexis Laferrière
<alexis.laf@xymus.net>
Wed, 4 Mar 2015 02:00:35 +0000
(21:00 -0500)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Tue, 10 Mar 2015 00:39:04 +0000
(20:39 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/standard/math.nit
patch
|
blob
|
history
diff --git
a/lib/standard/math.nit
b/lib/standard/math.nit
index
4b6ed35
..
14c0e40
100644
(file)
--- a/
lib/standard/math.nit
+++ b/
lib/standard/math.nit
@@
-238,6
+238,15
@@
redef class Collection[ E ]
end
end
+redef class SequenceRead[E]
+ # Optimized for large collections using `[]`
+ redef fun rand
+ do
+ assert not is_empty
+ return self[length.rand]
+ end
+end
+
redef class Sys
init
do