Skip to content

Commit

Permalink
Merge pull request #311 from yuyichao/yyc/0.7
Browse files Browse the repository at this point in the history
Fix most of 0.7 depwarns
  • Loading branch information
yuyichao authored Jul 24, 2017
2 parents 5b75505 + a8a044b commit c3059a9
Show file tree
Hide file tree
Showing 29 changed files with 215 additions and 271 deletions.
182 changes: 91 additions & 91 deletions src/balanced_tree.jl

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/circ_deque.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type CircularDeque{T}
last::Int
end

@compat (::Type{CircularDeque{T}}){T}(n::Int) = CircularDeque(Vector{T}(n), n, 0, 1, n)
(::Type{CircularDeque{T}}){T}(n::Int) = CircularDeque(Vector{T}(n), n, 0, 1, n)

Base.length(D::CircularDeque) = D.n
Base.eltype{T}(::Type{CircularDeque{T}}) = T
Expand All @@ -27,17 +27,17 @@ end
Base.isempty(D::CircularDeque) = D.n == 0

@inline function front(D::CircularDeque)
@compat @boundscheck D.n > 0 || throw(BoundsError())
@boundscheck D.n > 0 || throw(BoundsError())
D.buffer[D.first]
end

@inline function back(D::CircularDeque)
@compat @boundscheck D.n > 0 || throw(BoundsError())
@boundscheck D.n > 0 || throw(BoundsError())
D.buffer[D.last]
end

@inline function Base.push!(D::CircularDeque, v)
@compat @boundscheck D.n < D.capacity || throw(BoundsError()) # prevent overflow
@boundscheck D.n < D.capacity || throw(BoundsError()) # prevent overflow
D.n += 1
tmp = D.last+1
D.last = ifelse(tmp > D.capacity, 1, tmp) # wraparound
Expand All @@ -54,7 +54,7 @@ end
end

@inline function Base.unshift!(D::CircularDeque, v)
@compat @boundscheck D.n < D.capacity || throw(BoundsError())
@boundscheck D.n < D.capacity || throw(BoundsError())
D.n += 1
tmp = D.first - 1
D.first = ifelse(tmp < 1, D.capacity, tmp)
Expand All @@ -81,7 +81,7 @@ end
end

@inline function Base.getindex(D::CircularDeque, i::Integer)
@compat @boundscheck 1 <= i <= D.n || throw(BoundsError())
@boundscheck 1 <= i <= D.n || throw(BoundsError())
return _unsafe_getindex(D, i)
end

