diff --git a/src/Stuffing.jl b/src/Stuffing.jl index a0515ba..54762f9 100644 --- a/src/Stuffing.jl +++ b/src/Stuffing.jl @@ -4,7 +4,7 @@ export QTrees, getshift, getcenter, setshift!, setcenter!, outofbounds, outofker dynamiccollisions, partialcollisions, totalcollisions, collision, findroom_uniform, findroom_gathering, DynamicColliders, locate!, linked_spacial_qtree, hash_spacial_qtree export Trainer, train!, fit!, Momentum, SGD -include("linkedlist.jl") +include("common_datatypes.jl") include("qtrees.jl") include("fit.jl") using .QTrees diff --git a/src/linkedlist.jl b/src/common_datatypes.jl similarity index 97% rename from src/linkedlist.jl rename to src/common_datatypes.jl index 2954a70..36d5936 100644 --- a/src/linkedlist.jl +++ b/src/common_datatypes.jl @@ -1,5 +1,5 @@ -module LinkedList -export DoubleList, ListNode, movetofirst!, IntMap, next, prev, value, setvalue!, ishead, istail, seek_head, seek_tail +module CommonDatatypes +export DoubleList, ListNode, IntMap, movetofirst!, next, prev, value, setvalue!, ishead, istail, seek_head, seek_tail mutable struct ListNode{T} value::T prev::ListNode{T} @@ -137,11 +137,11 @@ function collect!(filter, l::DoubleList, collection, firstn) end Base.collect(l::DoubleList{T}, args...) where T = collect!(l, Vector{T}(), args...) Base.collect(filter, l::DoubleList{T}, args...) where T = collect!(filter, l, Vector{T}(), args...) + struct IntMap{T} map::T end Base.haskey(im::IntMap, key) = isassigned(im.map, key) Base.getindex(im::IntMap, ind...) = getindex(im.map, ind...) Base.setindex!(im::IntMap, v, ind...) = setindex!(im.map, v, ind...) - end diff --git a/src/fit_helper.jl b/src/fit_helper.jl index 4a19a79..cba99a6 100644 --- a/src/fit_helper.jl +++ b/src/fit_helper.jl @@ -1,4 +1,4 @@ -using ..LinkedList +using ..CommonDatatypes abstract type AbstractOptimiser end function apply(o::AbstractOptimiser, x, Δ) end function apply!(o::AbstractOptimiser, x, Δ) @@ -95,8 +95,8 @@ function Base.push!(lru::LRU, v) end v end -collect!(lru::LRU, args...) = LinkedList.collect!(lru.list, args...) -Base.collect(lru::LRU, args...) = LinkedList.collect(lru.list, args...) +collect!(lru::LRU, args...) = CommonDatatypes.collect!(lru.list, args...) +Base.collect(lru::LRU, args...) = CommonDatatypes.collect(lru.list, args...) Base.broadcastable(lru::LRU) = Ref(lru) intlru(n) = LRU{Int}(IntMap(Vector{ListNode{Int}}(undef, n))) diff --git a/src/qtrees.jl b/src/qtrees.jl index 768c0d7..05c7cd6 100644 --- a/src/qtrees.jl +++ b/src/qtrees.jl @@ -7,7 +7,7 @@ export AbstractStackedQTree, StackedQTree, ShiftedQTree, buildqtree!, kernelsize, place!, overlap, overlap!, decode, charimage using Random -using ..LinkedList +using ..CommonDatatypes const PERM4 = ((0, 1, 2, 3), (0, 1, 3, 2), (0, 2, 1, 3), (0, 2, 3, 1), (0, 3, 1, 2), (0, 3, 2, 1), (1, 0, 2, 3), (1, 0, 3, 2), (1, 2, 0, 3), (1, 2, 3, 0), (1, 3, 0, 2), (1, 3, 2, 0),