// Copyright: Matra-Datavision 1991 // File: PCollection_AVLNode.gxx // Created: Fri May 24 10:38:53 1991 // Author: Annick PANCHER // // Updated: Jean-Pierre TIRAULT Apr,6 1992, Mireille MERCIEN #include typedef PCollection_Side Side; typedef PCollection_AVLNode Node; typedef Handle(PCollection_AVLNode) Handle(Node); //--------------------------------------------------------------------------- // Create // -------------------------------------------------------------------------- PCollection_AVLNode::PCollection_AVLNode(const Item& theItem) { MyItem = theItem; Count = 1; MyRightChild.Nullify(); MyLeftChild.Nullify(); } // -------------------------- READING --------------------------------------- //---------------------------------------------------------------------------- // RightChild // -------------------------------------------------------------------------- Handle(Node) PCollection_AVLNode::RightChild () const { return MyRightChild; } //--------------------------------------------------------------------------- // LeftChild // -------------------------------------------------------------------------- Handle(Node) PCollection_AVLNode::LeftChild () const { return MyLeftChild; } //-------------------------------------------------------------------------- // Value // -------------------------------------------------------------------------- Item PCollection_AVLNode::Value () const { return MyItem; } //--------------------------------------------------------------------------- // GetMultiplicity // -------------------------------------------------------------------------- Integer PCollection_AVLNode::GetMultiplicity () const { return Count; } // -------------------- WRITING --------------------------------------------- //-------------------------------------------------------------------------- // Setvalue // -------------------------------------------------------------------------- void PCollection_AVLNode::SetValue(const Item& theValue) { MyItem = theValue; } //--------------------------------------------------------------------------- // SetRightChild // -------------------------------------------------------------------------- void PCollection_AVLNode:: SetRightChild(const Handle(Node)& theNode) { MyRightChild = theNode; } //-------------------------------------------------------------------------- // SetLeftChild // -------------------------------------------------------------------------- void PCollection_AVLNode:: SetLeftChild(const Handle(Node)& theNode) { MyLeftChild = theNode; } //--------------------------------------------------------------------------- // SetChild // -------------------------------------------------------------------------- void PCollection_AVLNode::SetChild ( const Handle(Node)& theNode, const Side theSide) { if (theSide == PCollection_Left) { MyLeftChild = theNode; } else { MyRightChild = theNode; } } //-------------------------------------------------------------------------- // SetMultiplicity // -------------------------------------------------------------------------- void PCollection_AVLNode::SetMultiplicity(const Integer theCount) { Count = theCount; } //---------------------------------------------------------------------------- // Copy //----------------------------------------------------------------------------- Handle(Node) PCollection_AVLNode::Copy() const { Handle(Node) newNode = new Node(MyItem); newNode->SetMultiplicity(Count); if (!MyLeftChild.IsNull()) newNode->SetLeftChild(MyLeftChild->Copy()); if (!MyRightChild.IsNull()) newNode->SetRightChild(MyRightChild->Copy()); return newNode; } // ------------ REDEFINED // -------------------------------------------------------------------------- // ShallowCopy // -------------------------------------------------------------------------- Handle(Standard_Persistent) PCollection_AVLNode::ShallowCopy() const { Handle(Node) TheCopy; TheCopy = new Node(MyItem); TheCopy->SetMultiplicity (Count); TheCopy->SetValue (MyItem); TheCopy->SetRightChild (MyRightChild); TheCopy->SetLeftChild (MyLeftChild); return TheCopy; } //--------------------------------------------------------------------------- // ShallowDump // ---------------------------------------------------------------------------- void PCollection_AVLNode::ShallowDump(Standard_OStream& S) const { S << "begin class AVLNode "<< endl; // MyItem->ShallowDump(S) ; S << "Count : "<< Count << "times." << endl; MyLeftChild->ShallowDump(S); MyRightChild->ShallowDump(S); S << "end class AVLNode" << endl; }