Expand Down
2 changes: 1 addition & 1 deletion src/circular_buffer.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
New items are pushed to the back of the list, overwriting values in a circular fashion.
"""
@compat type CircularBuffer{T} <: AbstractVector{T}
type CircularBuffer{T} <: AbstractVector{T}
capacity::Int
first::Int
buffer::Vector{T}
Expand Down
10 changes: 5 additions & 5 deletions src/default_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# subclassed.
#

@compat immutable DefaultDictBase{K,V,F,D} <: Associative{K,V}
immutable DefaultDictBase{K,V,F,D} <: Associative{K,V}
default::F
d::D

Expand Down Expand Up @@ -44,7 +44,7 @@ DefaultDictBase{K,V,F}(default::F, ps::Pair{K,V}...) = DefaultDictBase{K,V,F,Dic
DefaultDictBase{F,D<:Associative}(default::F, d::D) = (K=keytype(d); V=valtype(d); DefaultDictBase{K,V,F,D}(default, d))

# Constructor for DefaultDictBase{Int,Float64}(0.0)
@compat (::Type{DefaultDictBase{K,V}}){K,V,F}(default::F) = DefaultDictBase{K,V,F,Dict{K,V}}(default)
(::Type{DefaultDictBase{K,V}}){K,V,F}(default::F) = DefaultDictBase{K,V,F,Dict{K,V}}(default)

# Functions

Expand Down Expand Up @@ -82,7 +82,7 @@ end
for _Dict in [:Dict, :OrderedDict]
DefaultDict = Symbol("Default"*string(_Dict))
@eval begin
@compat immutable $DefaultDict{K,V,F} <: Associative{K,V}
immutable $DefaultDict{K,V,F} <: Associative{K,V}
d::DefaultDictBase{K,V,F,$_Dict{K,V}}

(::Type{$DefaultDict{K,V,F}}){K,V,F}(x, ps::Pair{K,V}...) =
Expand All @@ -109,8 +109,8 @@ for _Dict in [:Dict, :OrderedDict]
$DefaultDict{F}(default::F, d::Associative) = ((K,V)= (Base.keytype(d), Base.valtype(d)); $DefaultDict{K,V,F}(default, $_Dict(d)))

# Constructor syntax: DefaultDictBase{Int,Float64}(default)
@compat (::Type{$DefaultDict{K,V}}){K,V}() = throw(ArgumentError("$DefaultDict: no default specified"))
@compat (::Type{$DefaultDict{K,V}}){K,V,F}(default::F) = $DefaultDict{K,V,F}(default)
(::Type{$DefaultDict{K,V}}){K,V}() = throw(ArgumentError("$DefaultDict: no default specified"))
(::Type{$DefaultDict{K,V}}){K,V,F}(default::F) = $DefaultDict{K,V,F}(default)

## Functions

Expand Down
4 changes: 2 additions & 2 deletions src/deque.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
#######################################

@compat type DequeBlock{T}
type DequeBlock{T}
data::Vector{T} # only data[front:back] is valid
capa::Int
front::Int
Expand Down Expand Up @@ -58,7 +58,7 @@ end

const DEFAULT_DEQUEUE_BLOCKSIZE = 1024

@compat type Deque{T}
type Deque{T}
nblocks::Int
blksize::Int
len::Int
Expand Down
2 changes: 1 addition & 1 deletion src/disjoint_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ end
#
############################################################

@compat type DisjointSets{T}
type DisjointSets{T}
intmap::Dict{T,Int}
revmap::Vector{T}
internal::IntDisjointSets
Expand Down
2 changes: 1 addition & 1 deletion src/heaps/binary_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ end
#
#################################################

@compat type BinaryHeap{T,Comp} <: AbstractHeap{T}
type BinaryHeap{T,Comp} <: AbstractHeap{T}
comparer::Comp
valtree::Vector{T}

Expand Down
2 changes: 1 addition & 1 deletion src/heaps/mutable_binary_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ end
#
#################################################

@compat type MutableBinaryHeap{VT, Comp} <: AbstractMutableHeap{VT,Int}
type MutableBinaryHeap{VT, Comp} <: AbstractMutableHeap{VT,Int}
comparer::Comp
nodes::Vector{MutableBinaryHeapNode{VT}}
node_map::Vector{Int}
Expand Down
10 changes: 4 additions & 6 deletions src/multi_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Base: haskey, get, get!, getkey, delete!, pop!, empty!,
next, done, keys, values, copy, similar, push!,
count, size, eltype

@compat immutable MultiDict{K,V}
immutable MultiDict{K,V}
d::Dict{K,Vector{V}}

(::Type{MultiDict{K,V}}){K,V}() = new{K,V}(Dict{K,Vector{V}}())
Expand Down Expand Up @@ -85,11 +85,9 @@ function pop!(d::MultiDict, key, default)
end
pop!(d::MultiDict, key) = pop!(d, key, Base.secret_table_token)

if VERSION >= v"0.4.0-dev+980"
push!(d::MultiDict, kv::Pair) = insert!(d, kv[1], kv[2])
#push!(d::MultiDict, kv::Pair, kv2::Pair) = (push!(d.d, kv, kv2); d)
#push!(d::MultiDict, kv::Pair, kv2::Pair, kv3::Pair...) = (push!(d.d, kv, kv2, kv3...); d)
end
push!(d::MultiDict, kv::Pair) = insert!(d, kv[1], kv[2])
#push!(d::MultiDict, kv::Pair, kv2::Pair) = (push!(d.d, kv, kv2); d)
#push!(d::MultiDict, kv::Pair, kv2::Pair, kv3::Pair...) = (push!(d.d, kv, kv2, kv3...); d)

push!(d::MultiDict, kv) = insert!(d, kv[1], kv[2])
#push!(d::MultiDict, kv, kv2...) = (push!(d.d, kv, kv2...); d)
Expand Down
2 changes: 1 addition & 1 deletion src/ordered_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Base: haskey, get, get!, getkey, delete!, push!, pop!, empty!,
`OrderedDict`s are simply dictionaries whose entries have a particular order. The order
refers to insertion order, which allows deterministic iteration over the dictionary or set.
"""
@compat type OrderedDict{K,V} <: Associative{K,V}
type OrderedDict{K,V} <: Associative{K,V}
slots::Array{Int32,1}
keys::Array{K,1}
vals::Array{V,1}
Expand Down
2 changes: 1 addition & 1 deletion src/ordered_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# TODO: Most of these functions should be removed once AbstractSet is introduced there
# (see https://github.com/JuliaLang/julia/issues/5533)

