63#include "SoShaderSystem.h"
66template <
class KeyType,
class ValueType>
137 return mParent ==
nullptr;
140 return mParent !=
nullptr && mParent->
getLeftChild() ==
this;
143 return mParent !=
nullptr && mParent->
getRightChild() ==
this;
146 return mLeftChild ==
nullptr && mRightChild ==
nullptr;
175template <
class KeyType,
class ValueType>
204 mCur = (
atLowest) ? minNode(mRoot) : maxNode(mRoot);
209 return mCur ==
nullptr;
238 throw "Iterator at end";
248 while(
n &&
n->getLeftChild())
255 while(
n &&
n->getRightChild())
345 return mCur==
nullptr;
369 throw "ParentFirstIterator at end";
392 while(mCur !=
nullptr) {
428 mCur = minNode(mRoot);
433 return mCur ==
nullptr;
457 throw "ParentLastIterator at end";
465 while(
n !=
nullptr && (
n->getLeftChild() != 0 ||
n->getRightChild() != 0)) {
518 if(
src.mArray !=
nullptr) {
519 mArray =
new Node*[(mSize+1)/2];
528 if(mArray !=
nullptr) {
537 if(mArray ==
nullptr) {
540 mArray =
new Node*[(mSize+1)/2];
562 if(
src.mArray !=
nullptr) {
563 mArray =
new Node*[(mSize+1)/2];
583 throw "ParentLastIterator at end";
598 for(
unsigned int i = 0;
i < mEndPos;
i++) {
599 mArray[
i] = mArray[
i+1];
620 unsigned int mEndPos;
641 mTree.
set(mKey, value);
645 operator ValueType() {
649 if(node ==
nullptr) {
650 throw "Item not found";
689 set(
i->getKey(),
i->getValue());
704 if(
newNode->getParent()->isLeftChild()) {
711 newNode->getParent()->getParent()->setRed();
724 newNode->getParent()->setBlack();
725 newNode->getParent()->getParent()->setRed();
726 RotateRight(
newNode->getParent()->getParent());
736 newNode->getParent()->getParent()->setRed();
749 newNode->getParent()->setBlack();
750 newNode->getParent()->getParent()->setRed();
751 RotateLeft(
newNode->getParent()->getParent());
813 Node *p =
i.getNode();
824 return mRoot ==
nullptr;
832 while(
pNode !=
nullptr) {
895 if(mRoot ==
nullptr) {
910 if(
pNode->getLeftChild() == 0) {
920 if(
pNode->getRightChild() == 0) {
940 void RotateLeft(
Node *p) {
941 Node *right = p->getRightChild();
943 p->setRightChild(right->getLeftChild());
945 if(p->isLeftChild()) {
946 p->getParent()->setLeftChild(right);
948 else if(p->isRightChild()) {
949 p->getParent()->setRightChild(right);
954 right->setLeftChild(p);
959 void RotateRight(
Node *p) {
960 Node *left = p->getLeftChild();
962 p->setLeftChild(left->getRightChild());
964 if(p->isLeftChild()) {
965 p->getParent()->setLeftChild(left);
967 else if(p->isRightChild()) {
968 p->getParent()->setRightChild(left);
973 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)
SbMapItem< KeyType, ValueType > Node
AccessClass operator[](const KeyType &k)
bool insert(const KeyType &keyNew, const ValueType &v)
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.