Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Revisit (less|greater)_than_disjoint functions #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 1 addition & 2 deletions src/Intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include("endpoint.jl")
include("interval.jl")
include("anchoredinterval.jl")
include("description.jl")
include("deprecated.jl")

export AbstractInterval,
Interval,
Expand All @@ -39,7 +40,5 @@ export AbstractInterval,
merge,
union,
union!,
less_than_disjoint,
greater_than_disjoint,
.., ≪, ≫, ⊆, ⊇, ⊈, ⊉
end
8 changes: 8 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Base: @deprecate

# BEGIN Intervals 0.1 deprecations

@deprecate less_than_disjoint(a, b) isless_disjoint(a, b) true
@deprecate greater_than_disjoint(a, b) isless_disjoint(b, a) true

# END Intervals 0.1 deprecations
22 changes: 9 additions & 13 deletions src/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,21 @@ end
Base.isless(a::AbstractInterval, b) = LeftEndpoint(a) < b
Base.isless(a, b::AbstractInterval) = a < LeftEndpoint(b)

less_than_disjoint(a::AbstractInterval, b) = RightEndpoint(a) < b
less_than_disjoint(a, b::AbstractInterval) = a < LeftEndpoint(b)

function Base.:isless(a::AbstractInterval, b::AbstractInterval)
function Base.isless(a::AbstractInterval, b::AbstractInterval)
return LeftEndpoint(a) < LeftEndpoint(b)
end

function less_than_disjoint(a::AbstractInterval, b::AbstractInterval)
isless_disjoint(a::AbstractInterval, b) = RightEndpoint(a) < b
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's called isless-something it should call isless, not <.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I need to some investigation here.

isless_disjoint(a, b::AbstractInterval) = a < LeftEndpoint(b)

function isless_disjoint(a::AbstractInterval, b::AbstractInterval)
return RightEndpoint(a) < LeftEndpoint(b)
end

greater_than_disjoint(a, b) = less_than_disjoint(b, a)

"""
≪(a::AbstractInterval, b::AbstractInterval) -> Bool
less_than_disjoint(a::AbstractInterval, b::AbstractInterval) -> Bool

Less-than-and-disjoint comparison operator. Returns `true` if `a` is less than `b` and they
Less than and disjoint comparison operator. Returns `true` if `a` is less than `b` and they
are disjoint (they do not overlap).

```
Expand All @@ -198,14 +195,13 @@ julia> 0..10 ≪ 11..20
true
```
"""
≪(a, b) = less_than_disjoint(a, b)
≪(a, b) = isless_disjoint(a, b)
# ≪̸(a, b) = !≪(a, b)

"""
≫(a::AbstractInterval, b::AbstractInterval) -> Bool
greater_than_disjoint(a::AbstractInterval, b::AbstractInterval) -> Bool

Greater-than-and-disjoint comparison operator. Returns `true` if `a` is greater than `b` and
Greater than and disjoint comparison operator. Returns `true` if `a` is greater than `b` and
they are disjoint (they do not overlap).

```
Expand All @@ -216,7 +212,7 @@ julia> 11..20 ≫ 0..10
true
```
"""
≫(a, b) = greater_than_disjoint(a, b)
≫(a, b) = isless_disjoint(b, a)
# ≫̸(a, b) = !≫(a, b)

##### SET OPERATIONS #####
Expand Down