Skip to content

Commit abf58b2

Browse files
committed
Remove unused indexing utilities
1 parent d42b570 commit abf58b2

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

src/tree_map.jl

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,21 @@ import Base:
66
convert,
77
copy,
88
filter,
9-
firstindex,
109
foldl,
1110
foldr,
1211
foreach,
13-
getindex,
1412
hash,
1513
in,
1614
isempty,
1715
iterate,
1816
keys,
19-
lastindex,
2017
length,
2118
map,
2219
map!,
2320
mapfoldl,
2421
mapfoldr,
2522
mapreduce,
2623
reduce,
27-
setindex!,
2824
sum
2925
import Compat: @inline, Returns
3026
import ..UtilsModule: @memoize_on, @with_memoization
@@ -120,33 +116,6 @@ function any(f::F, tree::Node) where {F<:Function}
120116
end
121117
end
122118

123-
"""
124-
getindex(root::Node, i::Int)
125-
126-
Get the `i`th node of `root` in depth-first order. This does not require
127-
extra allocations, but does require a traversal of the tree for every call.
128-
Once the matching node is found, the traversal stops.
129-
"""
130-
function getindex(root::N, i::Int) where {N<:Node}
131-
return_tree = Ref(root)
132-
_extract!(return_tree, root, i, 0)
133-
return return_tree.x
134-
end
135-
function _extract!(return_tree::Ref{N}, tree::N, i::Int, iter::Int)::Int where {N<:Node}
136-
iter += 1
137-
if i == iter
138-
return_tree.x = tree
139-
return iter
140-
end
141-
if tree.degree == 1
142-
iter = _extract!(return_tree, tree.l, i, iter)
143-
elseif tree.degree == 2
144-
iter = _extract!(return_tree, tree.l, i, iter)
145-
iter = _extract!(return_tree, tree.r, i, iter)
146-
end
147-
return iter
148-
end
149-
150119
function Base.:(==)(a::Node{T}, b::Node{T})::Bool where {T}
151120
(degree = a.degree) != b.degree && return false
152121
if degree == 0
@@ -259,14 +228,6 @@ end
259228

260229
all(f::F, tree::Node) where {F<:Function} = !any(t -> !@inline(f(t)), tree)
261230

262-
function setindex!(root::Node{T}, insert::Node{T}, i::Int) where {T}
263-
set_node!(getindex(root, i), insert)
264-
return nothing
265-
end
266-
function setindex!(root::Node{T1}, insert::Node{T2}, i::Int) where {T1,T2}
267-
return setindex!(root, convert(Node{T1}, insert), i)
268-
end
269-
270231
function mapreduce(f::F, op::G, tree::Node) where {F<:Function,G<:Function}
271232
return tree_mapreduce(f, (n...) -> reduce(op, n), tree)
272233
end
@@ -276,9 +237,6 @@ iterate(root::Node) = (root, collect(root)[(begin + 1):end])
276237
iterate(::Node, stack) = isempty(stack) ? nothing : (popfirst!(stack), stack)
277238
in(item, tree::Node) = any(t -> t == item, tree)
278239
length(tree::Node) = sum(Returns(1), tree)
279-
firstindex(::Node) = 1
280-
lastindex(tree::Node) = length(tree)
281-
keys(tree::Node) = Base.OneTo(length(tree))
282240
function hash(tree::Node{T}) where {T}
283241
return tree_mapreduce(
284242
t -> hash(t.constant ? (0, t.val::T) : (1, t.feature)),

0 commit comments

Comments
 (0)