Skip to content

Commit b4b4570

Browse files
committed
clean up
1 parent b7dedfb commit b4b4570

File tree

5 files changed

+5
-64
lines changed

5 files changed

+5
-64
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Added B+tree multimap for internal (future) use. [#93](https://github.com/tzaeschke/phtree-cpp/issues/93)
1111

1212
### Changed
13-
- Rewrote relocate(). This should be much cleaner now and slightly faster. [#98](https://github.com/tzaeschke/phtree-cpp/pull/98)
13+
- Rewrote relocate(). This should be much cleaner now and slightly faster.
14+
[#98](https://github.com/tzaeschke/phtree-cpp/pull/98), [#99](https://github.com/tzaeschke/phtree-cpp/pull/99)
15+
1416
- Cleaned up HandleCollision() and key comparison functions. [#97](https://github.com/tzaeschke/phtree-cpp/pull/97)
1517
- Improved performance by eliminating memory indirection for DIM > 3.
1618
This was enabled by referencing "Node" directly in "Entry" which was enabled by
1719
implanting an indirection in array_map. [#96](https://github.com/tzaeschke/phtree-cpp/pull/96)
1820
- Improved performance of window queries by executing them partially as point queries.
1921
This works best for point datasets, and somewhat for box datasets with "include" queries.
2022
There is no benefit for "intersection" queries. [#88](https://github.com/tzaeschke/phtree-cpp/issues/88)
21-
- Improved benchmarks for insert and query to use a more compact format. [#91](https://github.com/tzaeschke/phtree-cpp/pull/91)
23+
- Improved benchmarks for insert and query to use a more compact format.
24+
[#91](https://github.com/tzaeschke/phtree-cpp/pull/91)
2225
- Improved performance of window queries by optimizing calculation of min/max masks.
2326
Improved performance of queries and updates by changing bit-width of min/max masks and
2427
hc_pos_t. [#95](https://github.com/tzaeschke/phtree-cpp/pull/95)

include/phtree/common/common.h

-35
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,6 @@ static bit_width_t NumberOfDivergingBits(
103103
return MAX_BIT_WIDTH<SCALAR> - CountLeadingZeros(diff2);
104104
}
105105

106-
//template <dimension_t DIM, typename SCALAR>
107-
//static bit_width_t NumberOfDivergingBits2(
108-
// const PhPoint<DIM, SCALAR>& v1, const PhPoint<DIM, SCALAR>& v2) {
109-
// // write all differences to diff, we just check diff afterwards
110-
// SCALAR diff = 0;
111-
// //bit_mask_t<SCALAR> diff = 0;
112-
// for (dimension_t i = 0; i < DIM; ++i) {
113-
// diff |= v1[i] ^ v2[i];
114-
// }
115-
// bit_mask_t<SCALAR> diff2 = reinterpret_cast<bit_mask_t<SCALAR>&>(diff);
116-
// assert(CountLeadingZeros(diff2) <= MAX_BIT_WIDTH<SCALAR>);
117-
// return MAX_BIT_WIDTH<SCALAR> - CountLeadingZeros(diff2);
118-
//}
119-
120-
121106
template <dimension_t DIM, typename SCALAR>
122107
static bool KeyEquals(
123108
const PhPoint<DIM, SCALAR>& key_a, const PhPoint<DIM, SCALAR>& key_b, bit_width_t ignore_bits) {
@@ -127,26 +112,6 @@ static bool KeyEquals(
127112
}
128113
return diff >> ignore_bits == 0;
129114
}
130-
//template <dimension_t DIM, typename SCALAR>
131-
//static bool KeyEquals0(
132-
// const PhPoint<DIM, SCALAR>& key_a, const PhPoint<DIM, SCALAR>& key_b, SCALAR mask) {
133-
// for (dimension_t i = 0; i < DIM; ++i) {
134-
// if (((key_a[i] ^ key_b[i]) & mask) != 0) {
135-
// return false;
136-
// }
137-
// }
138-
// return true;
139-
//}
140-
//
141-
//template <dimension_t DIM, typename SCALAR>
142-
//static bool KeyEquals1(
143-
// const PhPoint<DIM, SCALAR>& key_a, const PhPoint<DIM, SCALAR>& key_b, SCALAR mask) {
144-
// SCALAR sum = 0;
145-
// for (dimension_t i = 0; i < DIM; ++i) {
146-
// sum |= (key_a[i] ^ key_b[i]);
147-
// }
148-
// return (sum & mask) == 0;
149-
//}
150115

151116
// ************************************************************************
152117
// String helpers

include/phtree/v16/entry.h

-5
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@ class Entry {
177177
kd_key_ = key;
178178
}
179179

180-
void SetValue(T&& value) noexcept {
181-
assert(union_type_ == VALUE);
182-
value_ = std::move(value);
183-
}
184-
185180
void SetNode(NodeT&& node, bit_width_t postfix_len) noexcept {
186181
postfix_len_ = static_cast<std::uint16_t>(postfix_len);
187182
DestroyUnion();

include/phtree/v16/phtree_v16.h

-21
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ class PhTreeV16 {
595595
return std::make_pair(iter1, iter2);
596596
}
597597

598-
public:
599598
/*
600599
* Iterates over all entries in the tree. The optional filter allows filtering entries and nodes
601600
* (=sub-trees) before returning / traversing them. By default, all entries are returned. Filter
@@ -775,26 +774,6 @@ class PhTreeV16 {
775774
return {parent, entry_iter};
776775
}
777776

778-
std::pair<EntryT*, EntryIteratorC<DIM, EntryT>> find_starting_node(
779-
const KeyT& key1, const KeyT& key2, bit_width_t& max_conflicting_bits) {
780-
auto& prefix = key1;
781-
max_conflicting_bits = NumberOfDivergingBits(key1, key2);
782-
EntryT* parent = &root_;
783-
if (max_conflicting_bits > root_.GetNodePostfixLen()) {
784-
// Abort early if we have no shared prefix in the query
785-
return {&root_, root_.GetNode().Entries().end()};
786-
}
787-
EntryIterator<DIM, EntryT> entry_iter =
788-
root_.GetNode().FindPrefix(prefix, max_conflicting_bits, root_.GetNodePostfixLen());
789-
while (entry_iter != parent->GetNode().Entries().end() && entry_iter->second.IsNode() &&
790-
entry_iter->second.GetNodePostfixLen() >= max_conflicting_bits) {
791-
parent = &entry_iter->second;
792-
entry_iter = parent->GetNode().FindPrefix(
793-
prefix, max_conflicting_bits, parent->GetNodePostfixLen());
794-
}
795-
return {parent, entry_iter};
796-
}
797-
798777
size_t num_entries_;
799778
// Contract: root_ contains a Node with 0 or more entries. The root node is the only Node
800779
// that is allowed to have less than two entries.

test/phtree_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ TEST(PhTreeTest, TestUpdateWithRelocateIf) {
668668
TestPoint<dim> pNew{pOld[0] + delta, pOld[1] + delta, pOld[2] + delta};
669669
if ((delta > 0.0 && tree.find(pNew) != tree.end()) || (i % 2 != 0)) {
670670
// Skip this, there is already another entry
671-
std::cout << "x = " << x << " i=" << i << std::endl;
672671
ASSERT_EQ(0, tree.relocate_if(pOld, pNew, pred));
673672
} else {
674673
ASSERT_EQ(1, tree.relocate_if(pOld, pNew, pred));

0 commit comments

Comments
 (0)