Skip to content

Commit

Permalink
Merge pull request #9 from timbitz/master
Browse files Browse the repository at this point in the history
Update for Julia 1.0
  • Loading branch information
quinnj authored Mar 29, 2019
2 parents d1d1fb9 + b9a94dc commit 239af21
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:
- linux
- osx
julia:
- 0.5
- 1.0
- nightly
notifications:
email: false
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ A Julia interface to working with [Suffix Arrays](http://en.wikipedia.org/wiki/S

You can use the package by running:
```julia
Pkg.add("SuffixArrays")
using Pkg
add("SuffixArrays")
#Pkg.add("SuffixArrays") for julia prior to v0.7
using SuffixArrays
sa = suffixsort("banana")
sa.index # access the underlying sorted suffix array; returned indices are currently 0-based
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
julia 0.5
julia 1.0
4 changes: 2 additions & 2 deletions src/SuffixArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module SuffixArrays

export suffixsort

immutable SuffixArray{S<:AbstractString,N<:Signed}
struct SuffixArray{S<:AbstractString,N<:Signed}
string::S
n::Int
index::Array{N,1}
end

function SuffixArray{S}(s::S)
function SuffixArray(s::S) where S <: AbstractString
n = length(s)
index = zeros(n <= typemax(Int8) ? Int8 :
n <= typemax(Int16) ? Int16 :
Expand Down
2 changes: 1 addition & 1 deletion src/sais.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
=#

#= Suffixsorting =#
type IntArray
mutable struct IntArray
a::Array{Int,1}
pos::Int
end
Expand Down
16 changes: 11 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using SuffixArrays
using Base.Test
using Test

readstring(s) = read(s, String)

function test_suffix(args)
for file in args
T = open(readstring,file)
tic()
SA = suffixsort(T)
t = toq()
t = @elapsed SA = suffixsort(T)
println("Sorting '$file' took: $t")
@test sufcheck(T,SA.index) == 0
end
Expand Down Expand Up @@ -69,6 +69,12 @@ function sufcheck(T,SA)
return 0
end

function initwalk(dir, files)
files = walkdir("$dir/src", files)
files = walkdir("$dir/test", files)
files
end

function walkdir(dir,files)
t = readdir(dir)
for f in t
Expand All @@ -83,5 +89,5 @@ function walkdir(dir,files)
return unique(files)
end

files = walkdir(dirname(dirname(@__FILE__)),[])
files = initwalk(dirname(dirname(@__FILE__)),[])
test_suffix(files)

0 comments on commit 239af21

Please sign in to comment.