MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / construct

Method construct

animations/segmenttree.py:188–212  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

186 self.play(n.set_color, RED)
187
188 def construct(self):
189 self.start_logo(animate=False)
190 self.init_message("更新线段树")
191 array = AlgoVector(self, self.datas)
192 array.set_color(BLUE)
193 self.play(ShowCreation(array))
194 self.play(array.to_edge, LEFT)
195 self.array = array
196
197 self.tree = AlgoSegTree(self, self.datas).scale(0.9)
198 self.tree.to_edge(edge=RIGHT).shift(LEFT)
199 self.play(ShowCreation(self.tree))
200 # 3 -> 7
201 self.show_messaged("比如将3更新为7")
202 new_node = AlgoNode("7", color=RED)
203 self.play(ShowCreation(new_node))
204 self.play(new_node.next_to, self.array.get_node(3), DOWN)
205 arrow = Arrow(new_node, self.array.get_node(3)).set_color(BLUE)
206 self.play(ShowCreation(arrow))
207
208 self.show_message("首先是找到元素")
209
210 # find
211 self.find_element(self.tree.root, 3, 7)
212 self.wait(10)
213
214class SegmentTreeQuery(SegmentTreeBase):
215 def __init__(self, **kwargs):

Callers

nothing calls this directly

Calls 10

find_elementMethod · 0.95
AlgoVectorClass · 0.85
AlgoSegTreeClass · 0.85
AlgoNodeClass · 0.85
start_logoMethod · 0.80
init_messageMethod · 0.80
show_messagedMethod · 0.80
scaleMethod · 0.45
get_nodeMethod · 0.45
show_messageMethod · 0.45

Tested by

no test coverage detected