-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
Future.jl
44 lines (33 loc) · 1.45 KB
/
Future.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# This file is a part of Julia. License is MIT: https://julialang.org/license
"The `Future` module implements future behavior of already existing functions,
which will replace the current version in a future release of Julia."
module Future
using Random
## copy!
"""
Future.copy!(dst, src) -> dst
Copy `src` into `dst`.
For collections of the same type, copy the elements of `src` into `dst`,
discarding any pre-existing elements in `dst`.
Usually, `dst == src` holds after the call.
"""
copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
copy!(dst::AbstractDict, src::AbstractDict) = merge!(empty!(dst), src)
copy!(dst::AbstractVector, src::AbstractVector) = append!(empty!(dst), src)
function copy!(dst::AbstractArray, src::AbstractArray)
size(dst) == size(src) || throw(ArgumentError(
"arrays must have the same size for copy! (consider using `copyto!`)"))
copyto!(dst, src)
end
## randjump
"""
randjump(r::MersenneTwister, steps::Integer) -> MersenneTwister
Create an initialized `MersenneTwister` object, whose state is moved forward
(without generating numbers) from `r` by `steps` steps.
One such step corresponds to the generation of two `Float64` numbers.
For each different value of `steps`, a large polynomial has to be generated internally.
One is already pre-computed for `steps=big(10)^20`.
"""
randjump(r::MersenneTwister, steps::Integer) =
Random._randjump(r, Random.DSFMT.calc_jump(steps))
end # module Future