remove extra layer of redirection in avl tree

This commit is contained in:
IlyaShurupov 2024-04-01 13:57:10 +03:00 committed by Ilya Shurupov
parent 4d381d62e4
commit 3148e2c020
2 changed files with 42 additions and 45 deletions

View file

@ -21,15 +21,19 @@ namespace tp {
inline bool exactNode(const IntervalKey& in) const { return in.mStart == mStart && in.mEnd == mEnd; }
inline const IntervalKey& getFindKey() const { return *this; }
template <typename tTreeNodeType>
inline const IntervalKey& getFindKey(const tTreeNodeType* node) const {
return *this;
}
inline const IntervalKey& keyInRightSubtree(const IntervalKey& in) const { return in; }
inline const IntervalKey& keyInLeftSubtree(const IntervalKey& in) const { return in; }
template <typename tTreeNodeType>
inline void updateTreeCacheCallBack(const tTreeNodeType& node) {
inline void updateTreeCacheCallBack(const tTreeNodeType* node) {
mMax = 0;
if (node.mRight && node.mRight->key.mMax > mMax) mMax = node.mRight->key.mMax;
if (node.mLeft && node.mLeft->key.mMax > mMax) mMax = node.mLeft->key.mMax;
if (node->mRight && node->mRight->key.mMax > mMax) mMax = node->mRight->key.mMax;
if (node->mLeft && node->mLeft->key.mMax > mMax) mMax = node->mLeft->key.mMax;
if (mMax < mEnd) mMax = mEnd;
}