@compat immutable OrderedSet{T}
immutable OrderedSet{T}
dict::OrderedDict{T,Void}

(::Type{OrderedSet{T}}){T}() = new{T}(OrderedDict{T,Void}())
Expand Down
2 changes: 1 addition & 1 deletion src/priorityqueue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PriorityQueue{String,Int64,Base.Order.ForwardOrdering} with 3 entries:
"a" => 2
```
"""
@compat type PriorityQueue{K,V,O<:Ordering} <: Associative{K,V}
type PriorityQueue{K,V,O<:Ordering} <: Associative{K,V}
# Binary heap of (element, priority) pairs.
xs::Array{Pair{K,V}, 1}
o::O
Expand Down
16 changes: 8 additions & 8 deletions src/sorted_dict.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## A SortedDict is a wrapper around balancedTree with
## methods similiar to those of Julia container Dict.

@compat type SortedDict{K, D, Ord <: Ordering} <: Associative{K,D}
type SortedDict{K, D, Ord <: Ordering} <: Associative{K,D}
bt::BalancedTree23{K,D,Ord}

## Base constructors
Expand Down Expand Up @@ -36,8 +36,8 @@ SortedDict{Ord <: Ordering}(o::Ord) = SortedDict{Any,Any,Ord}(o)
# TODO: fix SortedDict(1=>1, 2=>2.0)
SortedDict(ps::Pair...) = SortedDict(Forward, ps)
SortedDict(o::Ordering, ps::Pair...) = SortedDict(o, ps)
@compat (::Type{SortedDict{K,D}}){K,D}(ps::Pair...) = SortedDict{K,D,ForwardOrdering}(Forward, ps)
@compat (::Type{SortedDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, ps::Pair...) = SortedDict{K,D,Ord}(o, ps)
(::Type{SortedDict{K,D}}){K,D}(ps::Pair...) = SortedDict{K,D,ForwardOrdering}(Forward, ps)
(::Type{SortedDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, ps::Pair...) = SortedDict{K,D,Ord}(o, ps)

# Construction from Associatives
SortedDict{K,D,Ord<:Ordering}(o::Ord, d::Associative{K,D}) = SortedDict{K,D,Ord}(o, d)
Expand All @@ -46,8 +46,8 @@ SortedDict{K,D,Ord<:Ordering}(o::Ord, d::Associative{K,D}) = SortedDict{K,D,Ord}

# Construction specifying Key/Value types
# e.g., SortedDict{Int,Float64}([1=>1, 2=>2.0])
@compat (::Type{SortedDict{K,D}}){K,D}(kv) = SortedDict{K,D}(Forward, kv)
@compat function (::Type{SortedDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, kv)
(::Type{SortedDict{K,D}}){K,D}(kv) = SortedDict{K,D}(Forward, kv)
function (::Type{SortedDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, kv)
try
SortedDict{K,D,Ord}(o, kv)
catch e
Expand Down Expand Up @@ -129,7 +129,7 @@ end

@inline function find(m::SortedDict, k_)
ll, exactfound = findkey(m.bt, convert(keytype(m),k_))
IntSemiToken(exactfound? ll : 2)
IntSemiToken(exactfound ? ll : 2)
end

## This function inserts an item into the tree.
Expand Down Expand Up @@ -196,7 +196,7 @@ end

@inline function get{K,D,Ord <: Ordering}(m::SortedDict{K,D,Ord}, k_, default_)
i, exactfound = findkey(m.bt, convert(K,k_))
return exactfound? m.bt.data[i].d : convert(D,default_)
return exactfound ? m.bt.data[i].d : convert(D,default_)
end


Expand All @@ -215,7 +215,7 @@ end

function getkey{K,D,Ord <: Ordering}(m::SortedDict{K,D,Ord}, k_, default_)
i, exactfound = findkey(m.bt, convert(K,k_))
exactfound? m.bt.data[i].k : convert(K, default_)
exactfound ? m.bt.data[i].k : convert(K, default_)
end

## Function delete! deletes an item at a given
Expand Down
10 changes: 5 additions & 5 deletions src/sorted_multi_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Unlike SortedDict, a key in SortedMultiDict can
## refer to multiple data entries.

@compat type SortedMultiDict{K, D, Ord <: Ordering}
type SortedMultiDict{K, D, Ord <: Ordering}
bt::BalancedTree23{K,D,Ord}

## Base constructors
Expand Down Expand Up @@ -34,8 +34,8 @@ SortedMultiDict{O<:Ordering}(o::O) = SortedMultiDict{Any,Any,O}(o)
# Construction from Pairs
SortedMultiDict(ps::Pair...) = SortedMultiDict(Forward, ps)
SortedMultiDict(o::Ordering, ps::Pair...) = SortedMultiDict(o, ps)
@compat (::Type{SortedMultiDict{K,D}}){K,D}(ps::Pair...) = SortedMultiDict{K,D,ForwardOrdering}(Forward, ps)
@compat (::Type{SortedMultiDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, ps::Pair...) = SortedMultiDict{K,D,Ord}(o, ps)
(::Type{SortedMultiDict{K,D}}){K,D}(ps::Pair...) = SortedMultiDict{K,D,ForwardOrdering}(Forward, ps)
(::Type{SortedMultiDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, ps::Pair...) = SortedMultiDict{K,D,Ord}(o, ps)

# Construction from Associatives
SortedMultiDict{K,D,Ord<:Ordering}(o::Ord, d::Associative{K,D}) = SortedMultiDict{K,D,Ord}(o, d)
Expand All @@ -44,8 +44,8 @@ SortedMultiDict{K,D,Ord<:Ordering}(o::Ord, d::Associative{K,D}) = SortedMultiDic

# Construction specifying Key/Value types
# e.g., SortedMultiDict{Int,Float64}([1=>1, 2=>2.0])
@compat (::Type{SortedMultiDict{K,D}}){K,D}(kv) = SortedMultiDict{K,D}(Forward, kv)
@compat function (::Type{SortedMultiDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, kv)
(::Type{SortedMultiDict{K,D}}){K,D}(kv) = SortedMultiDict{K,D}(Forward, kv)
function (::Type{SortedMultiDict{K,D}}){K,D,Ord<:Ordering}(o::Ord, kv)
try
SortedMultiDict{K,D,Ord}(o, kv)
catch e
Expand Down
14 changes: 7 additions & 7 deletions src/sorted_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## methods similiar to those of the julia Set.


@compat type SortedSet{K, Ord <: Ordering}
type SortedSet{K, Ord <: Ordering}
bt::BalancedTree23{K,Void,Ord}

function (::Type{SortedSet{K,Ord}}){K,Ord<:Ordering}(o::Ord=Forward, iter=[])
Expand All @@ -25,14 +25,14 @@ SortedSet(o1::Ordering,o2::Ordering) =
SortedSet(o::Ordering, iter) = sortedset_with_eltype(o, iter, eltype(iter))
SortedSet(iter, o::Ordering=Forward) = sortedset_with_eltype(o, iter, eltype(iter))

@compat (::Type{SortedSet{K}}){K}() = SortedSet{K,ForwardOrdering}(Forward)
@compat (::Type{SortedSet{K}}){K,O<:Ordering}(o::O) = SortedSet{K,O}(o)
(::Type{SortedSet{K}}){K}() = SortedSet{K,ForwardOrdering}(Forward)
(::Type{SortedSet{K}}){K,O<:Ordering}(o::O) = SortedSet{K,O}(o)

# To address ambiguity warnings on Julia v0.4
@compat (::Type{SortedSet{K}}){K}(o1::Ordering,o2::Ordering) =
(::Type{SortedSet{K}}){K}(o1::Ordering,o2::Ordering) =
throw(ArgumentError("SortedSet with two parameters must be called with an Ordering and an interable"))
@compat (::Type{SortedSet{K}}){K}(o::Ordering, iter) = sortedset_with_eltype(o, iter, K)
@compat (::Type{SortedSet{K}}){K}(iter, o::Ordering=Forward) = sortedset_with_eltype(o, iter, K)
(::Type{SortedSet{K}}){K}(o::Ordering, iter) = sortedset_with_eltype(o, iter, K)
(::Type{SortedSet{K}}){K}(iter, o::Ordering=Forward) = sortedset_with_eltype(o, iter, K)

sortedset_with_eltype{K,Ord}(o::Ord, iter, ::Type{K}) = SortedSet{K,Ord}(o, iter)

Expand All @@ -47,7 +47,7 @@ const SetSemiToken = IntSemiToken

@inline function find(m::SortedSet, k_)
ll, exactfound = findkey(m.bt, convert(keytype(m),k_))
IntSemiToken(exactfound? ll : 2)
IntSemiToken(exactfound ? ll : 2)
end


Expand Down
6 changes: 3 additions & 3 deletions src/tokens2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ end


@inline status(ii::Token) =
!(ii[2].address in ii[1].bt.useddatacells)? 0 :
ii[2].address == 1? 2 :
ii[2].address == 2? 3 : 1
!(ii[2].address in ii[1].bt.useddatacells) ? 0 :
ii[2].address == 1 ? 2 :
ii[2].address == 2 ? 3 : 1

"""
compare(m::SAContainer, s::IntSemiToken, t::IntSemiToken)
Expand Down
6 changes: 2 additions & 4 deletions src/trie.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@compat type Trie{T}
type Trie{T}
value::T
children::Dict{Char,Trie{T}}
is_key::Bool
Expand Down Expand Up @@ -126,6 +126,4 @@ function done(it::TrieIterator, state)
end

path(t::Trie, str::AbstractString) = TrieIterator(t, str)
if VERSION >= v"0.5.0-dev+3294"
Base.iteratorsize(::Type{TrieIterator}) = Base.SizeUnknown()
end
Base.iteratorsize(::Type{TrieIterator}) = Base.SizeUnknown()
2 changes: 0 additions & 2 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
BaseTestNext
Primes 0.1.1
Compat 0.9.5
10 changes: 2 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
if VERSION >= v"0.5.0-dev+7720"
using Base.Test
else
using BaseTestNext
const Test = BaseTestNext
end
using Base.Test
using DataStructures
const IntSet = DataStructures.IntSet
import Compat: String
using Primes

if VERSION >= v"0.5.0" && VERSION < v"0.6.0-dev"
if VERSION < v"0.6.0-dev"
@test isempty(detect_ambiguities(Base, Core, DataStructures))
end

Expand Down
Loading

0 comments on commit c3059a9

Please sign in to comment.