Skip to content

Commit 8b13a97

Browse files
authored
fixes for 0.7 (#3)
* fixes for 0.7 * Fix deprecations * updates for 0.7
1 parent cbda53e commit 8b13a97

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ os:
55
- osx
66

77
julia:
8-
- 0.5
9-
- 0.6
8+
- 0.7
109
- nightly
1110

1211
notifications:

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
julia 0.5
1+
julia 0.7-alpha
22
GeometryTypes

src/rectangle.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
type BinaryNode{T}
2-
left::Nullable{T}
3-
right::Nullable{T}
1+
mutable struct BinaryNode{T}
2+
left::Union{Nothing, T}
3+
right::Union{Nothing, T}
44

5-
(::Type{BinaryNode{T}}){T}() = new{T}(Nullable{T}(), Nullable{T}())
6-
(::Type{BinaryNode}){T}(left::T, right::T) = new{T}(Nullable{T}(a), Nullable{T}(b))
7-
(::Type{BinaryNode{T}}){T}(left::T, right::T) = new{T}(Nullable{T}(a), Nullable{T}(b))
5+
BinaryNode{T}() where {T} = new{T}(nothing, nothing)
6+
BinaryNode(left::T, right::T) where {T} = new{T}(nothing, nothing)
7+
BinaryNode{T}(left::T, right::T) where {T} = new{T}(nothing, nothing)
88
end
9-
type RectanglePacker{T}
9+
mutable struct RectanglePacker{T}
1010
children::BinaryNode{RectanglePacker{T}}
1111
area::SimpleRectangle{T}
1212
end
1313

14-
left(a::RectanglePacker) = get(a.children.left)
15-
left{T}(a::RectanglePacker{T}, r::RectanglePacker{T}) = (a.children.left = Nullable(r))
16-
right(a::RectanglePacker) = get(a.children.right)
17-
right{T}(a::RectanglePacker{T}, r::RectanglePacker{T}) = (a.children.right = Nullable(r))
18-
RectanglePacker{T}(area::SimpleRectangle{T}) = RectanglePacker{T}(BinaryNode{RectanglePacker{T}}(), area)
19-
isleaf(a::RectanglePacker) = isnull(a.children.left) && isnull(a.children.right)
14+
left(a::RectanglePacker) = a.children.left
15+
left(a::RectanglePacker{T}, r::RectanglePacker{T}) where {T} = (a.children.left = r)
16+
right(a::RectanglePacker) = a.children.right
17+
right(a::RectanglePacker{T}, r::RectanglePacker{T}) where {T} = (a.children.right = r)
18+
RectanglePacker(area::SimpleRectangle{T}) where {T} = RectanglePacker{T}(BinaryNode{RectanglePacker{T}}(), area)
19+
isleaf(a::RectanglePacker) = (a.children.left) == nothing && (a.children.right == nothing)
2020

2121
# This is rather append, but it seems odd to use another function here.
2222
# Maybe its a bad idea, to call it push regardless!?
23-
function Base.push!{T}(node::RectanglePacker{T}, areas::Vector{SimpleRectangle{T}})
23+
function Base.push!(node::RectanglePacker{T}, areas::Vector{SimpleRectangle{T}}) where T
2424
sort!(areas)
2525
RectanglePacker{T}[push!(node, area) for area in areas]
2626
end
27-
function Base.push!{T}(node::RectanglePacker{T}, area::SimpleRectangle{T})
27+
function Base.push!(node::RectanglePacker{T}, area::SimpleRectangle{T}) where T
2828
if !isleaf(node)
2929
l = push!(left(node), area)
3030
l == nothing && return push!(right(node), area) # if left does not have space, try right

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Packing, GeometryTypes
2-
using Base.Test
2+
using Test
33

44
# write your own tests here
55
include("test_rectangle.jl")

0 commit comments

Comments
 (0)