MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / AddNode

Method AddNode

src/core/kdtree.hpp:52–63  ·  view source on GitHub ↗

Create one new node in the tree, return its index in the pool */

Source from the content-addressed store, hash-verified

50
51 /** Create one new node in the tree, return its index in the pool */
52 size_t AddNode(const T &element)
53 {
54 if (this->free_list.empty()) {
55 this->nodes.emplace_back(element);
56 return this->nodes.size() - 1;
57 } else {
58 size_t newidx = this->free_list.back();
59 this->free_list.pop_back();
60 this->nodes[newidx] = node{ element };
61 return newidx;
62 }
63 }
64
65 /** Find a coordinate value to split a range of elements at */
66 template <typename It>

Callers 5

BuildSubtreeMethod · 0.95
InsertRecursiveMethod · 0.95
InsertMethod · 0.95
IncreaseStatsFunction · 0.45
UpdateStationWaitingFunction · 0.45

Calls 3

pop_backMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected