public interface IRBNode : IComparable { IRBNode Left { get; set; } IRBNode Right { get; set; } Color Color { get; set; } IRBNode Parent { get; set; } IRBNode Grandparent(); IRBNode Sibling(); // { //#if ASSERT // Debug.Assert(Parent != null); // Root node has no sibling //#endif // if (this == Parent.Left) // return Parent.Right; // else // return Parent.Left; // } IRBNode Uncle(); // { //#if ASSERT // Debug.Assert(Parent != null); // Root node has no uncle // Debug.Assert(Parent.Parent != null); // Children of root have no uncle //#endif // return Parent.Sibling(); // } // } void AssignValueTo(IRBNode other); }转化为c++
时间: 2024-02-10 12:35:25 浏览: 125
// C++ 类定义
class IRBNode : public IComparable {
public:
virtual IRBNode* getLeft() = 0;
virtual void setLeft(IRBNode* node) = 0;
virtual IRBNode* getRight() = 0;
virtual void setRight(IRBNode* node) = 0;
virtual Color getColor() = 0;
virtual void setColor(Color color) = 0;
virtual IRBNode* getParent() = 0;
virtual void setParent(IRBNode* node) = 0;
virtual IRBNode* Grandparent() = 0;
virtual IRBNode* Sibling() = 0;
virtual IRBNode* Uncle() = 0;
virtual void AssignValueTo(IRBNode* other) = 0;
};
// 注意,这里使用了纯虚函数,需要在子类中实现这些方法。
阅读全文
相关推荐












