Skip to content
Open
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MicroCollections = "0.1"
Referenceables = "0.1"
Setfield = "0.3, 0.4, 0.5, 0.6, 0.7"
SplittablesBase = "0.1.8"
Transducers = "0.4.52"
Transducers = "0.4.55"
julia = "1"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions benchmark/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ version = "0.1.3-DEV"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "a2d46274b3a58d9117681d7effdf706022d44650"
git-tree-sha1 = "43af70a0c200318b1a0e7f5552d302f7ecda5d71"
repo-rev = "master"
repo-url = "https://github.com/JuliaFolds/Transducers.jl.git"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.52"
version = "0.4.55-DEV"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
4 changes: 2 additions & 2 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ version = "0.1.3-DEV"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "a2d46274b3a58d9117681d7effdf706022d44650"
git-tree-sha1 = "43af70a0c200318b1a0e7f5552d302f7ecda5d71"
repo-rev = "master"
repo-url = "https://github.com/JuliaFolds/Transducers.jl.git"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.52"
version = "0.4.55-DEV"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
1 change: 1 addition & 0 deletions src/ThreadsX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ using Referenceables: referenceable
using Setfield: @set
using Transducers:
Cat,
Consecutive,
Empty,
Filter,
Init,
Expand Down
21 changes: 17 additions & 4 deletions src/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,29 @@ ThreadsX.issorted(
kw...,
) = ThreadsX.issorted(itr, Base.ord(lt, by, rev, order); kw...)

ThreadsX.issorted(itr, order::Base.Ordering; kw...) =
function make_geq(order)
geq((x1, x2),) = !Base.lt(order, x2, x1)
return geq
end

# TODO: Benchmark it with `Consecutive` version and drop this method
# if the speed is comparable.
ThreadsX.issorted(itr::AbstractArray, order::Base.Ordering; kw...) =
ThreadsX.all(
make_geq(order),
zip(
view(itr, firstindex(itr):lastindex(itr)-1),
view(itr, firstindex(itr)+1:lastindex(itr)),
);
kw...,
) do (x1, x2)
!Base.lt(order, x2, x1)
end
)

ThreadsX.issorted(itr, order::Base.Ordering; kw...) =
ThreadsX.all(
make_geq(order),
itr |> Consecutive(Val(2), Val(1));
kw...,
)

struct PushUnique{F} <: Function
f::F
Expand Down
4 changes: 2 additions & 2 deletions test/environments/main/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ version = "0.1.3-DEV"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "a2d46274b3a58d9117681d7effdf706022d44650"
git-tree-sha1 = "43af70a0c200318b1a0e7f5552d302f7ecda5d71"
repo-rev = "master"
repo-url = "https://github.com/JuliaFolds/Transducers.jl.git"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.52"
version = "0.4.55-DEV"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
4 changes: 4 additions & 0 deletions test/test_with_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ issorted(reverse(0:9); by=_ -> 1)
issorted([])
issorted([]; rev=true)
issorted([]; by=_ -> 1)
issorted(x^2 for x in 0:9)
issorted(x^2 for x in reverse(0:8))
issorted(x^2 for x in reverse(0:7); rev = true)
issorted(x^2 for x in reverse(0:6); by = _ -> 1)
unique([1, 2, 6, 2])
unique(Real[1, 1.0, 2])
unique(x -> x^2, [1, -1, -3, 4, 3])
Expand Down