63#include "SoShaderSystem.h"
66template <
class KeyType,
class ValueType>
class SbMapItem
154 return mParent ==
nullptr;
158 return mParent !=
nullptr && mParent->
getLeftChild() ==
this;
162 return mParent !=
nullptr && mParent->
getRightChild() ==
this;
166 return mLeftChild ==
nullptr && mRightChild ==
nullptr;
197template <
class KeyType,
class ValueType>
class SbMap
230 mCur = (
atLowest) ? minNode(mRoot) : maxNode(mRoot);
236 return mCur ==
nullptr;
271 throw "Iterator at end";
281 while (
n &&
n->getLeftChild())
289 while (
n &&
n->getRightChild())
387 return mCur ==
nullptr;
416 throw "ParentFirstIterator at end";
439 while (mCur !=
nullptr) {
480 mCur = minNode(mRoot);
486 return mCur ==
nullptr;
515 throw "ParentLastIterator at end";
523 while (
n !=
nullptr && (
n->getLeftChild() != 0 ||
n->getRightChild() != 0)) {
585 , mEndPos(
src.mEndPos)
587 if (
src.mArray !=
nullptr) {
588 mArray =
new Node*[(mSize + 1) / 2];
598 if (mArray !=
nullptr) {
608 if (mArray ==
nullptr) {
611 mArray =
new Node*[(mSize + 1) / 2];
636 if (
src.mArray !=
nullptr) {
637 mArray =
new Node*[(mSize + 1) / 2];
660 throw "ParentLastIterator at end";
675 for (
unsigned int i = 0;
i < mEndPos;
i++) {
676 mArray[
i] = mArray[
i + 1];
696 unsigned int mEndPos;
717 mTree.
set(mKey, value);
726 if (node ==
nullptr) {
727 throw "Item not found";
775 set(
i->getKey(),
i->getValue());
791 if (
newNode->getParent()->isLeftChild()) {
798 newNode->getParent()->getParent()->setRed();
811 newNode->getParent()->setBlack();
812 newNode->getParent()->getParent()->setRed();
813 RotateRight(
newNode->getParent()->getParent());
823 newNode->getParent()->getParent()->setRed();
836 newNode->getParent()->setBlack();
837 newNode->getParent()->getParent()->setRed();
838 RotateLeft(
newNode->getParent()->getParent());
903 Node* p =
i.getNode();
915 return mRoot ==
nullptr;
924 while (
pNode !=
nullptr) {
985 if (mRoot !=
nullptr)
995 if (mRoot ==
nullptr) {
1010 if (
pNode->getLeftChild() == 0) {
1020 if (
pNode->getRightChild() == 0) {
1040 void RotateLeft(
Node* p)
1042 Node* right = p->getRightChild();
1044 p->setRightChild(right->getLeftChild());
1046 if (p->isLeftChild()) {
1047 p->getParent()->setLeftChild(right);
1049 else if (p->isRightChild()) {
1050 p->getParent()->setRightChild(right);
1055 right->setLeftChild(p);
1060 void RotateRight(
Node* p)
1062 Node* left = p->getLeftChild();
1064 p->setLeftChild(left->getRightChild());
1066 if (p->isLeftChild()) {
1067 p->getParent()->setLeftChild(left);
1069 else if (p->isRightChild()) {
1070 p->getParent()->setRightChild(left);
1075 left->setRightChild(p);
KeyType
SoKeyGrabber is a general facility to grab keyboard events.
Class SbMapItem is the element type of the SbMap tree.
SbMapItem * getParent() const
const KeyType & getKey() const
SbMapItem(const KeyType &k, const ValueType &v)
bool isRightChild() const
void setLeftChild(SbMapItem *p)
void setRightChild(SbMapItem *p)
void setValue(const ValueType &v)
unsigned int GetLevel() const
void setParent(SbMapItem *p)
const ValueType & getValue() const
SbMapItem * getLeftChild() const
SbMapItem * getRightChild() const
AccessClass is a temporary class used with the [] operator on an SbMap.
operator=(const ValueType &value)
SbMap::ByLevelIterator for an SbMap, traversing the map top to bottom, level by level left to right....
ByLevelIterator(const ByLevelIterator &src)
ByLevelIterator(Node *root, unsigned int size)
ByLevelIterator & operator=(const ByLevelIterator &src)
Regular low->high (++) and high->low (–) iterator class for an SbMap.
Iterator(const Iterator &src)
Iterator & operator=(const Iterator &src)
void reset(bool atLowest=true)
SbMap::ParentFirstIterator for an SbMap, traversing the map from top to bottom.
ParentFirstIterator(Node *root)
ParentFirstIterator & operator=(const ParentFirstIterator &src)
SbMap::ParentFirstIterator for an SbMap, traversing the map from bottom to top.
ParentLastIterator & operator=(const ParentLastIterator &src)
ParentLastIterator(Node *root)
Open Inventor container that associates objects of type KeyType with objects of type ValueType.
ParentFirstIterator getParentFirstIterator()
ByLevelIterator getByLevelIterator()
void set(const KeyType &k, const ValueType &v)
AccessClass operator[](const KeyType &k)
bool insert(const KeyType &keyNew, const ValueType &v)
SbMapItem< KeyType, ValueType > Node
ParentLastIterator getParentLastIterator()
unsigned int size() const
Node * find(const KeyType &keyToFind) const
SbMap & operator=(const SbMap &src)
bool remove(const KeyType &k)
Target mlrange_cast(Source arg)
Generic version of checked ML casts.