Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ To find out functions supported by ThreadsX.jl, just type

``````julia
julia> ThreadsX.
MergeSort any findlast mapreduce sort
QuickSort count foreach maximum sort!
Set extrema issorted minimum sum
StableQuickSort findall map prod unique
all findfirst map! reduce
MergeSort any findfirst map! reduce
QuickSort collect findlast mapreduce sort
Set count foreach maximum sort!
StableQuickSort extrema issorted minimum sum
all findall map prod unique
``````

## Interoperability
Expand Down
1 change: 1 addition & 0 deletions src/ThreadsX.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
baremodule ThreadsX

function collect end
function map end

function mapreduce end
Expand Down
9 changes: 9 additions & 0 deletions src/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ function ThreadsX.map!(f, dest, array, arrays...; kw...)
end
return dest
end

struct ConvertTo{T} end
(::ConvertTo{T})(x) where {T} = convert(T, x)

ThreadsX.collect(::Type{T}, itr; kwargs...) where {T} =
tcopy(Map(ConvertTo{T}()), Vector{T}, itr; basesize = default_basesize(itr), kwargs...)

ThreadsX.collect(itr; kwargs...) =
tcollect(itr; basesize = default_basesize(itr), kwargs...)
4 changes: 4 additions & 0 deletions test/test_with_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ args_and_kwargs(args...; kwargs...) = args, (; kwargs...)
inc(x) = x + 1

raw_testdata = """
collect(1:10)
collect(Float64, 1:10)
collect(inc(x) for x in 1:10)
collect(Float64, (inc(x) for x in 1:10))
map(inc, 1:10)
map(inc, Float64[])
map(inc, ones(3, 3))
Expand Down