Skip to content

Commit 646619e

Browse files
committed
Rename NaturalTree -> NaturalIndex and fix typos everywhere
1 parent f31a6da commit 646619e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/utils/NaturalIndexing.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using ..SpatialTreeInterface
77

88
import ..GeometryOps as GO # TODO: only needed for NaturallyIndexedRing, remove when that is removed.
99

10-
export NaturalTree, NaturallyIndexedRing, prepare_naturally
10+
export NaturalIndex, NaturallyIndexedRing, prepare_naturally
1111

1212
"""
1313
NaturalLevel{E <: Extents.Extent}
@@ -124,7 +124,7 @@ end
124124

125125
# This is like a pointer to a node in the tree.
126126
"""
127-
NaturalTreeNode{E <: Extents.Extent}
127+
NaturalIndexNode{E <: Extents.Extent}
128128
129129
A reference to a node in the natural tree. Kind of like a tree cursor.
130130
@@ -133,14 +133,14 @@ A reference to a node in the natural tree. Kind of like a tree cursor.
133133
- `index` is the index of the node in the level
134134
- `extent` is the extent of the node
135135
"""
136-
struct NaturalTreeNode{E <: Extents.Extent}
136+
struct NaturalIndexNode{E <: Extents.Extent}
137137
parent_index::NaturalIndex{E}
138138
level::Int
139139
index::Int
140140
extent::E
141141
end
142142

143-
Extents.extent(node::NaturalTreeNode) = node.extent
143+
Extents.extent(node::NaturalIndexNode) = node.extent
144144

145145
# What does SpatialTreeInterface require of trees?
146146
# - Parents completely cover their children
@@ -152,18 +152,18 @@ Extents.extent(node::NaturalTreeNode) = node.extent
152152
# - `isleaf(node)` returns a boolean indicating whether the node is a leaf
153153
# - `child_indices_extents(node)` returns an iterator over the indices and extents of the children of the node
154154

155-
SpatialTreeInterface.isspatialtree(::Type{<: NaturalIndexing}) = true
156-
SpatialTreeInterface.isspatialtree(::Type{<: NaturalTreeNode}) = true
155+
SpatialTreeInterface.isspatialtree(::Type{<: NaturalIndex}) = true
156+
SpatialTreeInterface.isspatialtree(::Type{<: NaturalIndexNode}) = true
157157

158-
function SpatialTreeInterface.nchild(node::NaturalTreeNode)
158+
function SpatialTreeInterface.nchild(node::NaturalIndexNode)
159159
start_idx = (node.index - 1) * node.parent_index.nodecapacity + 1
160160
stop_idx = min(start_idx + node.parent_index.nodecapacity - 1, length(node.parent_index.levels[node.level+1].extents))
161161
return stop_idx - start_idx + 1
162162
end
163163

164-
function SpatialTreeInterface.getchild(node::NaturalTreeNode, i::Int)
164+
function SpatialTreeInterface.getchild(node::NaturalIndexNode, i::Int)
165165
child_index = (node.index - 1) * node.parent_index.nodecapacity + i
166-
return NaturalTreeNode(
166+
return NaturalIndexNode(
167167
node.parent_index,
168168
node.level + 1, # increment level by 1
169169
child_index, # index of this particular child
@@ -172,13 +172,13 @@ function SpatialTreeInterface.getchild(node::NaturalTreeNode, i::Int)
172172
end
173173

174174
# Get all children of a node
175-
function SpatialTreeInterface.getchild(node::NaturalTreeNode)
175+
function SpatialTreeInterface.getchild(node::NaturalIndexNode)
176176
return (SpatialTreeInterface.getchild(node, i) for i in 1:SpatialTreeInterface.nchild(node))
177177
end
178178

179-
SpatialTreeInterface.isleaf(node::NaturalTreeNode) = node.level == length(node.parent_index.levels) - 1
179+
SpatialTreeInterface.isleaf(node::NaturalIndexNode) = node.level == length(node.parent_index.levels) - 1
180180

181-
function SpatialTreeInterface.child_indices_extents(node::NaturalTreeNode)
181+
function SpatialTreeInterface.child_indices_extents(node::NaturalIndexNode)
182182
start_idx = (node.index - 1) * node.parent_index.nodecapacity + 1
183183
stop_idx = min(start_idx + node.parent_index.nodecapacity - 1, length(node.parent_index.levels[node.level+1].extents))
184184
return ((i, node.parent_index.levels[node.level+1].extents[i]) for i in start_idx:stop_idx)
@@ -190,8 +190,8 @@ SpatialTreeInterface.isleaf(node::NaturalIndex) = length(node.levels) == 1
190190

191191
SpatialTreeInterface.nchild(node::NaturalIndex) = length(node.levels[1].extents)
192192

193-
SpatialTreeInterface.getchild(node::NaturalIndex) = SpatialTreeInterface.getchild(NaturalTreeNode(node, 0, 1, node.extent))
194-
SpatialTreeInterface.getchild(node::NaturalIndex, i) = SpatialTreeInterface.getchild(NaturalTreeNode(node, 0, 1, node.extent), i)
193+
SpatialTreeInterface.getchild(node::NaturalIndex) = SpatialTreeInterface.getchild(NaturalIndexNode(node, 0, 1, node.extent))
194+
SpatialTreeInterface.getchild(node::NaturalIndex, i) = SpatialTreeInterface.getchild(NaturalIndexNode(node, 0, 1, node.extent), i)
195195

196196
SpatialTreeInterface.child_indices_extents(node::NaturalIndex) = (i_ext for i_ext in enumerate(node.levels[1].extents))
197197

0 commit comments

Comments
 (0)