---Purpose: Generic sequence of elements
-- indexed by an integer in the range 1..N.
- generic class HQueue,QueueNode,QueueIterator;
-
- ---Purpose: A queue is a sequence of items in which items
- -- are added at one end (called the back of the queue)
- -- and removed at the other end (calledthe front).
- -- The Queue is empty if there are no elements.
-
-
- generic class HSet,SetNode,SetIterator;
-
- ---Purpose: A set is an unordered collection of items
- -- We can not have duplicated items in a given set.
-
-
- generic class HStack,StackNode,StackIterator;
-
- ---Purpose: A stack is a list of items in which items are
- -- added and removed from the same end, called the
- -- top of the stack.
generic class Hash;
---Purpose: Definition of hash function. This class is used by Map
-- class and may be redefined by user.
- generic class HDataMap,MapNode,Array,MapIterator;
-
- ---Purpose: A map is a Collection of bindings
- -- between two objects. One is considered as
- -- the key and a hash code value must be
- -- computed for it.
-
- generic class HDoubleMap,
- DoubleMapNode,
- ArrayDoubleMap,
- DoubleMapIterator;
- ---Purpose: A double map is a collection of bindings
- -- between two objects.
- -- It can be retrieved either by its Key or its Item;
- -- A hash code value must be computed for both.
-
- generic class HIndexedDataMap,
- IndexedDataMapNode,
- ArrayIndexedDataMap;
- ---Purpose: The IndexedDataMap is a hashed set of objects of
- -- Type Key, called Keys. Keys can be inserted in
- -- the Map but not removed. The Map keeps the number
- -- of keys called NbKeys. Each time a Key is inserted
- -- the Map tests if this Key is already in the Map.
- -- If it is, nothing is done. If not, NbKeys is
- -- incremented and it's value is bound to the Key
- -- and called the Index.
deferred generic class Compare ;
enumeration Side is Left , Right;
- generic class HAVLSearchTree,
- AVLNode,
- AVLNodeStack,
- AVLIterator ;
-
exception IsNotRoot inherits Failure;
exception IsNullTree inherits Failure;
exception IsContained inherits Failure;
- generic class HArbitraryTree,
- SeqArbitraryTree,
- StackArbitraryTree,
- ATPreOrderIterator ,
- ATPostOrderIterator,
- ATInOrderIterator ;
-
- generic class HDirectedGraph,
- Vertex,
- Edge,
- SetOfVertex,
- SetOfEdge,
- StackOfVertex,
- QueueOfVertex,
- FrontEdgesIterator,
- BackEdgesIterator,
- DepthFirstIterator,
- BreadthFirstIterator,
- AdjacentVerticesIterator,
- VerticesIterator,
- RootsIterator,
- LeavesIterator,
- EdgesIterator;
-
class HAsciiString;
class HExtendedString;
+++ /dev/null
-// Created on: 1992-08-17
-// Created by: Mireille MERCIEN
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_OutOfRange.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// ----------------------------------------------------------------------
-// ----------------------------------------------------------------------
-
-// Purpose: Permits to iterate through an ArbitraryTree so that, from
-// the most left leave, it reads it, then its parent, then in
-// the same order what is on its right.
-// IF theTree is ( A (B (C D E)) F G (H (I J K)))
-// THEN it will read ( C B D E A F I H J K G)
-
-//-------------------------------------------------------------------
-// Create
-//-------------------------------------------------------------------
-PCollection_ATInOrderIterator::PCollection_ATInOrderIterator
- (const Handle(PCollection_HArbitraryTree)& ATree)
-{
- CurrentStack = new PCollection_StackArbitraryTree;
- if (ATree.IsNull()) {
- HasMore = Standard_False;
- }
- else {
-// ... stop at the last child to the left
- RecursiveAppend( ATree);
- CurrentTree = CurrentStack->Top();
- HasMore = Standard_True;
- }
-}
-
-//-------------------------------------------------------------------
-// More
-//-------------------------------------------------------------------
-Standard_Boolean PCollection_ATInOrderIterator::More () const
-{
- return HasMore;
-}
-
-//-------------------------------------------------------------------
-// Value
-//-------------------------------------------------------------------
-Handle(PCollection_HArbitraryTree)
- PCollection_ATInOrderIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return CurrentTree;
-}
-
-//-------------------------------------------------------------------
-// Clear
-//-------------------------------------------------------------------
-void PCollection_ATInOrderIterator::Clear ()
-{
- CurrentTree.Nullify();
- CurrentStack.Nullify();
- HasMore = Standard_False;
-}
-
-//-------------------------------------------------------------------
-// Next
-//-------------------------------------------------------------------
-void PCollection_ATInOrderIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- Handle(PCollection_HArbitraryTree) Temp;
- Standard_Integer Nb = CurrentTree->NbChildren();
- if( Nb > 1) {
-// ... go to the other children (first one already visited)
- Temp = CurrentTree->Child(2);
- RecursiveAppend( Temp);
- }
- else {
-// ... was <CurrentTree> the first child ?
-// ... If yes, nothing more to do than removing it
-// ... if not, go upward, and on the right as soon as possible
- Temp = RecursiveRemove( CurrentTree);
- Handle(PCollection_HArbitraryTree) Left = Temp->LeftSibling();
- if ( !Left.IsNull()) RecursiveAppend(Temp->RightSibling());
- }
-// ... CurrentTree's updating
- if (HasMore) CurrentTree = CurrentStack->Top();
-}
-
-// INTERNAL TOOLS TO MANAGE CurrentStack
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-void PCollection_ATInOrderIterator::RecursiveAppend (
- const Handle(PCollection_HArbitraryTree)& ATree)
-{
- CurrentStack->Push(ATree);
-// ... is there still some child ?
- if( !ATree->IsLeaf()) {
- RecursiveAppend(ATree->Child(1));
- }
-}
-
-
-//-------------------------------------------------------------------
-//-------------------------------------------------------------------
-Handle(PCollection_HArbitraryTree)
- PCollection_ATInOrderIterator::RecursiveRemove (
- const Handle(PCollection_HArbitraryTree)& ATree) {
-
- Handle(PCollection_HArbitraryTree) Temp = ATree;
- CurrentStack->Pop();
- if( CurrentStack->IsEmpty()) {
-// ... it's the end...
- HasMore = Standard_False;
- }
- else {
-// ... are there other trees to be removed ?
- Handle(PCollection_HArbitraryTree) Left = ATree->LeftSibling();
- Handle(PCollection_HArbitraryTree) Right = ATree->RightSibling();
- if(!Left.IsNull() && Right.IsNull()) {
-// ... it's still necessary to go upward
- Temp = CurrentStack->Top();
- Temp = RecursiveRemove( Temp);
- }
- }
- return Temp;
-}
-
-
+++ /dev/null
-// Created on: 1992-08-13
-// Created by: Mireille MERCIEN
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_OutOfRange.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// ----------------------------------------------------------------------
-// ----------------------------------------------------------------------
-
-// Purpose: Permits to iterate through an ArbitraryTree beginning by
-// the most left leave and its rightSibling, then upward to
-// its parent, ..
-// IF theTree is ( A (B (C D E)) F G (H (I J K)))
-// THEN it will read ( C D E B F I J K H G A)
-
-
-// --------
-// Create
-// --------
-PCollection_ATPostOrderIterator::
- PCollection_ATPostOrderIterator
- (const Handle(PCollection_HArbitraryTree)& ATree)
-{
- CurrentStack = new PCollection_StackArbitraryTree;
- if (ATree.IsNull()) {
- HasMore = Standard_False;
- }
- else {
- HasMore = Standard_True;
- RecursiveAppend(ATree);
- CurrentTree = CurrentStack->Top();
- }
-}
-
-// --------
-// More
-// --------
-Standard_Boolean PCollection_ATPostOrderIterator::More () const
-{
- return HasMore;
-}
-
-// --------
-// Value
-// --------
-Handle(PCollection_HArbitraryTree)
- PCollection_ATPostOrderIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return CurrentTree;
-}
-
-// --------
-// Clear
-// --------
-void PCollection_ATPostOrderIterator::Clear ()
-{
- CurrentTree.Nullify();
- CurrentStack.Nullify();
- HasMore = Standard_False;
-}
-
-// --------
-// Next
-// --------
-void PCollection_ATPostOrderIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
-// ... removes the last tree
- CurrentStack->Pop();
- if (CurrentStack->IsEmpty()) {
- HasMore = Standard_False;
- }
- else {
-// ... is there still someone on the right ?
-// ... if yes, go on to the right
- Handle(PCollection_HArbitraryTree) Temp = CurrentTree->RightSibling();
- if (!Temp.IsNull()) {
- RecursiveAppend(Temp);
- }
- CurrentTree = CurrentStack->Top();
- }
-}
-
-// PRIVATE TOOLS TO MANAGE CURRENTSTACK
-
-// --------
-// --------
-void PCollection_ATPostOrderIterator::RecursiveAppend (
- const Handle(PCollection_HArbitraryTree)& ATree)
-{
- CurrentStack->Push(ATree);
-// ... is there still some child ?
- if ( !ATree->IsLeaf()) {
- RecursiveAppend( ATree->Child(1));
- }
-}
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1992-08-13
-// Created by: Mireille MERCIEN
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_OutOfRange.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// ----------------------------------------------------------------------
-// ----------------------------------------------------------------------
-
-// Purpose: Permits to iterate through an ArbitraryTree so that,
-// from the root, it reads each element on the left,
-// until the first leave, then goes to its rightSibling
-// and upward.
-// IF theTree is ( A (B (C D E)) F G (H (I J K)))
-// THEN it will read ( A B C D E F G H I J K)
-
-// -----------
-// constructor :
-// -----------
-PCollection_ATPreOrderIterator::
- PCollection_ATPreOrderIterator
- (const Handle(PCollection_HArbitraryTree)& ATree)
-{
- CurrentStack = new PCollection_StackArbitraryTree;
- if (ATree.IsNull()) {
- HasMore = Standard_False;
- }
- else {
- HasMore = Standard_True;
- CurrentTree = ATree;
- CurrentStack->Push(ATree);
- }
-}
-
-// --------
-// More
-// --------
-Standard_Boolean PCollection_ATPreOrderIterator::More() const
-{
- return HasMore;
-}
-
-// --------
-// Value
-// --------
-Handle(PCollection_HArbitraryTree)
- PCollection_ATPreOrderIterator::Value() const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return CurrentTree;
-}
-
-// --------
-// Clear
-// --------
-void PCollection_ATPreOrderIterator::Clear()
-{
- CurrentTree.Nullify();
- CurrentStack.Nullify();
- HasMore = Standard_False;
-}
-
-// --------
-// Next
-// --------
-void PCollection_ATPreOrderIterator::Next()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- Handle(PCollection_HArbitraryTree) Temp;
- if (CurrentTree->IsLeaf()) {
-// ... no child, so go upward, then to the right
- Temp = RecursiveRemove( CurrentTree);
-// ... and adds the right neighbour of the last removed tree
- if ( HasMore) {
- CurrentTree = Temp->RightSibling();
- CurrentStack->Push(CurrentTree);
- }
- }
- else {
-// ... just go down for one step
- CurrentTree = CurrentTree->Child(1);
- CurrentStack->Push(CurrentTree);
- }
-}
-
-
-// PRIVATE TOOLS TO MANAGE CURRENTSTACK
-
-Handle(PCollection_HArbitraryTree)
- PCollection_ATPreOrderIterator::RecursiveRemove(
- const Handle(PCollection_HArbitraryTree)& ATree)
-{
- Handle(PCollection_HArbitraryTree) Temp;
- CurrentStack->Pop();
- if ( CurrentStack->IsEmpty()) {
- HasMore = Standard_False;
- Temp = ATree; // ... to be returned
- }
- else {
-// ... is there somebody to the right ? if yes, stop removing
-// ... if not, go on removing
- Temp = ATree->RightSibling();
- if (!Temp.IsNull()) {
- Temp = ATree; // ... to be returned
- }
- else {
- Temp = CurrentStack->Top();
- Temp = RecursiveRemove( Temp);
- }
- }
- return Temp;
-}
-
-
-
-
-
+++ /dev/null
-// Created on: 1992-05-13
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Revised: Wed Oct,21 1992
-// By : Mireille MERCIEN
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-typedef PCollection_AVLNodeStack Stack;
-typedef PCollection_HAVLSearchTree Tree;
-typedef Handle(PCollection_HAVLSearchTree) Handle(Tree);
-typedef PCollection_AVLNode Node;
-typedef Handle(PCollection_AVLNode) Handle(Node);
-
-//-----------------------------------------------------------------------------
-PCollection_AVLIterator::
- PCollection_AVLIterator ( const Handle(Tree)& aTree)
-{
- CurrentStack = new Stack; // Create an empty Stack
- Handle(Node) Root = aTree->GetRoot(); // Current node = root of tree
- if (Root.IsNull()) {
- HasMore = False;
- }
- else {
- HasMore = True;
- // CURRENTSTACK MANAGEMENT
- Append( Root);
- }
-}
-
-//-----------------------------------------------------------------------------
-Boolean PCollection_AVLIterator::More () const
-{
- return HasMore;
-}
-
-//-----------------------------------------------------------------------------
-Handle(Node) PCollection_AVLIterator::Value () const
-{
- if (!HasMore) NoSuchObject::Raise();
- return CurrentNode;
-}
-
-//-----------------------------------------------------------------------------
-void PCollection_AVLIterator::Clear ()
-{
- CurrentNode.Nullify();
- CurrentStack.Nullify();
- HasMore = False;
-}
-
-//-----------------------------------------------------------------------------
-void PCollection_AVLIterator::Next ()
-{
- if (!HasMore) NoMoreObject::Raise();
- Handle(Node) Right = CurrentNode->RightChild();
-
- // WHAT ARE THE FOLLOWING ELEMENTS ?
- if ( Right.IsNull()) {
- RecursiveRemove(CurrentNode);
- // MAYBE IT'S THE END
- if (CurrentStack->IsEmpty())
- HasMore = False;
- else
- CurrentNode = CurrentStack->Top();
- }
- else {
- Append (Right);
- }
-}
-
-
-// PRIVATE TOOLS TO ITERATE
-
-
-void PCollection_AVLIterator::Append ( const Handle(Node)& Root)
-{
- RecursiveAppend( Root);
- CurrentNode = CurrentStack->Top();
-}
-
-
-void PCollection_AVLIterator::RecursiveAppend(const Handle(Node)& ANode)
-{
- if (!ANode.IsNull()) {
- CurrentStack->Push(ANode);
- Handle(Node) Left = ANode->LeftChild();
- RecursiveAppend( Left);
- }
-}
-
-
-void PCollection_AVLIterator::RecursiveRemove(const Handle(Node)& theNode)
-{
- CurrentStack->Pop();
- if (CurrentStack->IsEmpty()) return;
- Handle(Node) NewNode = CurrentStack->Top();
- if (theNode == NewNode->RightChild()) {
- RecursiveRemove(NewNode);
- }
-}
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-24
-// Created by: Annick PANCHER
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Updated: Jean-Pierre TIRAULT Apr,6 1992, Mireille MERCIEN
-
-#include <PCollection_Side.hxx>
-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;
-}
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_AdjacentVerticesIterator::PCollection_AdjacentVerticesIterator
- (const Handle(PCollection_Vertex)& V):MyEdgeIterator(V->GetFrontEdges())
-{
- HasMore = MyEdgeIterator.More();
-}
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_AdjacentVerticesIterator::More () const
-{
- return HasMore;
-}
-
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_AdjacentVerticesIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- MyEdgeIterator.Next();
- HasMore = MyEdgeIterator.More();
-}
-
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_AdjacentVerticesIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- Handle(PCollection_Edge) AnEdge = MyEdgeIterator.Value();
- return AnEdge->Destination();
-}
-
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_AdjacentVerticesIterator::Clear ()
-{
- HasMore = False;
-}
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_BackEdgesIterator::PCollection_BackEdgesIterator
- (const Handle(PCollection_Vertex)& V):MyEdgeIterator(V->GetBackEdges())
-{
- HasMore = MyEdgeIterator.More();
-}
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_BackEdgesIterator::More () const
-{
- return HasMore;
-}
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_BackEdgesIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- MyEdgeIterator.Next();
- HasMore = MyEdgeIterator.More();
-}
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Edge) PCollection_BackEdgesIterator::Value () const
-{
- if (HasMore) {
- return MyEdgeIterator.Value();
- }
- else {
- NoSuchObject::Raise();
- }
-}
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_BackEdgesIterator::Clear ()
-{
- HasMore = False;
-}
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_BreadthFirstIterator::
- PCollection_BreadthFirstIterator (const Handle(PCollection_Vertex)& V)
-{
- Visited = new PCollection_SetOfVertex;
- Ready = new PCollection_QueueOfVertex;
- Visited->Add(V);
-//mip Ready->Add(V);
- Ready->Push(V);
- HasMore = !(Ready->IsEmpty());
-}
-
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_BreadthFirstIterator::More () const
-{
- return HasMore;
-}
-
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_BreadthFirstIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- Handle(PCollection_Vertex) w1 = Ready->Front();
- Ready->Pop();
- PCollection_FrontEdgesIterator It(w1);
- while (It.More()) {
- Handle(PCollection_Vertex) w2 = It.Value()->Destination();
- if (! (Visited->Contains(w2))) {
-//mip Ready->Add(w2);
- Ready->Push(w2);
- Visited->Add(w2);
- }
- It.Next();
- }
- HasMore = !(Ready->IsEmpty());
-}
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_BreadthFirstIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return Ready->Front();
-}
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_BreadthFirstIterator::Clear ()
-{
- HasMore = False;
-}
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_DepthFirstIterator::
- PCollection_DepthFirstIterator(const Handle(PCollection_Vertex)& V)
-{
- Visited = new PCollection_SetOfVertex;
- Ready = new PCollection_StackOfVertex;
- Visited->Add(V);
- Ready->Push(V);
- HasMore = ! (Ready->IsEmpty());
-}
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_DepthFirstIterator::More () const
-{
- return HasMore;
-}
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_DepthFirstIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- Handle(PCollection_Vertex) w1 = Ready->Top();
- Ready->Pop();
- PCollection_FrontEdgesIterator It(w1);
- while (It.More()) {
- Handle(PCollection_Vertex) w2 = It.Value()->Destination();
- if (! (Visited->Contains(w2))) {
- Ready->Push(w2);
- Visited->Add(w2);
- }
- It.Next();
- }
- HasMore = !(Ready->IsEmpty());
-}
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_DepthFirstIterator::Value () const
-{
- if (HasMore)
- return Ready->Top();
- else
- Standard_NoSuchObject::Raise();
-}
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
- void PCollection_DepthFirstIterator::Clear ()
-{
- HasMore = False;
- Ready->Nullify();
- Visited->Nullify();
-}
+++ /dev/null
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-Version:
-
-// Version Date Purpose
-// 07/01/93 Creation
-
-//-Language C++2.0
-
-//-Declarations
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-//=======================================================================
-// Function : DoubleMapIterator
-//=======================================================================
-
-PCollection_DoubleMapIterator::PCollection_DoubleMapIterator
- ( const Handle(PCollection_HDoubleMap) &aDoubleMap )
-{
- Standard_Boolean Found = Standard_False;
-
- myBuckets = aDoubleMap->GetArrayKey();
-// Sets the index and the node on the first "no empty" entry
- if ( aDoubleMap->IsEmpty() ) myCurrentIndex = myBuckets->Length() + 1;
- else myCurrentIndex = 1;
-
- while ( myCurrentIndex <= myBuckets->Length() && !Found ) {
- if ( ! myBuckets->Value(myCurrentIndex).IsNull() ) {
- myCurrentNode = myBuckets->Value(myCurrentIndex);
- Found = Standard_True;
- }
- else myCurrentIndex++;
- }
-}
-
-//=======================================================================
-// Function : More
-//=======================================================================
-
-Standard_Boolean PCollection_DoubleMapIterator::More() const
-{
- Standard_Boolean Ok = ( myCurrentIndex <= myBuckets->Length()) &&
- (! myCurrentNode.IsNull());
-
- return Ok;
-}
-
-//=======================================================================
-// Function : Next
-//=======================================================================
-
-void PCollection_DoubleMapIterator::Next()
-{
- Standard_Boolean Found = Standard_False;
- Standard_Boolean HasMore = ( myCurrentIndex <= myBuckets->Length()) &&
- (! myCurrentNode.IsNull());
-
- if ( !HasMore ) Standard_NoMoreObject::Raise();
-
- myCurrentNode = myCurrentNode->NextKey();
- if ( myCurrentNode.IsNull() ) {
- myCurrentIndex++;
- while ( myCurrentIndex <= myBuckets->Length() && !Found ) {
- myCurrentNode = myBuckets->Value(myCurrentIndex);
- if ( myCurrentNode.IsNull() )
- myCurrentIndex++;
- else
- Found = Standard_True;
- }
- }
-
-}
-
-//=======================================================================
-// Function : KeyValue
-//=======================================================================
-
-Key PCollection_DoubleMapIterator::KeyValue () const
-{
- if ( myCurrentNode.IsNull() ) Standard_NoSuchObject::Raise();
- return myCurrentNode->GetKey();
-}
-
-//=======================================================================
-// Function : ItemValue
-//=======================================================================
-
-Item PCollection_DoubleMapIterator::ItemValue () const
-{
- if ( myCurrentNode.IsNull() ) Standard_NoSuchObject::Raise();
- return myCurrentNode->GetItem();
-}
+++ /dev/null
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-Version:
-
-// Version Date Purpose
-// 14/12/92 Creation
-
-//-Language C++2.0
-
-//=======================================================================
-// Function : DoubleMapNode
-//=======================================================================
-
-PCollection_DoubleMapNode::PCollection_DoubleMapNode
- (
- const Key &aKey,
- const Item &anItem,
- const Handle(PCollection_DoubleMapNode) &nextKey,
- const Handle(PCollection_DoubleMapNode) &nextItem ) :
-
- myKey(aKey), myItem(anItem), myNextKey(nextKey), myNextItem(nextItem)
-
-{
-}
-
-//=======================================================================
-// Function : SetNextKey
-//=======================================================================
-
-void PCollection_DoubleMapNode::SetNextKey
- ( const Handle(PCollection_DoubleMapNode) &aNode )
-{
- myNextKey = aNode;
-}
-
-//=======================================================================
-// Function : SetNextItem
-//=======================================================================
-
-void PCollection_DoubleMapNode::SetNextItem
- ( const Handle(PCollection_DoubleMapNode) &aNode )
-{
- myNextItem = aNode;
-}
-
-//=======================================================================
-// Function : GetKey
-//=======================================================================
-
-Key PCollection_DoubleMapNode::GetKey () const
-{
- return myKey;
-}
-
-//=======================================================================
-// Function : GetItem
-//=======================================================================
-
-Item PCollection_DoubleMapNode::GetItem () const
-{
- return myItem;
-}
-
-//=======================================================================
-// Function : NextKey
-//=======================================================================
-
-Handle(PCollection_DoubleMapNode)
- PCollection_DoubleMapNode::NextKey() const
-{
- return myNextKey;
-}
-
-//=======================================================================
-// Function : SetNextItem
-//=======================================================================
-
-Handle(PCollection_DoubleMapNode)
- PCollection_DoubleMapNode::NextItem() const
-{
- return myNextItem;
-}
-
+++ /dev/null
-// Created on: 1991-05-30
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_Edge::
- PCollection_Edge(const Handle(PCollection_Vertex)& Source,
- const Handle(PCollection_Vertex)& Destination,
- const Attribute& Value)
-{
- MyAttribute = Value;
- MySource = Source;
- MyDestination = Destination;
-}
-
-//---------------------------------------------------------------------------
-// GetAttribute
-//---------------------------------------------------------------------------
-Attribute PCollection_Edge::GetAttribute () const
-{
- return MyAttribute;
-}
-
-//---------------------------------------------------------------------------
-// SetAttribute
-//---------------------------------------------------------------------------
-void PCollection_Edge::SetAttribute (const Attribute& Value)
-{
- MyAttribute = Value;
-}
-
-//---------------------------------------------------------------------------
-// Source
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_Edge::Source () const
-{
- return MySource;
-}
-
-//---------------------------------------------------------------------------
-// Destination
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_Edge::Destination () const
-{
- return MyDestination;
-}
-
-
-//---------------------------------------------------------------------------
-// SetSource
-//---------------------------------------------------------------------------
-void PCollection_Edge::SetSource (const Handle(PCollection_Vertex)& V)
-{
- MySource = V;
-}
-
-//---------------------------------------------------------------------------
-// SetDestination
-//---------------------------------------------------------------------------
-void PCollection_Edge::SetDestination (const Handle(PCollection_Vertex)& V)
-{
- MyDestination = V;
-}
-
-//---------------------------------------------------------------------------
-// Reverse
-//---------------------------------------------------------------------------
-void PCollection_Edge::Reverse ()
-{
- Handle(PCollection_Edge) me = this;
- MyDestination->RemoveBackEdge(me);
- MySource->RemoveFrontEdge(me);
- MyDestination->AddFrontEdge(me);
- MySource->AddBackEdge(me);
- Handle (PCollection_Vertex) temp = MyDestination;
- MyDestination = MySource;
- MySource = temp;
-}
-
-//---------------------------------------------------------------------------
-// IsLoop
-//---------------------------------------------------------------------------
-Boolean PCollection_Edge::IsLoop () const
-{
- return (MyDestination == MySource);
-}
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_EdgesIterator::PCollection_EdgesIterator
- (const Handle(PCollection_HDirectedGraph)& G):MyEdgeIterator(G->GetEdges())
-{
- HasMore = MyEdgeIterator.More();
-}
-
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_EdgesIterator::More () const
-{
- return HasMore;
-}
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_EdgesIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- MyEdgeIterator.Next();
- HasMore = MyEdgeIterator.More();
-}
-
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Edge) PCollection_EdgesIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return MyEdgeIterator.Value();
-}
-
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_EdgesIterator::Clear ()
-{
- HasMore = False;
-}
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_FrontEdgesIterator::PCollection_FrontEdgesIterator
- (const Handle(PCollection_Vertex)& V):MyEdgeIterator(V->GetFrontEdges())
-{
- HasMore = MyEdgeIterator.More();
-}
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_FrontEdgesIterator::More () const
-{
- return HasMore;
-}
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_FrontEdgesIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- MyEdgeIterator.Next();
- HasMore = MyEdgeIterator.More();
-}
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Edge) PCollection_FrontEdgesIterator::Value () const
-{
- if (HasMore) {
- return MyEdgeIterator.Value();
- }
- else {
- Standard_NoSuchObject::Raise();
- }
-}
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_FrontEdgesIterator::Clear ()
-{
- HasMore = False;
-}
-
-
-
-
-
-
+++ /dev/null
--- Created on: 1991-05-21
--- Created by: Annick PANCHER
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
--- Revised: Mireille MERCIEN
-
-
-generic class HAVLSearchTree from PCollection (
- Item as Storable;
- Comparator as Compare from PCollection(Item))
-
-inherits Persistent
-
----Purpose: Defines a binary search tree, e.g. an ordered and
- -- balanced binary tree. An AVLSearchTree is created with a
- -- kind of Item and a Comparator. It's composed with Nodes.
- -- One item is contained only by one Node, and a 'count' stores
- -- the number of its occurences.
- -- The only public operations on an AVLSearchTree,
- -- except reading ( the number of its Nodes, its Root
- -- or the Node containing an item) are to insert or
- -- remove an item, plus, of course, to find an item.
- --
- -- Then, it's possible to ask to a Node its value,
- -- the number of occurences of this value, and its
- -- right and left children. Other methods of Node are
- -- private and called by the private methods of
- -- AVLSearchTree which manage the Find method, and
- -- Insert and Remove operations, always ensuring
- -- order and balance.
- -- 1. ORDER :
- -- If the tree contains three elements A,B,C, which
- -- are ordered, regarding to a comparator Comp, as
- -- following:
- -- A < B < C
- -- Then TheRoot of the tree will contain B, with A as
- -- LeftChild and C as RightChild.
- -- Each element on the left of a node A are 'lower'
- -- than A in respect with the used comparator, and
- -- each element on its right are greater.
- --
- -- 2. BALANCE : The height of two children of a Node
- -- will never have a difference of more than one
- -- level. An AVLSearch Tree is ALWAYS balanced.
- -- Keywords: binary tree, ordered, balanced
- -- Warning: To use an AVLSearchTree, since it's ordered and
- -- balanced each time an item is inserted or removed,
- -- may be a bad choice if there are more changing
- -- operations than searching requests, for
- -- performances criterias. It can be judicious to
- -- use it when there are many items to consult
- -- frequently.
- -- References: Classix, Reusable C++ Components( Empathy
- -- incorporated, 1990).
- -- Algorithms are attributed to :
- -- G.M.Adel'son-Vel'skii and E.M.Landis, 1962.
-
-
-uses Side from PCollection
-
-
-raises NoSuchObject from Standard,
- NoMoreObject from Standard
-
-
-
- class AVLNode inherits PManaged
- uses Side from PCollection
- is
-
- ---Purpose: Private class. This class provides tools to manipulate
- -- an AVLSearchTree node.
-
- Create( theItem: Item)
- returns mutable AVLNode ;
-
- RightChild( me) returns mutable AVLNode;
- ---Purpose: Reads the value of MyRightChild.
-
- LeftChild( me) returns mutable AVLNode;
- ---Purpose: Reads the value of MyLeftChild.
-
- Value( me) returns any Item;
- ---Purpose: Reads TheItem.
-
- GetMultiplicity( me)
- ---Purpose: Returns number of occurences of Item contained
- -- by <me>.
- returns Integer from Standard;
-
-
- SetRightChild( me:mutable; theNode: AVLNode);
- ---Purpose: Modifies the value of MyRightChild.
-
- SetLeftChild( me:mutable; theNode: AVLNode);
- ---Purpose: Modifies the value of MyLeftChild.
-
- SetChild ( me: mutable; theNode: AVLNode;
- theSide: Side from PCollection);
- ---Purpose: Modifies the value of right or left child.
-
- SetValue( me:mutable; theValue: Item);
- ---Purpose: Modifies the value of TheItem.
-
- SetMultiplicity( me:mutable; theCount: Integer from Standard);
- ---Purpose: Modifies the value of Count.
-
- Copy(me)
- returns mutable AVLNode
- is private;
-
- -- REDEFINED
-
- ShallowCopy(me) returns mutable like me
- is redefined;
- ---Purpose: ShallowCopy redefinition.
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Purpose: ShallowDump redefinition.
- ---C++: function call
-
-
- fields
- MyRightChild: AVLNode;
- MyLeftChild : AVLNode;
- MyItem : Item;
- Count : Integer from Standard;
-
- friends class HAVLSearchTree from PCollection
-
- end;
-
- class AVLNodeStack instantiates HStack(AVLNode);
-
- class AVLIterator
-
- raises NoMoreObject from Standard, NoSuchObject from Standard
- is
- ---Purpose: This class provides to iterate on an AVLSearchTree.
- -- The type of traversal is the in-order traversal.
- -- Example : If the AVLTree is the following:
- -- 5
- -- 2 7
- -- 1 3 6 8
- --
- -- The result is:
- -- 1 2 3 5 6 7 8
- --
-
- Create( aTree: HAVLSearchTree)
- ---Purpose: Creates an iterator on <aTree>.
- ---Level: Public
- returns AVLIterator;
-
- More( me)
- ---Purpose: Returns True if there is still an element to be read.
- ---Level: Public
- returns Boolean from Standard;
-
- Next( me: in out) raises NoMoreObject from Standard;
- ---Purpose: Goes to next element of <me>.
- ---Level: Public
-
- Value( me)
- returns mutable AVLNode
- ---Level: Public
- raises NoSuchObject from Standard;
-
- Clear (me: in out);
- ---Purpose: Empties my structure, so that if next call on <me>,
- -- it will raise an exception NoMoreObject.
- ---Level: Public
-
- Append (me: in out; ANode:AVLNode)
- ---Purpose: Adds Nodes to <CurrentStack> from <ANode>.
- ---Level: Internal
- is private;
-
- RecursiveAppend (me: in out; ANode:AVLNode)
- ---Purpose: Called by Append to add <ANode> to
- -- <CurrentStack>, and goes down to left
- ---Level: Internal
- is private;
-
- RecursiveRemove (me: in out; ANode:AVLNode)
- ---Purpose: Called by Next to remove <ANode> and
- -- the Node which is before in CurrentStack.
- -- If <ANode> was its rightChild.
- ---Level: Internal
- is private;
-
-fields
- CurrentNode : AVLNode;
- CurrentStack : AVLNodeStack;
- HasMore : Boolean;
-end;
-
-
-is
-
- Create( aComparator: Comparator)
- ---Purpose: Creates an empty tree (root points to NULL).
- returns mutable HAVLSearchTree;
-
-
- IsEmpty( me)
- ---Level: Public
- returns Boolean from Standard;
-
- Extent( me)
- ---Purpose: Returns number of different items contained by <me>
- ---Level: Public
- returns Integer from Standard;
-
- TotalExtent( me)
- ---Purpose: Returns total number of items (considers account of each Node)
- ---Level: Public
- returns Integer from Standard;
-
- Find( me; theItem: Item)
- ---Purpose: Returns the Node containing <theItem>.
- ---Level: Public
- returns AVLNode;
-
- GetRoot( me)
- returns AVLNode;
- ---Level: Public
-
-
- Insert( me: mutable; theItem: Item);
- ---Purpose: Inserts <theItem> at the right place; if it's
- -- already in <me>, only changes its <count>.
- -- Level: Public
- -- Example:
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i2
- -- After
- -- me = ( i5( i2( i1 -i3)) -i7))
- -- ( i means LeftChild, -i means RightChild)
-
- InsertOnce(me: mutable; theItem: Item)
- ---Purpose: Inserts <theItem> at the right place, but only if
- -- it isn't already in <me>; returns False if already there.
- -- Level: Public
- -- Example:
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i3
- -- After
- -- me = ( i5( i3( i1)) -i7) and return False
- returns Boolean from Standard;
-
- Remove( me : mutable; theItem : Item)
- ---Purpose: Removes from <me> the Node containing <theItem>,
- -- if its count=1, or reduces its count if count>1;
- -- in this aim, calls the recursive method
- -- RecursiveRemove, with <forAll>=False;
- -- Level: Public
- -- Example:
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i7
- -- After
- -- me = ( i3( i1 -i5)) if count(i7)=1
- -- Or
- -- me = ( i5( i3( i1)) -i7) if count(i7)>1
- raises NoSuchObject from Standard;
-
- RemoveAll( me: mutable; theItem: Item)
- ---Purpose: Removes from <me> the Node containing <theItem>;
- -- in this aim, calls the recursive method
- -- RecursiveRemove, with <forAll>=True;
- -- Level: Public
- -- Example
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i7
- -- After
- -- me = ( i3( i1 -i5))
- raises NoSuchObject from Standard;
-
- Merge (me; another:HAVLSearchTree)
- ---Purpose: Creates a third one from <me> and <another>.
- ---Level: Public
- returns mutable HAVLSearchTree;
-
- Copy(me)
- returns mutable HAVLSearchTree
- ---Level: Internal
- is private;
-
- SetRoot( me: mutable; theNode: mutable AVLNode)
- ---Level: Internal
- is private;
-
- RotateLeft( me; theNode : in out mutable AVLNode)
- ---Purpose: right child A of <theNode> becomes the parent, and
- -- <theNode> becomes its left child; left child of A
- -- becomes the right child of <theNode>. This
- -- rotation will permit to balance <me> after a
- -- pertubating action ( insert or remove) on it.
- ---Level: Internal
- is private;
-
- RotateRight( me; theNode : in out mutable AVLNode)
- ---Purpose: left child A of <theNode> becomes the parent, and
- -- <theNode> becomes its right child; right child of
- -- A becomes the left child of <theNode>. This
- -- rotation will permit to balance <me> after a
- -- pertubating action ( insert or remove) on it.
- ---Level: Internal
- is private;
-
- LeftBalance( me; theNode : in out mutable AVLNode)
- ---Purpose: Called after inserting or removing an item, if the
- -- left branch of <theNode> is too long
- ---Level: Internal
- is private;
-
- RightBalance( me; theNode : in out mutable AVLNode)
- ---Purpose: Called after inserting or removing an item, if the
- -- right branch of <theNode> is too long.
- ---Level: Internal
- is private;
-
- InsertBalance( me; theNode : in out mutable AVLNode;
- theFather: mutable AVLNode;
- theSide : Side from PCollection)
- ---Purpose: Balances <me> after inserting an item.
- returns Boolean from Standard
- ---Level: Internal
- is private;
-
- RemoveBalance( me; theNode : in out mutable AVLNode;
- theFather: mutable AVLNode;
- theSide : Side from PCollection)
- ---Purpose: Balances <me> after inserting an item.
- ---Level: Internal
- returns Boolean from Standard
- is private;
-
- RecursiveInsert( me; theNode : in out mutable AVLNode;
- theFather: mutable AVLNode;
- theSide : Side from PCollection;
- theItem : Item;
- forOnce : in out Boolean from Standard)
- ---Purpose: Recursive method to insert a new Node OR to find
- -- the existing one containing <theItem> and increase its count.
- -- Returns True when a new Node has been created to
- -- know it needs to be balanced, and then returns
- -- False again.
- ---Level: Internal
- returns Boolean from Standard
- is private;
-
- RecursiveRemove( me; theNode : in out mutable AVLNode;
- theFather: mutable AVLNode;
- theSide : Side from PCollection;
- theItem : Item;
- forAll : Boolean from Standard)
- ---Purpose: Recursive method to find the Node containing
- -- <theItem>. In case it's <theNode>, removes it if
- -- <forAll> is True, or reduces its count if <forAll> is False.
- -- Returns True when theItem has been found
- ---Level: Internal
- returns Boolean from Standard
- is private;
-
-
- ShallowCopy(me) returns mutable like me
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
-fields
-
- TheRoot : AVLNode;
- TheComparator : Comparator;
-
-end;
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-23
-// Created by: Annick PANCHER
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Revised by: Jean-Pierre TIRAULT,Mireille MERCIEN
-// May,14 1992
-
-#include <Standard_NoSuchObject.hxx>
-#include <PCollection_Side.hxx>
-typedef PCollection_Side Side;
-typedef PCollection_AVLNode Node;
-typedef Handle(PCollection_AVLNode) Handle(Node);
-typedef PCollection_HAVLSearchTree Tree;
-typedef Handle(PCollection_HAVLSearchTree) Handle(Tree);
-typedef PCollection_AVLIterator AVLIterator;
-
-
-//-----------------------------------------------------------------------------
-// Internal function Height : returns the height of an AVLtree
-//-----------------------------------------------------------------------------
-static Integer Height(const Handle(Node)& ANode)
-{
-// ... Length of the longest child
- if(ANode.IsNull()) return 0;
- return (1 + Max( Height(ANode->LeftChild()),
- Height(ANode->RightChild()) ) );
-}
-
-//-----------------------------------------------------------------------------
-// Create : creates an empty AVLSearchTree
-//-----------------------------------------------------------------------------
-PCollection_HAVLSearchTree::
- PCollection_HAVLSearchTree(const Comparator& AComparator)
-{
- TheComparator = AComparator;
- Handle(Node) NullNode;
- NullNode.Nullify();
- TheRoot = NullNode;
-}
-
-//-----------------------------------------------------------------------------
-// IsEmpty : Is the current tree empty ?
-//-----------------------------------------------------------------------------
-Boolean PCollection_HAVLSearchTree::IsEmpty () const
-{
- return (TheRoot.IsNull());
-}
-
-//-----------------------------------------------------------------------------
-// GetRoot : Returns the root of the current tree
-//-----------------------------------------------------------------------------
-Handle(Node) PCollection_HAVLSearchTree::GetRoot () const
-{
- return TheRoot;
-}
-
-// ---------------------------------------------------------------------------
-// SetRoot : Replaces the root of the current tree
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::SetRoot(const Handle(Node)& ANode)
-{
- TheRoot = ANode;
-}
-
-//-----------------------------------------------------------------------------
-// Extent : Number of different items in the current tree
-//-----------------------------------------------------------------------------
-// ... Management tools to have the number of nodes from a given one
-static Integer RecursiveExtent(const Handle(Node)& ANode)
-{
- if (ANode.IsNull()) return 0;
- return (1 + RecursiveExtent(ANode->LeftChild())
- + RecursiveExtent(ANode->RightChild()) );
-}
-
-//----------------------------------------------------------------------------
-Integer PCollection_HAVLSearchTree::Extent () const
-{
- return RecursiveExtent(TheRoot);
-}
-
-//-----------------------------------------------------------------------------
-// Extent : Number of different items in the current tree according to
-// the multiplicity
-//-----------------------------------------------------------------------------
-// ... Management tools to have the number of nodes from a given one
-static Integer RecursiveTotalExtent(const Handle(Node)& ANode)
-{
- if ( ANode.IsNull()) return 0;
- return ( RecursiveTotalExtent(ANode->LeftChild()) +
- RecursiveTotalExtent(ANode->RightChild()) +
- ANode->GetMultiplicity() );
-}
-
-//----------------------------------------------------------------------------
-Integer PCollection_HAVLSearchTree::TotalExtent () const
-{
- return RecursiveTotalExtent(TheRoot);
-}
-
-//-----------------------------------------------------------------------------
-// Find : Find the node containing an item
-//-----------------------------------------------------------------------------
-// ... Management tools
-static Handle(Node) RecursiveFind( const Comparator& Comp,
- const Handle(Node)& SubRoot,
- const Item& TheItem)
-{
- if ( SubRoot.IsNull() ) return SubRoot;
- if ( Comp.IsLower(TheItem, SubRoot->Value()) ) {
- return RecursiveFind(Comp, SubRoot->LeftChild(), TheItem);
- }
- if (Comp.IsGreater(TheItem, SubRoot->Value()) ) {
- return RecursiveFind(Comp, SubRoot->RightChild(), TheItem);
- }
- return SubRoot;
-}
-
-//----------------------------------------------------------------------------
-Handle(Node) PCollection_HAVLSearchTree::Find(const Item& TheItem) const
-{
- return RecursiveFind(TheComparator, TheRoot, TheItem);
-}
-
-//----------------------------------------------------------------------------
-// RotateRight
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::RotateRight(Handle(Node)& TheNode) const
-{
-// the left child becomes the parent...
- Handle(Node) Temp = TheNode->LeftChild();
- TheNode->SetLeftChild(Temp->RightChild());
- Temp->SetRightChild(TheNode);
- TheNode = Temp;
-}
-
-//-----------------------------------------------------------------------------
-// RotateLeft
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::
- RotateLeft(Handle(Node)& TheNode) const
-{
-// the right child becomes the parent...
- Handle(Node) Temp = TheNode->RightChild();
- TheNode->SetRightChild(Temp->LeftChild());
- Temp->SetLeftChild(TheNode);
- TheNode = Temp;
-}
-
-//-----------------------------------------------------------------------------
-// LeftBalance
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::LeftBalance(Handle(Node)& Root) const
-{
- Handle(Node) TheNode = Root->LeftChild();
- if( Height(TheNode->LeftChild()) >= Height(TheNode->RightChild()) ) {
- RotateRight(Root);
- return;
- }
- RotateLeft(TheNode);
- Root->SetLeftChild(TheNode);
- RotateRight(Root);
-}
-
-//----------------------------------------------------------------------------
-// RightBalance
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::RightBalance(Handle(Node)& Root) const
-{
- Handle(Node) TheNode = Root->RightChild();
- if( Height(TheNode->RightChild()) >= Height(TheNode->LeftChild())) {
- RotateLeft(Root);
- return;
- }
- RotateRight(TheNode);
- Root->SetRightChild(TheNode);
- RotateLeft(Root);
-}
-
-//-----------------------------------------------------------------------------
-// InsertBalance
-//-----------------------------------------------------------------------------
-Boolean PCollection_HAVLSearchTree::InsertBalance(Handle(Node)& Child,
- const Handle(Node)& Father,
- const Side theSide) const
-{
-// Balance after insertion
- switch (Height(Child->LeftChild()) - Height(Child->RightChild())) {
- case 2 : LeftBalance(Child);
- if (!Father.IsNull()) Father->SetChild(Child, theSide);
- return False;
- case -2 : RightBalance(Child);
- if (!Father.IsNull()) Father->SetChild(Child, theSide);
- return False;
- case 0 : return False;
- default : return True;
- }
-}
-
-//----------------------------------------------------------------------------
-// RemoveBalance
-//-----------------------------------------------------------------------------
-Boolean PCollection_HAVLSearchTree::
- RemoveBalance(Handle(Node)& Child,
- const Handle(Node)& Father,
- const Side theSide) const
-{
-// Balance after Remove
- switch (Height(Child->LeftChild()) - Height(Child->RightChild())) {
- case 2 : LeftBalance(Child);
- if (!Father.IsNull()) Father->SetChild(Child, theSide);
- return True;
- case -2 : RightBalance(Child);
- if (!Father.IsNull()) Father->SetChild(Child, theSide);
- return True;
- default : return True;
- }
-}
-
-//---------------------------------------------------------------------------
-// RecursiveInsert
-//-----------------------------------------------------------------------------
-Boolean PCollection_HAVLSearchTree::
- RecursiveInsert(Handle(Node)& Child,
- const Handle(Node)& Father,
- const Side theSide,
- const Item& theItem,
- Boolean& forOnce) const
-{
-// FINDS WHERE TO INSERT theItem AND DOES IT
- Handle(Node) Temp;
- Boolean Result = False;
- Integer Number;
- if(TheComparator.IsLower(theItem, Child->Value())) {
- Temp = Child->LeftChild();
- if (Temp.IsNull()) {
- Child->SetLeftChild( new Node(theItem));
- return True;
- }
- Result = RecursiveInsert( Temp, Child, PCollection_Left,
- theItem, forOnce);
- if(Result) return InsertBalance(Child, Father, theSide) ;
- else return False;
- }
- else if (TheComparator.IsGreater(theItem, Child->Value())) {
- Temp = Child->RightChild();
- if (Temp.IsNull()) {
- Child->SetRightChild( new Node(theItem));
- return True;
- }
- Result = RecursiveInsert( Temp, Child, PCollection_Right,
- theItem, forOnce);
- if(Result) return InsertBalance(Child, Father, theSide);
- else return False;
- }
- else {
-// ITEM FOUND // SET MULTIPLICITY
- if (forOnce) {
- forOnce = False;
- }
- else {
- Number = Child->GetMultiplicity();
- Child->SetMultiplicity(++Number);
- }
- return False;
- }
-}
-
-//-----------------------------------------------------------------------------
-// RecursiveRemove
-//-----------------------------------------------------------------------------
-
-Boolean PCollection_HAVLSearchTree::RecursiveRemove(
- Handle(Node)& Child,
- const Handle(Node)& Father,
- const Side theSide,
- const Item& TheItem,
- const Boolean ForAll) const
-{
-
- Boolean Result;
- Integer Number;
-// ITEM NOT FOUND
- if (Child.IsNull()) NoSuchObject::Raise();
- Handle(Node) TheLeft = Child->LeftChild();
- Handle(Node) TheRight = Child->RightChild();
- if (TheComparator.IsLower(TheItem, Child->Value())) {
- Result = RecursiveRemove( TheLeft, Child,
- PCollection_Left,
- TheItem, ForAll);
- }
-
- else if (TheComparator.IsGreater(TheItem, Child->Value())) {
- Result = RecursiveRemove( TheRight, Child,
- PCollection_Right,
- TheItem, ForAll);
- }
- else {
-// theItem IS FOUND
- Number = Child->GetMultiplicity();
- Child->SetMultiplicity(--Number);
-// SOMETIMES IT'S NOT NECESSARY REMOVING theItem
- if (!ForAll && Number > 0) return True;
-// IF IT IS, LOOKING FOR THE NEW VALUE OF Child
- if (! TheLeft.IsNull() && ! TheRight.IsNull()) {
-// Child HAS TWO CHILDREN
- Handle(Node) T;
- Handle(Node) Temp = TheRight;
- while (! Temp.IsNull()) {
- T = Temp;
- Temp = Temp->LeftChild();
- }
-// WE HAVE FOUND THE GOOD NODE
- Child->SetValue(T->Value());
- Child->SetMultiplicity(T->GetMultiplicity());
-
-
- const Item anItem = Child->Value();
-
- Result = RecursiveRemove( TheRight, Child, PCollection_Right,
-//JPT/RBA on sait pas pourquoi ? Child->Value(), ForAll);
- anItem, ForAll);
- }
- else {
-// ONLY ONE CHILD, SO IT'S THE GOOD ONE
-// Mip-12-janv-93 : integration de la gestion memoire
-// if (TheLeft.IsNull())
-// Child = TheRight;
-// else
-// Child = TheLeft;
- Child.Delete();
- if (TheLeft.IsNull()) {
- Child = TheRight;
- }
- else {
- Child = TheLeft;
- }
- Father->SetChild(Child, theSide);
- return True;
- }
- }
- if (Result) return RemoveBalance(Child, Father, theSide);
- return False; // Child has not been found for now
-}
-
-//----------------------------------------------------------------------------
-// Insert
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::Insert (const Item& theItem)
-{
- if (TheRoot.IsNull()) {
- TheRoot = new Node(theItem);
- return;
- }
- Handle(Node) Bid;
- Boolean forOnce = False;
- RecursiveInsert( TheRoot, Bid, PCollection_Left, theItem, forOnce);
-}
-
-//-----------------------------------------------------------------------------
-// InsertOnce
-//-----------------------------------------------------------------------------
-Boolean PCollection_HAVLSearchTree::InsertOnce (const Item& theItem)
-{
- if (TheRoot.IsNull()) {
- TheRoot = new Node(theItem);
- return True;
- }
- Handle(Node) Bid;
- Boolean forOnce = True;
- RecursiveInsert( TheRoot, Bid, PCollection_Left, theItem, forOnce);
- return forOnce;
-}
-
-//-----------------------------------------------------------------------------
-// Remove
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::Remove (const Item& theItem)
-{
- Handle(Node) Bid;
- RecursiveRemove( TheRoot, Bid, PCollection_Left, theItem, False);
-}
-
-//----------------------------------------------------------------------------
-// RemoveAll
-//-----------------------------------------------------------------------------
-void PCollection_HAVLSearchTree::RemoveAll (const Item& theItem)
-{
- Handle(Node) Bid;
- RecursiveRemove( TheRoot, Bid, PCollection_Left, theItem, True);
-}
-
-//----------------------------------------------------------------------------
-// Copy
-//-----------------------------------------------------------------------------
-Handle(Tree) PCollection_HAVLSearchTree::Copy() const
-{
- Handle(Tree) aTree = new Tree(TheComparator);
- aTree->SetRoot(TheRoot->Copy());
- return aTree;
-}
-
-//----------------------------------------------------------------------------
-// Merge
-//-----------------------------------------------------------------------------
-Handle(Tree) PCollection_HAVLSearchTree::Merge(const Handle(Tree)& aTree) const
-{
- Item theItem;
- AVLIterator Iter( aTree);
- Handle(Tree) newTree = Copy();
- while( Iter.More()) {
- theItem = Iter.Value()->Value();
- newTree->Insert(theItem);
- Iter.Next();
- }
- return newTree;
-}
-
-
-// ----------------------------------------------------------
-//
-// These methods must be implemented
-//
-// ----------------------------------------------------------
-
-Handle(Standard_Persistent) PCollection_HAVLSearchTree::ShallowCopy() const
-{
-
-cout << "HAVLSearchTree::ShallowCopy Not yet implemented" << endl;
-return This();
-}
-
-
-// ----------------------------------------------------
-//
-// ShallowDump
-// ----------------------------------------------------
-void PCollection_HAVLSearchTree::ShallowDump(Standard_OStream& S) const
-{
-cout << "HAVLSearchTree::ShallowDump Not yet implemented" << endl;
-}
-
-
-
+++ /dev/null
--- Created on: 1991-06-20
--- Created by: Annick PANCHER
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
--- Revised: Mireille MERCIEN
-
-
-generic class HArbitraryTree from PCollection (
- Item as Storable)
-
-
- ---Purpose: Description of a tree with an arbitrary number of
- -- children at each level. Each 'node' is an
- -- ArbitraryTree which knows its parent and its children.
- -- An ArbitraryTree can't contain an empty child. To
- -- separate a part B from an ArbitraryTree A, it's
- -- possible to swap B with a Null tree: the parent A will
- -- remove its child B, which is returned.
- --
- -- There are three iterators known for an ArbitraryTree(
- -- PreOrder, PostOrder and InOrder). Each of them
- -- manages a stack whose depth is always less or equal to
- -- the tree's height, and which describes the way from
- -- the root to the current tree.
- -- Warning: It could be a bad choice to use an ArbitraryTree for
- -- a great number of items if it's frequently necessary
- -- to search them, for there is no optimisation to find
- -- an item in an unordered tree.
- -- The same item can be stored several times in several places.
-
-inherits Persistent
-raises IsNotRoot ,
- IsNullTree ,
- IsContained ,
- NoMoreObject from Standard,
- NoSuchObject from Standard,
- OutOfRange from Standard
-
-
- class SeqArbitraryTree instantiates
- HSequence from PCollection(HArbitraryTree);
- class StackArbitraryTree instantiates
- HStack from PCollection(HArbitraryTree);
-
- class ATPreOrderIterator
-
- ---Purpose: Permits to iterate through an ArbitraryTree so that,
- -- from the root, it reads each element on the left,
- -- until the first leave, then goes to its rightSibling
- -- and upward.
- -- IF theTree is ( A (B (C D E)) F G (H (I J K)))
- -- THEN it will read ( A B C D E F G H I J K)
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
-
- Create( theTree : HArbitraryTree)
- ---Purpose: Creates an iterator on <theTree>.
- returns ATPreOrderIterator;
-
- More( me)
- ---Purpose: Returns True if there is at least one element to be read.
- ---Level: Public
- returns Boolean from Standard;
-
- Next( me : in out) raises NoMoreObject from Standard;
- ---Purpose: Manages currentStack which always contains
- -- the way from the root to the next leaf to be
- -- visited. Updates currentTree.
- ---Level: Public
-
- Value( me )
- ---Purpose: Returns the current element.
- ---Level: Public
- returns mutable HArbitraryTree
- raises NoSuchObject from Standard;
-
- Clear( me : in out);
- ---Purpose: Empties <me>, so that More() will answer False.
- ---Level: Public
-
-
-
- RecursiveRemove( me : in out; aTree : HArbitraryTree)
- ---Purpose: Removes the end of currentStack until finding a
- -- tree having a right sibling: removes it too, and returns it.
- returns mutable HArbitraryTree
- ---Level: Internal
- is private;
-
- fields
- HasMore : Boolean from Standard;
- CurrentTree : HArbitraryTree;
- CurrentStack: StackArbitraryTree;
- end;
-
-
- class ATPostOrderIterator
-
- ---Purpose: Permits to iterate through an ArbitraryTree beginning by
- -- the most left leave and its rightSibling, then upward to its parent.
- -- IF theTree is ( A (B (C D E)) F G (H (I J K)))
- -- THEN it will read ( C D E B F I J K H G A)
-
- raises NoMoreObject from Standard,
- NoSuchObject from Standard
-
- is
-
- Create( theTree : HArbitraryTree)
- ---Purpose: Creates an iterator on the tree theTree
- returns ATPostOrderIterator;
-
- More( me) returns Boolean from Standard;
- ---Purpose: Returns True if there is at least one element to
- -- be read.
- ---Level: Public
-
- Next( me : in out) raises NoMoreObject from Standard;
- ---Purpose: Sets the iterator on the next element
- ---Level: Public
-
- Value( me)
- ---Level: Public
- returns mutable HArbitraryTree
- raises NoSuchObject from Standard;
-
- Clear( me : in out);
- ---Purpose: Empties <me>, so that More() will answer False
- ---Level: Public
-
- RecursiveAppend( me : in out; aTree : HArbitraryTree)
- ---Purpose: adds a new branch to currentStack, until
- -- reaching a leaf; the branch's parent is <aTree>
- ---Level: Internal
- is private;
-
- fields
- HasMore : Boolean from Standard;
- CurrentTree : HArbitraryTree;
- CurrentStack: StackArbitraryTree;
-
- end;
-
-
- class ATInOrderIterator
-
- ---Purpose: Permits to iterate through an ArbitraryTree so that, from
- -- the most left leave, it reads it, then its parent, then in
- -- the same order what is on its right.
- -- IF theTree is ( A (B (C D E)) F G (H (I J K)))
- -- THEN it will read ( C B D E A F I H J K G)
-
- raises NoMoreObject from Standard,
- NoSuchObject from Standard
- is
-
- Create( theTree : HArbitraryTree)
- ---Purpose: Create an iterator on the tree theTree
- returns ATInOrderIterator;
-
- More( me) returns Boolean from Standard;
- ---Purpose: Returns True if there is at least one element to be read.
- ---Level: Public
-
- Next( me : in out) raises NoMoreObject from Standard;
- ---Purpose: Sets the iterator to the next element.
- ---Level: Public
-
- Value( me)
- returns mutable HArbitraryTree
- raises NoSuchObject from Standard;
- ---Level: Public
-
- Clear( me : in out);
- ---Purpose: Empties <me>, so that More() will answer False.
- ---Level: Public
-
- RecursiveAppend( me : in out; aTree : HArbitraryTree)
- ---Purpose: Adds to currentStack a new branch of the tree,
- -- which has not been visited; this branch's parent is <aTree>.
- ---Level: Internal
- is private;
-
- RecursiveRemove( me : in out; aTree : HArbitraryTree)
- ---Purpose: Removes from currentStack one or more trees,
- -- which have already been visited and have no
- -- more children not visited; the first tree
- -- removed is <aTree>.
- ---Level: Internal
- returns mutable HArbitraryTree
- is private;
-
- fields
- HasMore : Boolean from Standard;
- CurrentTree : HArbitraryTree;
- CurrentStack: StackArbitraryTree;
- end;
-
-
-is
-
-
- Create ( TheItem : Item)
- ---Purpose: Creation of a root tree of value Item with no child(e.g. a leaf)
- -- Example:
- -- if <TheItem> = i0
- -- returns
- -- ( i0 )
- -- The field <MyParent> is Null and so is <MyChildren>.
- returns mutable HArbitraryTree;
-
- Children( me)
- ---Purpose: Reads all children of <me>, to be able to know the
- -- location of one of them.
- ---Level: Internal
- returns mutable SeqArbitraryTree
- is private;
-
- Child( me; Index : Integer from Standard)
- ---Purpose: Returns the child of <me> at the range <Index>.
- -- Raises an exception if <Index> is out of range.
- -- Example:Before
- -- me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) ), Index = 2
- -- After
- -- me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) )
- -- returns (i2)
- ---Level: Public
- returns mutable HArbitraryTree
- raises OutOfRange from Standard;
-
- Value( me) returns any Item;
- ---Purpose: Returns the value of <me>.
- -- Example:Before and After
- -- me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) )
- -- returns i0
- ---Level: Public
-
- NbChildren( me) returns Integer from Standard;
- ---Purpose: Returns the number of children of me.
- -- Example: me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) )
- -- returns 3
- ---Level: Public
-
- IsLeaf( me) returns Boolean from Standard;
- ---Purpose: Returns True if the tree <me> is a leaf.
- -- Example: me = ( i0 )
- -- returns True
- ---Level: Public
-
- Parent( me)
- ---Purpose: Returns the father of <me>.
- -- The returned ArbitraryTree can be Null.
- -- Example: if T = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) ) and
- -- me = ( i1 (i4 i5) )
- -- returns T.
- ---Level: Public
- returns mutable HArbitraryTree;
-
- IsRoot( me)
- ---Purpose: Returns True if <me> has no father.
- ---Level: Public
- returns Boolean from Standard;
-
- Root( me)
- ---Purpose: Returns the root of the tree <me>.
- -- If <me> is a root, returns <me>
- -- Example: if T = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) ) and
- -- me = (i1( i4 i5 )) and T->IsRoot == True
- -- returns T
- ---Level: Public
- returns mutable HArbitraryTree ;
-
- LeftSibling( me)
- ---Purpose: Returns the left neighbour of the tree <me>.
- -- May return a Null tree.
- -- if T = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) )
- -- and me = (i2)
- -- returns ( i1 (i4 i5) )
- ---Level: Public
- returns mutable HArbitraryTree;
-
- RightSibling( me)
- ---Purpose: Returns the right neighbour of the tree <me>.
- -- May return a Null tree.
- -- Example: if T = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) )
- -- and me = (i2)
- -- returns ( i3 (i6 i7) )
- ---Level: Public
- returns mutable HArbitraryTree;
-
- Contains( me; aTree: HArbitraryTree)
- ---Purpose: Checks <aTree> is contained by <me>.
- ---Level: Public
- returns Boolean from Standard
- raises IsNullTree ;
-
- SetValue( me : mutable ; theItem : Item) ;
- ---Purpose: Changes the value of MyItem.
- -- Example: before
- -- me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) ), theItem= i10
- -- after
- -- me = ( i10 (i1 (i4 i5) i2 i3 (i6 i7) ) )
- ---Level: Public
-
- SwapChild( me : mutable ; Index : Integer from Standard;
- WithTree : in out mutable HArbitraryTree)
- ---Purpose: Replaces the child of <me> at range <Index> by <WithTree>
- -- and conversely.
- -- Only removes Child at range <Index> if <WithTree> is Null.
- -- Trigger: Raises an exception if <Index> is greater than NbChildren;
- -- raises IsNotRoot if <WithTree> is not a root;
- -- Example: Before
- -- me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) ),
- -- Index = 2, WithTree = ( i8 (i9 i10) )
- -- After
- -- me = ( i0 (i1 (i4 i5) i8 (i9 i10) i3 (i6 i7) ) )
- -- WithTree = (i2)
- ---Level: Public
- raises OutOfRange from Standard,
- IsNotRoot;
-
- SwapChildren( me : mutable ; subtree1, subtree2 : mutable HArbitraryTree)
- ---Purpose: TradeOff between two subtrees of <me>.
- -- Example: Before
- -- me = ( i0 (i1 (i4 i5) i2 i3 (i6 i7) ) ),
- -- subtree1 = (i4), subtree2 = (i3 (i6 i7)),
- -- After
- -- me = ( i0 (i1 ( i3 (i6 i7) i5) i2 i4))
- -- Trigger:Raises an exception if <subtree1> or <subtree2>
- -- are not subtrees of <me>.
- -- Raises an exception if one of the two subtrees is
- -- contained by the other one.For instance :
- -- Example: IF subtree1 = (i3( i6 i7)) and subtree2 = (i6).
- -- Raises an exception if one of the two subtrees is null.
- ---Level: Public
- raises OutOfRange from Standard,
- NoSuchObject from Standard,
- IsContained,
- IsNullTree;
-
- AppendChild( me: mutable; theTree: HArbitraryTree)
- ---Purpose: Appends <theTree> as last child of <me>
- -- Example:
- -- Before
- -- me = ( i0 ( i1 i2 i3))
- -- theTree = ( i4)
- -- After
- -- me = ( i0 ( i1 i2 i3 i4))
- -- Trigger: Raises IsNotRoot if <theTree> is not a root.
- -- Raises IsNullTree if <theTree> is Null.
- ---Level: Public
- raises IsNotRoot,
- IsNullTree;
-
- PrependChild( me: mutable; theTree: HArbitraryTree)
- ---Purpose: Appends <theTree> as first child of <me>.
- -- Example:
- -- Before
- -- me = ( i0 ( i1 i2 i3))
- -- theTree = ( i4)
- -- After
- -- me = ( i0 ( i4 i1 i2 i3))
- -- Trigger: Raises IsNotRoot if <theTree> is not a root.
- -- Raises IsNullTree if <theTree> is Null.
- ---Level: Public
- raises IsNotRoot,
- IsNullTree;
-
- InsertChildBefore( me : mutable; Index : Integer from Standard;
- theTree: HArbitraryTree)
- ---Purpose: Adds <theTree> to the field <MyChildren>, at
- -- <Index>, and all children from <Index> pushed on
- -- the right.
- -- Example: Before
- -- me = ( i0 ( i1 i2 i3))
- -- theTree = ( i4), Index = 2
- -- After
- -- me = ( i0 ( i1 i4 i2 i3))
- -- Trigger: Raises OutOfRange if <Index> is greater than
- -- NbChildren.
- -- Raises IsNotRoot if <theTree> is not a root.
- -- Raises IsNullTree if <theTree> is Null.
- ---Level: Public
- raises OutOfRange from Standard,
- IsNotRoot,
- IsNullTree;
-
- InsertChildAfter( me: mutable; Index: Integer from Standard;
- theTree: HArbitraryTree)
- ---Purpose: Adds <theTree> to <MyChildren>, at <Index>+1, and
- -- all children from <Index>+1 pushed on the right.
- -- Example: Before
- -- me = ( i0 ( i1 i2 i3))
- -- theTree = ( i4), Index = 2
- -- After
- -- me = ( i0 ( i1 i2 i4 i3))
- -- Trigger: Raises OutOfRange if <Index> is greater than NbChildren
- -- Raises IsNotRoot if <theTree> is not a root
- -- Raises IsNullTree if <theTree> is Null
- ---Level: Public
- raises OutOfRange from Standard,
- IsNotRoot,
- IsNullTree;
-
- RemoveChild( me : mutable; Index: Integer from Standard)
- ---Purpose: Removes from <MyChildren> the ArbitraryTree at range <Index>.
- -- Example: Before
- -- me = ( i0 ( i1 i2 i3 i4)) and Index = 2
- -- After
- -- me = ( i0 ( i1 i3 i4))
- -- Trigger: Raises OutOfRange if <Index> is greater than NbChildren
- ---Level: Public
- raises OutOfRange from Standard;
-
- RemoveAllChildren( me: mutable);
- ---Purpose: Removes all my children.
- ---Level: Public
-
- RemoveChildren( me: mutable; FromIndex, ToIndex : Integer from Standard)
- ---Purpose: Removes from <MyChildren> all the ArbitraryTree
- -- located from range <FromIndex> to <ToIndex>.
- -- Example: Before
- -- me = ( i0 ( i1 i2 i3 i4))
- -- FromIndex = 2 and ToIndex = 4
- -- After
- -- me = ( i0 ( i1))
- -- Trigger: Raises OutOfRange if <FromIndex> or <ToIndex> is
- -- greater than NbChildren.
- ---Level: Public
- raises OutOfRange from Standard;
-
- SetParent( me : mutable; theTree : HArbitraryTree)
- ---Purpose: Changes the value of MyParent.
- ---Level: Internal
- is private;
-
-
- ShallowCopy(me) returns mutable like me
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-fields
-
- MyParent : HArbitraryTree;
- MyItem : Item;
- MyChildren: SeqArbitraryTree;
-end;
+++ /dev/null
-// Created on: 1992-08-05
-// Created by: Mireille MERCIEN
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_OutOfRange.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-#include <PCollection_IsNotRoot.hxx>
-#include <PCollection_IsNullTree.hxx>
-#include <PCollection_IsContained.hxx>
-
-// ----------------------------------------------------------------------
-// ----------------------------------------------------------------------
-
-// -----------
-// constructor :
-// -----------
-PCollection_HArbitraryTree::PCollection_HArbitraryTree(const Item& T)
-{
- MyItem = T;
- MyChildren = new PCollection_SeqArbitraryTree;
- }
-
-// -----------------------------------------------
-// Children : Returns the list of children of me
-// -----------------------------------------------
-Handle(PCollection_SeqArbitraryTree)
- PCollection_HArbitraryTree::Children() const
-{
- return MyChildren;
-}
-
-// ----------------------
-// Child : returns a child
-// ----------------------
-Handle(PCollection_HArbitraryTree)
- PCollection_HArbitraryTree::Child(const Standard_Integer Index) const
-{
- return MyChildren->Value(Index);
-}
-
-// ----------------------------------------------
-// Value : returns the value of the current tree
-// ----------------------------------------------
-Item PCollection_HArbitraryTree::Value() const
-{
- return MyItem;
-}
-
-// ----------------------------------------------------
-// NbChildren : Number of children in the current tree
-// ----------------------------------------------------
-Standard_Integer PCollection_HArbitraryTree::NbChildren() const
-{
- return (MyChildren->Length());
-}
-
-// -------------------------------------------------------
-// IsLeaf : Returns True if the current tree has no child
-// -------------------------------------------------------
-Standard_Boolean PCollection_HArbitraryTree::IsLeaf() const
-{
- return (MyChildren->IsEmpty());
-}
-
-// ----------------------
-// Parent
-// ----------------------
-Handle(PCollection_HArbitraryTree) PCollection_HArbitraryTree::Parent() const
-{
- return MyParent;
-}
-
-// ----------------------
-// IsRoot
-// ---------------------
-Standard_Boolean PCollection_HArbitraryTree::IsRoot() const
-{
- return (MyParent.IsNull());
-}
-
-// ---------------------------------------------
-// Root : Returns the root of the current tree
-// ---------------------------------------------
-Handle(PCollection_HArbitraryTree) PCollection_HArbitraryTree::Root() const
-{
- Handle(PCollection_HArbitraryTree) AParent;
- AParent = this;
- while ( !AParent->IsRoot() ) AParent = AParent->Parent();
- return AParent;
-}
-
-// ----------------------------------------------------------------
- // LeftSibling : returns the left neighbour of the current tree
-// ----------------------------------------------------------------
-Handle(PCollection_HArbitraryTree) PCollection_HArbitraryTree::LeftSibling() const
-{
- Handle(PCollection_HArbitraryTree) MySelf,TheParent,NullTree;
- Handle(PCollection_SeqArbitraryTree) TheBrothers;
- NullTree.Nullify();
- MySelf = this;
- if (MySelf->IsRoot()) return NullTree;
- TheBrothers = (MySelf->Parent())->Children();
- Standard_Integer TheIndex = TheBrothers->Location(1,MySelf);
- if (TheIndex <= 1)
- return NullTree;
- else
- return (TheBrothers->Value(TheIndex-1));
-}
-
-// ---------------------------------------------------------------
-// RightSibling : returns the right neighbour of the current tree
-// ---------------------------------------------------------------
-Handle(PCollection_HArbitraryTree) PCollection_HArbitraryTree::RightSibling() const
-{
- Handle(PCollection_HArbitraryTree) MySelf,TheParent,NullTree;
- Handle(PCollection_SeqArbitraryTree) TheBrothers;
- NullTree.Nullify();
- MySelf = this;
- if (MySelf->IsRoot()) return NullTree;
- TheBrothers = (MySelf->Parent())->Children();
- Standard_Integer TheIndex = TheBrothers->Location(1,MySelf);
- if (TheIndex == TheBrothers->Length())
- return NullTree;
- else
- return (TheBrothers->Value(TheIndex+1));
-}
-
-// --------------------------------------------------------------------
-// Contains : checks if the tree Atree is contained by the current one
-// --------------------------------------------------------------------
-Standard_Boolean PCollection_HArbitraryTree::Contains
- (const Handle(PCollection_HArbitraryTree)& ATree) const
-{
- if (ATree.IsNull()) PCollection_IsNullTree::Raise();
- Handle(PCollection_HArbitraryTree) MySelf = this;
- Standard_Boolean IsFound = Standard_False;
- PCollection_ATPreOrderIterator Iter(MySelf);
- while (!IsFound && Iter.More()) {
- if (Iter.Value() == ATree) IsFound = Standard_True;
- Iter.Next();
- }
- return IsFound;
-}
-
-// -------------------------------------------------
-// SetValue : changes the value of the current tree
-// -------------------------------------------------
-void PCollection_HArbitraryTree::SetValue(const Item& T)
-{
- MyItem = T;
-}
-
-// ---------------------------------------------------------
-// SetParent : changes the parent value of the current tree
-// ---------------------------------------------------------
-void PCollection_HArbitraryTree::SetParent
- (const Handle(PCollection_HArbitraryTree)& ATree)
-{
- MyParent = ATree;
-}
-
-// ---------------------------------------------------------------------
-// SwapChild : replace, in the current tree, the child at the range
-// <Index> by the tree <ATree> and conversely
-// ---------------------------------------------------------------------
-void PCollection_HArbitraryTree::SwapChild
- (const Standard_Integer Index,Handle(PCollection_HArbitraryTree)& ATree)
-{
- if (!ATree.IsNull() && !ATree->IsRoot()) PCollection_IsNotRoot::Raise();
- Handle (PCollection_HArbitraryTree) TempTree = ATree;
- Handle (PCollection_HArbitraryTree) NullTree;
- NullTree.Nullify();
-// ... Update the returned tree
- ATree = Child(Index);
- ATree->SetParent(NullTree);
-// ... Update the current tree
- if (! TempTree.IsNull()) InsertChildAfter(Index,TempTree);
- MyChildren->Remove(Index);
-}
-
-// -----------------------------------------------------------------
-// SwapChildren : TradeOff between two subtrees in the current tree
-// -----------------------------------------------------------------
-void PCollection_HArbitraryTree::SwapChildren
- ( const Handle(PCollection_HArbitraryTree)& Subtree1,
- const Handle(PCollection_HArbitraryTree)& Subtree2 )
-{
- if (Subtree1.IsNull() || Subtree2.IsNull())
- PCollection_IsNullTree::Raise();
- if (!Contains(Subtree1) || !Contains(Subtree2))
- Standard_NoSuchObject::Raise();
- if (Subtree1->Contains(Subtree2) || Subtree1->Contains(Subtree2))
- PCollection_IsContained::Raise();
- Handle(PCollection_HArbitraryTree) Parent1 = Subtree1->Parent();
- Handle(PCollection_HArbitraryTree) Parent2 = Subtree2->Parent();
- Handle(PCollection_SeqArbitraryTree)
- Children1 = Parent1->Children();
- Handle(PCollection_SeqArbitraryTree)
- Children2 = Parent2->Children();
-
-// ... Searching the index of the subtrees.
- Standard_Integer Ind1 = Children1->Location(1,Subtree1);
- Standard_Integer Ind2 = Children2->Location(1,Subtree2);
-// ... Insertion of Subtree2
- Handle(PCollection_HArbitraryTree) NullTree;
- NullTree.Nullify();
- Subtree2->SetParent(NullTree);
- Parent1->InsertChildAfter(Ind1,Subtree2);
- Children1->Remove(Ind1);
-// ... Insertion of Subtree1
- Subtree1->SetParent(NullTree);
- Parent2->InsertChildAfter(Ind2,Subtree1);
- Children2->Remove(Ind2);
-}
-
-// -----------------------------------------------------------------------
-// AppendChild : appends the tree <Atree> as last child of the current tree
-// -----------------------------------------------------------------------
-void PCollection_HArbitraryTree::AppendChild
- (const Handle(PCollection_HArbitraryTree)& ATree)
-{
- if (ATree.IsNull()) PCollection_IsNullTree::Raise();
- if (!ATree->IsRoot()) PCollection_IsNotRoot::Raise();
-
- Handle (PCollection_HArbitraryTree) MySelf = this;
- ATree->SetParent(MySelf);
- MyChildren->Append(ATree);
-}
-
-// --------------------------------------------------------------------------
-// PrependChild : appends the tree <ATree> as first child of the current tree
-// --------------------------------------------------------------------------
-void PCollection_HArbitraryTree::PrependChild
- (const Handle(PCollection_HArbitraryTree)& ATree)
-{
- if (ATree.IsNull()) PCollection_IsNullTree::Raise();
- if (!ATree->IsRoot()) PCollection_IsNotRoot::Raise();
-
- Handle (PCollection_HArbitraryTree) MySelf = this;
- ATree->SetParent(MySelf);
- MyChildren->Prepend(ATree);
-
-}
-
-// -----------------------------------------------------------------------
-// InsertChildBefore : adds the child <ATree> at the index <Index> in the
-// current tree
-// -----------------------------------------------------------------------
-void PCollection_HArbitraryTree::InsertChildBefore
- (const Standard_Integer Index ,
- const Handle(PCollection_HArbitraryTree)& ATree)
-{
- if (ATree.IsNull()) PCollection_IsNullTree::Raise();
- if (!ATree->IsRoot()) PCollection_IsNotRoot::Raise();
-
- Handle (PCollection_HArbitraryTree) MySelf = this;
- ATree->SetParent(MySelf);
- MyChildren->InsertBefore(Index,ATree);
-}
-
-// ------------------------------------------------------------------------
-// InsertChildAfter : adds the child <ATree> at the index <Index+1> in the
-// current tree
-// ------------------------------------------------------------------------
-void PCollection_HArbitraryTree::InsertChildAfter
- (const Standard_Integer Index ,
- const Handle(PCollection_HArbitraryTree)& ATree)
-{
- if (ATree.IsNull()) PCollection_IsNullTree::Raise();
- if (!ATree->IsRoot()) PCollection_IsNotRoot::Raise();
-
- Handle (PCollection_HArbitraryTree) MySelf = this;
- ATree->SetParent(MySelf);
- MyChildren->InsertAfter(Index,ATree);
-}
-
-// ---------------------------------------------------------------------
-// RemoveChild : removes the child at range <Index> in the current tree
-// ---------------------------------------------------------------------
-void PCollection_HArbitraryTree::RemoveChild(const Standard_Integer Index)
-{
- MyChildren->Remove(Index);
-}
-
-// -------------------------------------------------------------
-// RemoveAllChildren : removes all children of the current tree
-// -------------------------------------------------------------
-void PCollection_HArbitraryTree::RemoveAllChildren()
-{
- MyChildren->Clear();
-}
-
-// --------------------------------------------------------------------------
-// RemoveChildren : removes the children in range <FromIndex,ToIndex> in the
-// current tree
-// --------------------------------------------------------------------------
-void PCollection_HArbitraryTree::RemoveChildren
- (const Standard_Integer FromIndex , const Standard_Integer ToIndex)
-{
- MyChildren->Remove(FromIndex,ToIndex);
-}
-
-
-
-
-
-
+++ /dev/null
--- Created on: 1992-02-19
--- Created by: Jean Pierre TIRAULT
--- Copyright (c) 1992-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
--- Revised: Thu Jan 7 17:26:12 1993
--- By : Mireille MERCIEN
-
-
-generic class HDataMap from PCollection (Key as Storable;
- Item as Storable;
- FH as Hash(Key) )
-inherits Persistent
-
- ---Purpose: A map is a Collection of bindings
- -- between two objects. One is considered as
- -- the key and a hash code value must be
- -- computed for it.
-
-
-raises MultiplyDefined from Standard,
- NoMoreObject from Standard,
- NoSuchObject from Standard
-
-
-
-
- class MapNode inherits PManaged
- ---Purpose: This class is used in the implementation of Map class.
- is
-
- Create( aKey : Key ; anItem : Item ; aNext : MapNode)
- returns mutable MapNode from PCollection;
-
- GetKey (me) returns any Key is static;
- ---Level: Internal
- ---Purpose: Returns myKey
-
- Value(me) returns any Item is static;
- ---Level: Internal
- ---Purpose: Returns myItem.
-
- Next(me) returns mutable MapNode is static;
- ---Level: Internal
- ---Purpose: Returns myNext.
-
- SetKey (me : mutable ; aKey : Key) is static;
- ---Level: Internal
- ---Purpose: Modifies myKey.
-
- SetValue( me : mutable; anItem: Item) is static;
- ---Level: Internal
- ---Purpose: Modifies myItem.
-
- SetNext( me : mutable; aNode: MapNode) is static;
- ---Level: Internal
- ---Purpose: Modifies myNext.
-
- ShallowCopy(me) returns mutable like me
- is redefined;
- ---Level: Internal
- ---Purpose: ShallowCopy redefinition
- ---C++: function call
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Internal
- ---Purpose: ShallowDump redefinition
- ---C++: function call
-
- fields
-
- myKey : Key;
- myItem : Item;
- myNext : MapNode;
-
- end;
-
- class Array instantiates HArray1 from PCollection(MapNode);
-
- class MapIterator
-
- raises NoMoreObject from Standard,
- NoSuchObject from Standard
- is
- ---Purpose: This class provides to iterate on a Map from the
- -- first bucket entry to the last one in the table;
- -- Going through the associated list for each bucket entry.
-
- Create( aMap: HDataMap)
- ---Purpose: Creates an iterator on <aMap> .
- returns MapIterator;
-
- More( me)
- ---Level: Public
- ---Purpose: Returns True if there is still an element to be read.
- returns Boolean from Standard;
-
- Next( me: in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Goes to next element of <me>.
-
- Value( me)
- ---Level: Public
- returns any Item
- raises NoSuchObject from Standard;
-
- GetKey( me)
- ---Level: Public
- returns Key
- raises NoSuchObject from Standard;
-
- fields
- Buckets : Array;
- NbBuck : Integer;
- Index : Integer;
- Node : MapNode;
- HasMore : Boolean;
- end;
-
-is
- Create(NbBuckets : Integer ; F : FH) returns mutable HDataMap;
- ---Purpose: Creation of a map of NbBuckets entries.
- -- the table is empty.
- -- If NbBuckets eq. 0 an exception will be raised.
-
- NbBuckets(me) returns Integer from Standard;
- ---Level: Public
- ---Purpose: Returns the number of entries in the table.
-
- IsEmpty(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns true if the table is empty.
-
- Extent(me) returns Integer from Standard ;
- ---Level: Public
- ---Purpose: Returns the number of elements in the table.
- ---Example: if me is the hash table ((a x)(b y)(c z)) Extent
- -- returns 3
-
- IsBound(me; K : Key) returns Boolean;
- ---Level: Public
- ---Purpose: Returns True if an element is bounded to K
-
- Find(me; K : Key) returns any Item raises NoSuchObject;
- ---Level: Public
- ---Purpose: Returns the element bounded to K.
- -- Raises an exception if the binding does not exist.
- ---Example: before
- -- me = ((a x)(b y)(c z)) , K = b
- -- returns y
-
- Clear(me:mutable);
- ---Level: Public
- ---Purpose: Removes all the element in the table.
- ---Example: before
- -- me = ((a x)(b y)(c z))
- -- after
- -- me = ()
-
- Bind(me:mutable; K : Key; T : Item)
- raises MultiplyDefined;
- ---Level: Public
- ---Purpose: Creates a binding between a key K and an item T.
- -- Raises an exception if the binding already exists.
- ---Example: before
- -- me = ((a x)(b y)) , K = c , T = z
- -- after
- -- me = ((a x)(b y)(c z))
-
- Rebind(me:mutable; K : Key; T : Item) raises NoSuchObject;
- ---Level: Public
- ---Purpose: Replaces the object binded to the key K by T.
- -- Raises an exception if the binding does not exist.
- ---Example: before
- -- me = ((a x)(b y)) , K = b , T = z
- -- after
- -- me = ((a x)(b z))
-
- Unbind(me:mutable; K : Key) raises NoSuchObject;
- ---Level: Public
- ---Purpose: Removes the binding keyed by K.
- -- Raises an exception if the binding does not exist.
- ---Example: before
- -- me = ((a x)(b y)(c z)) , K = b
- -- after
- -- me = ((a x)(c z))
-
- ShallowCopy(me) returns mutable like me
- is redefined;
- ---Level: Advanced
- ---Purpose: ShallowCopy redefinition
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---Purpose: ShallowDump redefinition
- ---C++: function call
-
-
- GetArray (me) returns Array is private;
- ---Level: Internal
- ---Purpose :Returns the field Buckets associated to the object.
- ---C++: inline
-
- GetFH (me) returns FH is private;
- ---Level: Internal
- ---Purpose :Returns the field Hash associated to the object.
- ---C++: inline
-
-fields
- Buckets : Array;
- Hash : FH;
-
-friends class MapIterator from PCollection
-
-end HDataMap;
-
-
-
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-// ----------------------------------------------------------------------
-// Map implementation:
-// Last Revision : Jan,8 1993 M. Mercien
-// The class SingleList is no more referenced in the
-// implementation of Map.
-// ----------------------------------------------------------------------
-
-//-----------------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------------
-PCollection_HDataMap::PCollection_HDataMap(const Integer NbBuckets,
- const FH& F)
-{
- Buckets = new PCollection_Array( 1 , NbBuckets);
- Hash = F;
-}
-
-
-// ------------------------ READING --------------------------------
-
-//-----------------------------------------------------------------
-// NbBuckets : Return the number of buckets
-//-----------------------------------------------------------------
-Integer PCollection_HDataMap::NbBuckets() const
-{
- return Buckets->Length();
-}
-
-//-----------------------------------------------------------------
-// IsEmpty : Return TRUE if the map is empty
-//-----------------------------------------------------------------
-Boolean PCollection_HDataMap::IsEmpty() const
-{
- Handle(PCollection_MapNode) aNode;
- Boolean Empty = True;
- for (Integer i = 1 ; i <= Buckets->Length() ; i++) {
- aNode = Buckets->Value(i);
- if ( !aNode.IsNull() ) Empty = False;
- }
- return Empty;
-}
-
-//-----------------------------------------------------------------
-// Extent : Returns the number of couples (item,key) contained in
-// the map.
-//-----------------------------------------------------------------
-Integer PCollection_HDataMap::Extent() const
-{
- Integer Number = 0;
- Handle(PCollection_MapNode) aNode;
- for (Integer i = 1 ; i <= Buckets->Length() ; i++) {
- aNode = Buckets->Value(i);
- while ( !aNode.IsNull() ) {
- Number++;
- aNode = aNode->Next();
- }
- }
- return Number;
-}
-
-//-----------------------------------------------------------------
-// IsBound : Returns TRUE if an element is bounded by K
-//-----------------------------------------------------------------
-Boolean PCollection_HDataMap::IsBound(const Key& K ) const
-{
- Integer Res;
- Key TheKey;
- Handle(PCollection_MapNode) aNode;
- Res = Hash.HashCode (K,Buckets->Length());
- aNode = Buckets->Value(Res);
- while ( !aNode.IsNull() ) {
- TheKey = aNode->GetKey();
- if ( Hash.Compare(TheKey,K) ) return True;
- else aNode = aNode->Next();
- }
- return False;
-}
-
-//-----------------------------------------------------------------
-// Find : Returns the element bounded by K
-//-----------------------------------------------------------------
-Item PCollection_HDataMap::Find(const Key& K ) const
-{
- Integer Res;
- Key TheKey;
- Handle(PCollection_MapNode) aNode;
- Res = Hash.HashCode (K,Buckets->Length());
- aNode = Buckets->Value(Res);
- while ( ! aNode.IsNull() ) {
- TheKey = aNode->GetKey();
- if ( Hash.Compare(TheKey,K) ) return aNode->Value();
- else aNode = aNode->Next();
- }
- NoSuchObject::Raise();
-}
-
-// ------------------------ WRITING --------------------------------
-
-//-----------------------------------------------------------------
-// Clear : Remove all couples (item,key) from the map.
-//-----------------------------------------------------------------
-void PCollection_HDataMap::Clear()
-{
- Handle(PCollection_MapNode) aNode1,aNode2;
- for (Integer i = 1 ; i <= Buckets->Length() ; i++) {
- aNode1 = Buckets->Value(i);
- aNode2.Nullify();
- Buckets->SetValue(i,aNode2);
- while ( ! aNode1.IsNull() ) {
- aNode2 = aNode1->Next();
- aNode1.Delete();
- aNode1 = aNode2;
- }
- }
-}
-
-//- ----------------------------------------------------------------
-// Bind : Add a new couple (Item,Key) in the map. The entry point in
-// the map corresponds to the result of Hashcode function (i.e
-// HashCode (key)).
-//- ----------------------------------------------------------------
-void PCollection_HDataMap::Bind(const Key& K , const Item& T)
-{
- Integer Res ;
- Key TheKey;
- Handle(PCollection_MapNode) aNode1,aNode2,pnul;
- pnul.Nullify();
- aNode1 = new PCollection_MapNode ( K , T , pnul) ;
- Res = Hash.HashCode (K,Buckets->Length());
- aNode2 = Buckets->Value(Res);
- if ( ! aNode2.IsNull()) {
- while ( ! aNode2.IsNull() ) {
- TheKey = aNode2->GetKey();
- if ( Hash.Compare(TheKey,K) ) MultiplyDefined::Raise();
- aNode2 = aNode2->Next();
- }
- aNode2 = Buckets->Value(Res);
- aNode1->SetNext(aNode2);
- }
- Buckets->SetValue(Res,aNode1);
-}
-
-//-----------------------------------------------------------------
-// Rebind : For an existant couple (Key,AnItem) in the map change
-// le value of the item.
-// If the couple does not exist raise an exception
-//-----------------------------------------------------------------
-void PCollection_HDataMap::Rebind(const Key& K , const Item& T)
-{
- Integer Res ;
- Key TheKey;
- Handle(PCollection_MapNode) aNode;
- Res = Hash.HashCode (K,Buckets->Length());
- aNode = Buckets->Value(Res);
- while ( ! aNode.IsNull() ) {
- TheKey = aNode->GetKey();
- if ( Hash.Compare(TheKey,K) ) {
- aNode->SetValue(T);
- return;
- }
- else {
- aNode = aNode->Next();
- }
- }
- NoSuchObject::Raise();
-}
-
-//-----------------------------------------------------------------
-// Unbind : Remove the couple keyed by K
-// If the couple does not exist raise an exception
-//-----------------------------------------------------------------
-void PCollection_HDataMap::Unbind(const Key& K)
-{
- Integer Res ;
- Key TheKey;
- Handle(PCollection_MapNode) aNode,pnul,previous,next;
- Res = Hash.HashCode (K,Buckets->Length());
- aNode = Buckets->Value(Res);
- pnul.Nullify();
- previous.Nullify();
- while ( ! aNode.IsNull() ) {
- TheKey = aNode->GetKey();
- if ( Hash.Compare(TheKey,K) ) {
- next = aNode->Next();
- if (previous.IsNull() && next.IsNull()) { // liste de 1 elt
- Buckets->SetValue(Res,pnul);
- aNode.Delete();
-
- } else if (previous.IsNull()) { // 1er elt de liste
- Buckets->SetValue(Res,next);
- aNode.Delete();
- next.Nullify();
-
- } else if (next.IsNull()) { // dernier de liste
- previous->SetNext(pnul);
- aNode.Delete();
-
- } else { // milieu de liste
- previous->SetNext(next);
- aNode.Delete();
- next.Nullify();
- }
- return;
- }
-
- else { // pas le bon noeud
- previous = aNode;
- aNode = aNode->Next();
- }
- }
- NoSuchObject::Raise();
-}
-
-//-----------------------------------------------------------------
-// ShallowCopy : ShallowCopy redefinition
-//-----------------------------------------------------------------
-Handle(Standard_Persistent) PCollection_HDataMap::ShallowCopy() const
-{
- PCollection_HDataMap* TheCopy = new PCollection_HDataMap (*this);
- TheCopy->Buckets =
- Handle(PCollection_Array)::DownCast(::ShallowCopy(Buckets));
- return TheCopy;
-}
-
-//-----------------------------------------------------------------
-// ShallowDump : ShallowDump redefinition
-//-----------------------------------------------------------------
-void PCollection_HDataMap::ShallowDump(OStream& S) const
-{
- S << "begin class Map "<< endl;
- if (!IsEmpty())
- Buckets->ShallowDump(S);
- else
- S << "Empty Map." << endl;
- S << "end of class Map." << endl;
-}
-
-
-
-
-
-
-
+++ /dev/null
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// inline methods for HMap class from PCollection.
-// Written by JPT FEB,24 1992
-
-
-// --------------------------------------------------
-// Returns the field Buckets associated to the object
-// --------------------------------------------------
-inline Handle(PCollection_Array) PCollection_HDataMap::GetArray() const {
- return Buckets;
-}
-
-// --------------------------------------------------
-// Returns the field FH associated to the object
-// --------------------------------------------------
-inline FH PCollection_HDataMap::GetFH() const {
- return Hash;
-}
-
-
+++ /dev/null
--- Created on: 1991-04-24
--- Created by: Denis PASCAL
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
--- Revised: Mireille MERCIEN
-
-
-generic class HDirectedGraph from PCollection (
- Item as Storable ;
- Attribute as Storable)
-
- ---Purpose: Definition of a generic directed graph for a type of
- -- Item associated to a vertex, and a type of Attribute
- -- associated to an Edge. A Directed Graph is a
- -- collection that includes a set of Vertices and a set
- -- of Edges. A vertex, also called a "Node", forms the
- -- basic structural element of the graph. Each edge,
- -- also called an "Arc" defines an oriented link between
- -- two vertices. In the scheme A->B, vertex A is called
- -- the SOURCE of the link, B its DESTINATION, and B is
- -- ADJACENT to A. If there is no edge which destinates
- -- to a vertex, this vertex is a ROOT of the graph. If
- -- there is no edge which originates from a vertex, this
- -- vertex is a LEAF of the graph.
-
- ---Keywords: SOURCE vertex, DESTINATION Vertex, ROOT vertex, LEAF
- -- vertex, ADJACENT vertex. Depth-first search, breadth, first Search.
-
- ---References: Software Components with ADA (The Benjamin/Cummings
- -- Company, Inc. 1986).
-
-
-
-inherits Persistent
-raises NoSuchObject from Standard,
- NoMoreObject from Standard
-
-
- class Edge inherits Persistent
-
- ---Purpose: Defines nested class Edge of a Directed Graph.
- -- An Edge is an oriented link between two vertices.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
-
- Create (Source,Destination : Vertex; Value : Attribute)
- ---Purpose: Creates an oriented link between <source> and
- -- <destination> with an associated attribute. To
- -- be used only by DirectedGraph methods to
- -- create and add an edge to a given graph.
- returns mutable Edge;
-
- GetAttribute (me)
- ---Level: Public
- ---Purpose: Returns attribute associated to <me>.
- returns Attribute;
-
- SetAttribute (me : mutable; Value : Attribute)
- ---Level: Internal
- ---Purpose: To associate an attribute to <me>.
- is private;
-
- Source (me)
- ---Level: Public
- ---Purpose: Returns the vertex which originates from <me>.
- returns mutable Vertex;
-
- SetSource (me :mutable; V: Vertex)
- ---Level: Internal
- ---Purpose: Sets the vertex which originates from <me>.
- is private;
-
- Destination (me)
- ---Level: Public
- ---Purpose: Returns the vertex which destinates to <me>.
- returns mutable Vertex;
-
- SetDestination (me :mutable ; V: Vertex)
- ---Level: Internal
- ---Purpose: Sets the vertex which destinates to <me>.
- is private;
-
- Reverse (me : mutable);
- ---Level: Public
- ---Purpose: Reverse the orientation of <me>.
- -- The source vertex becomes the destination vertex, and
- -- the destination becomes the source.
-
- IsLoop (me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if the fields <MyDestination> and
- -- <Mysource> are equal.
-
- fields
- MyAttribute : Attribute;
- MySource : Vertex;
- MyDestination : Vertex;
-
- friends class HDirectedGraph from PCollection,
- class Vertex from PCollection
-
- end;
-
- class SetOfEdge instantiates HSet from PCollection(Edge);
- ---Purpose: Defines nested class SetOfEdge used as field of
- -- Vertex and DirectedGraph.
-
- class SetOfVertex instantiates HSet from PCollection(Vertex);
- ---Purpose: Defines nested class SetOfVertex used as field of a
- -- DirectedGraph.
-
- class StackOfVertex instantiates HStack from PCollection(Vertex);
- ---Purpose: Defines nested class StackOfVertex used as field of
- -- DepthFirstIterator class.
-
-
- class QueueOfVertex instantiates HQueue from PCollection(Vertex);
- ---Purpose: Defines nested class QueueOfVertex used as field of
- -- BreadthFirstIterator.
-
- class FrontEdgesIterator
- ---Purpose: Defines nested class FrontEdgesIterator, to visit
- -- every edge that originates from a given vertex.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
-
- Create (aVertex : Vertex) returns FrontEdgesIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other edges.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Set the iterator to the next Edge.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the edge value for the current
- -- position of the iterator.
- returns any Edge
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting all edges.
-
- fields
- MyEdgeIterator : SetIteratorOfSetOfEdge;
- HasMore : Boolean from Standard;
- end;
-
- class BackEdgesIterator
- ---Purpose: Defines nested class BackEdgesIterator, to visit
- -- every edge that destinates to a given vertex.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
- Create (aVertex : Vertex) returns BackEdgesIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other edges.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next edge.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the edge value for the current
- -- position of the iterator.
- returns any Edge
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting all edges.
-
- fields
- MyEdgeIterator : SetIteratorOfSetOfEdge;
- HasMore : Boolean from Standard;
- end;
-
- class DepthFirstIterator
- ---Purpose: Defines nested class DepthFirstIterator, to visit
- -- every vertex that depends of a given one. Depth
- -- First Search is functionnally the equivalent of a
- -- preorder tree traversal. We start at a given
- -- Vertex V and recursively visit all adjacent
- -- unvisited Vertices.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
-
- Create (aVertex : Vertex) returns DepthFirstIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other vertices.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next vertex.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the vertex value for the current
- -- position of the iterator.
- returns any Vertex
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting
- -- all vertices.
-
- fields
- Visited : SetOfVertex;
- Ready : StackOfVertex;
- HasMore : Boolean from Standard;
- end;
-
- class BreadthFirstIterator
- ---Purpose: Defines nested class BreadthFirstIterator, to visit
- -- every vertex that depends of a given one. We start
- -- at a given vertex V, visit all its adjacent
- -- vertices, and then recursively visit the unvisited
- -- adjacent vertices of these previous ones.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
-
- Create (aVertex : Vertex) returns BreadthFirstIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other vertices.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next vertex.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the vertex value for the current
- -- position of the iterator.
- returns any Vertex
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting
- -- all vertices.
-
- fields
- Visited : SetOfVertex;
- Ready : QueueOfVertex;
- HasMore : Boolean from Standard;
- end;
-
- class AdjacentVerticesIterator
-
- ---Purpose: Defines nested class AdjacentVerticesIterator, to
- -- visit every adjacent vertex of a given one
- -- (Destination vertices of its front edges).
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
- Create (aVertex : Vertex) returns AdjacentVerticesIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other vertices.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next vertex.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the vertex value for the current
- -- position of the iterator.
- returns any Vertex
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting all vertices.
-
- fields
- MyEdgeIterator : SetIteratorOfSetOfEdge;
- HasMore : Boolean from Standard;
- end;
-
------------------------ Class Vertex ----------------------------------
-
- class Vertex inherits Persistent
- ---Purpose: Defines nested class vertex of a DirectedGraph. The
- -- Vertex is the basic element of a graph.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
-
- Create (Value : Item ; InGraph : HDirectedGraph)
- ---Purpose: Creates a vertex with an associated item. To
- -- be used only by DirectedGraph methods to
- -- create and add a vertex to a given graph.
- returns mutable Vertex;
-
- GetItem (me)
- ---Level: Public
- ---Purpose: Returns item associated to <me>.
- returns any Item;
-
- SetItem (me : mutable; value : Item)
- ---Level: Internal
- ---Purpose: Associates an item to <me>.
- is private;
-
- GetGraph (me)
- ---Level: Public
- ---Purpose: Returns the HDirectedGraph which owns <me>.
- returns HDirectedGraph;
-
- AddFrontEdge (me : mutable; anEdge : Edge)
- ---Level: Internal
- ---Purpose: To add an edge that destinates to <me>.
- -- To be used only by editing methods of a DirectedGraph.
- -- Returns False if the edge already exists.
- returns Boolean from Standard
- is private;
-
- RemoveFrontEdge (me : mutable; anEdge : Edge)
- ---Level: Internal
- ---Purpose: To remove an edge that originates from <me>.
- -- To be used only by editing methods of a DirectedGraph.
- -- An exception is raised if <anEdge> doesn't belong to
- -- myFrontEdges field.
- raises NoSuchObject from Standard
- is private;
-
- NbFrontEdges (me) returns Integer;
- ---Level: Public
- ---Purpose: Returns the number of edges which originates from <me>.
-
- GetFrontEdges (me)
- ---Level: Public
- ---Purpose: Returns "myFrontEdges" Field for Iterator.
- returns SetOfEdge
- is private;
-
- AddBackEdge (me : mutable; anEdge : Edge)
- ---Level: Internal
- ---Purpose: To add an edge that destinates to <me>. To be
- -- used only by editing methods of a
- -- DirectedGraph, to update it after
- -- modifications. Returns False if the edge already exists.
- returns Boolean from Standard
- is private;
-
- RemoveBackEdge (me : mutable; anEdge : Edge)
- ---Level: Internal
- ---Purpose: To remove an edge that destinates to <me>. To
- -- be used only by editing methods of a
- -- DirectedGraph, to update it after
- -- modifications. An exception is raised if
- -- <anEdge> doesn't belong to myBackEdges field.
- raises NoSuchObject from Standard
- is private;
-
- NbBackEdges (me)
- ---Level: Public
- ---Purpose: Returns the number of edge which destinates to <me>.
- returns Integer from Standard;
-
- GetBackEdges (me)
- ---Level: Internal
- ---Purpose: Returns "myBackEdges" field for Iterator.
- returns SetOfEdge
- is private;
-
- IsRoot (me)
- ---Level: Public
- ---Purpose: Returns TRUE if NbBackEdges = 0.
- returns Boolean from Standard;
-
- IsLeaf (me)
- ---Level: Public
- ---Purpose: Returns TRUE if NbFrontEdges = 0.
- returns Boolean from Standard;
-
- IsDestination (me; aVertex : Vertex)
- ---Level: Public
- ---Purpose: Returns TRUE if it exists an edge which
- -- originates from <me> and destinates to <aVertex>.
- returns Boolean from Standard;
-
- IsSource (me; aVertex : Vertex)
- ---Level: Public
- ---Purpose: Returns TRUE if it exists an edge which
- -- originates from <aVertex> and destinates to <me>.
- returns Boolean from Standard;
-
- fields
- MyItem : Item;
- MyGraph : HDirectedGraph;
- MyFrontEdges : SetOfEdge;
- MyBackEdges : SetOfEdge;
-
- friends class HDirectedGraph from PCollection,
- class Edge from PCollection,
- class BackEdgesIterator from PCollection,
- class FrontEdgesIterator from PCollection,
- class DepthFirstIterator from PCollection,
- class BreadthFirstIterator from PCollection,
- class AdjacentVerticesIterator from PCollection
- end;
-
-
- class VerticesIterator
- ---Purpose: Defines nested class VerticesIterator, to visit
- -- every vertex of a given directed graph.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
- Create (aGraph : HDirectedGraph) returns VerticesIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other vertices.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next vertex.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the vertex value for the current
- -- position of the iterator.
- returns any Vertex
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting
- -- all vertices.
-
- fields
- MyVertexIterator : SetIteratorOfSetOfVertex;
- HasMore : Boolean from Standard;
- end;
-
- class RootsIterator
- ---Purpose: Defines nested class RootsIterator, to visit every
- -- "root" vertex of a directed graph.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
- Create (aGraph : HDirectedGraph) returns RootsIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other vertices.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next vertex.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the vertex value for the current
- -- position of the iterator.
- returns any Vertex
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting
- -- all vertices.
-
- fields
- MyVertexIterator : SetIteratorOfSetOfVertex;
- HasMore : Boolean from Standard;
- end;
-
- class LeavesIterator
- ---Purpose: Defines nested class LeavesIterator, to visit every
- -- "leaf" vertex of a directed graph.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
- Create (aGraph : HDirectedGraph) returns LeavesIterator;
-
- More (me)
- ---Level: Public
- ---Purpose: Returns TRUE if there are other vertices.
- returns Boolean from Standard;
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Set the iterator to the next vertex.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the vertex value for the current
- -- position of the iterator.
- returns any Vertex
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting
- -- all vertices.
-
- fields
- MyVertexIterator : SetIteratorOfSetOfVertex;
- HasMore : Boolean from Standard;
- end;
-
- class EdgesIterator
- ---Purpose: Defines nested class EdgesIterator, to visit every
- -- edge of a directed graph.
-
- raises NoMoreObject from Standard ,
- NoSuchObject from Standard
- is
- Create (aGraph : HDirectedGraph) returns EdgesIterator;
-
- More (me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns TRUE if there are other edges.
-
- Next (me : in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next edge.
-
- Value (me)
- ---Level: Public
- ---Purpose: Returns the edge value for the current
- -- position of the iterator.
- returns any Edge
- raises NoSuchObject from Standard;
-
- Clear (me : in out);
- ---Level: Public
- ---Purpose: To clear the iterator before having visiting all edges.
-
- fields
- MyEdgeIterator : SetIteratorOfSetOfEdge;
- HasMore : Boolean from Standard;
- end;
-
---------------------- class HDirectedGraph -----------------------------
-
-is
-
- Create returns mutable HDirectedGraph;
- ---Purpose: Creates an empty Directed Graph.
-
- NumberOfVertices (me) returns Integer from Standard;
- ---Level: Public
-
- NumberOfEdges (me) returns Integer from Standard;
- ---Level: Public
-
- NumberOfLeaves (me) returns Integer from Standard;
- ---Level: Public
- ---Purpose: Returns the number of "leaf" vertices of <me>.
-
- NumberOfRoots (me) returns Integer from Standard;
- ---Level: Public
- ---Purpose: Returns the number of "root" vertices of <me>.
-
- IsEmpty (me) returns Boolean from Standard;
- ---Level: Public
-
- Clear (me : mutable);
- ---Level: Public
- ---Purpose: Removes all edges and vertices of <me>.
-
- IsMember (me; aVertex : Vertex) returns Boolean from Standard;
- ---Level: Public
-
- IsMember (me; anEdge : Edge) returns Boolean from Standard;
- ---Level: Public
-
- Add (me : mutable; Value : Item)
- ---Level: Public
- ---Purpose: Creates and Adds a vertex, with a given value
- -- <value>, to <me>. Of course this new Vertex is a
- -- "root" and "leaf" vertex of <me> because it has no
- -- connexion with other vertices of the directed graph.
- returns mutable Vertex;
-
- Remove (me : mutable; aVertex : mutable Vertex)
- ---Level: Public
- ---Purpose: Removes <aVertex> from <me>. Removes also all the
- -- edges of <me> which reference <aVertex>; Updates
- -- Source and Destination vertices of each of these
- -- edges . Raises an exception if <aVertex> is not
- -- member of <me>.
- raises NoSuchObject from Standard;
-
- Add (me : mutable; Source : mutable Vertex;
- Destination : mutable Vertex; Value : Attribute)
- ---Level: Public
- ---Purpose: Creates and adds an edge from <source> to
- -- <destination>, with the attribute <value>, to
- -- <me>. Updates Source and Destination Vertices of
- -- this new edge. Raises an exception if <source> or
- -- <destination> are not members of <me>.
- returns mutable Edge
- raises NoSuchObject from Standard;
-
- Remove (me : mutable; AnEdge : mutable Edge)
- ---Level: Public
- ---Purpose: Removes <anEdge> from <me>. And Updates Source
- -- and Destination Vertices of <anEdge>. Raises an
- -- exception if <Edge> is not member of <me>.
- raises NoSuchObject from Standard;
-
- GetVertices (me)
- ---Level: Internal
- ---Purpose: Returns "myVertices" field for Iterator.
- returns SetOfVertex
- is private;
-
- GetEdges (me)
- ---Level: Internal
- ---Purpose: Returns "myEdges" field for Iterator.
- returns SetOfEdge
- is private;
-
- ShallowCopy(me) returns mutable like me
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
-fields
- MyVertices : SetOfVertex;
- MyEdges : SetOfEdge;
-
- friends class VerticesIterator from PCollection,
- class RootsIterator from PCollection,
- class LeavesIterator from PCollection,
- class EdgesIterator from PCollection
-end;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised: Mireille MERCIEN
-
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-//----------------------------------------------------------------------
-PCollection_HDirectedGraph::PCollection_HDirectedGraph ()
-{
- MyVertices = new PCollection_SetOfVertex;
- MyEdges = new PCollection_SetOfEdge;
-}
-
-//--------------------------------------------------------------------
-Integer PCollection_HDirectedGraph::NumberOfVertices () const
-{
- return MyVertices->Extent();
-}
-
-
-//--------------------------------------------------------------------
-Integer PCollection_HDirectedGraph::NumberOfEdges () const
-{
- return MyEdges->Extent();
-}
-
-//--------------------------------------------------------------------
-Integer PCollection_HDirectedGraph::NumberOfLeaves () const
-{
- Integer nb = 0;
- PCollection_SetIteratorOfSetOfVertex It (MyVertices);
- while (It.More()) {
- Handle(PCollection_Vertex) V = It.Value();
- if (V->IsLeaf()) nb++;
- It.Next();
- }
- return nb;
-}
-
-
-//--------------------------------------------------------------------
-Integer PCollection_HDirectedGraph::NumberOfRoots () const
-{
- Integer nb = 0;
- PCollection_SetIteratorOfSetOfVertex It(MyVertices);
- while (It.More()) {
- Handle(PCollection_Vertex) V = It.Value();
- if (V->IsRoot()) nb++;
- It.Next();
- }
- return nb;
-}
-
-
-//--------------------------------------------------------------------
-Boolean PCollection_HDirectedGraph::IsEmpty () const
-{
- return (MyVertices->Extent() == 0);
-}
-
-
-//--------------------------------------------------------------------
-void PCollection_HDirectedGraph::Clear ()
-{
- MyVertices = new PCollection_SetOfVertex;
- MyEdges = new PCollection_SetOfEdge;
-}
-
-
-//--------------------------------------------------------------------
-Boolean PCollection_HDirectedGraph::IsMember
- (const Handle(PCollection_Vertex)& V) const
-{
- return MyVertices->Contains(V);
-}
-
-
-//--------------------------------------------------------------------
-Boolean PCollection_HDirectedGraph::IsMember
- (const Handle(PCollection_Edge)& E) const
-{
- return MyEdges->Contains(E);
-}
-
-
-//--------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_HDirectedGraph::Add
- (const Item& val)
-{
- Handle(PCollection_Vertex) V = new PCollection_Vertex (val,this);
- MyVertices->Add(V);
- return V;
-}
-
-
-//--------------------------------------------------------------------
-void PCollection_HDirectedGraph::Remove (const Handle(PCollection_Vertex)& V)
-{
- if (IsMember(V)) {
- PCollection_BackEdgesIterator ItBack(V);
- while (ItBack.More()) {
- Handle(PCollection_Edge) BE = ItBack.Value();
- if (BE->Source() != V) BE->Source()->RemoveFrontEdge(BE);
- MyEdges->Remove(BE);
- ItBack.Next();
- }
- PCollection_FrontEdgesIterator ItFront(V);
- while (ItFront.More()) {
- Handle(PCollection_Edge) FE = ItFront.Value();
- if (FE->Destination() != V) FE->Destination()->RemoveBackEdge(FE);
- if (MyEdges->Contains(FE)) MyEdges->Remove(FE);
- ItFront.Next();
- }
- MyVertices->Remove(V);
-// V->Nullify(); // test Handle nul sur Vertex retire
- }
- else {
- NoSuchObject::Raise();
- }
-}
-
-
-//--------------------------------------------------------------------
-Handle(PCollection_Edge) PCollection_HDirectedGraph::Add
- (const Handle(PCollection_Vertex)& source,
- const Handle(PCollection_Vertex)& destination,
- const Attribute& A)
-{
- if (IsMember(source) && IsMember(destination)) {
- Handle(PCollection_Edge) E = new PCollection_Edge (source,destination,A);
- source->AddFrontEdge (E);
- destination->AddBackEdge(E);
- MyEdges->Add (E);
- return E;
- }
- else {
- NoSuchObject::Raise();
- }
-}
-
-//--------------------------------------------------------------------
-void PCollection_HDirectedGraph::Remove (const Handle(PCollection_Edge)& E)
-{
- if (IsMember(E)) {
- (E->Source())->RemoveFrontEdge(E);
- (E->Destination())->RemoveBackEdge(E);
- MyEdges->Remove(E);
-// E->Nullify(); // test Handle nul sur Edge retire
- }
- else {
- NoSuchObject::Raise();
- }
-}
-
-
-//--------------------------------------------------------------------
-Handle(PCollection_SetOfVertex) PCollection_HDirectedGraph::GetVertices() const
-{
- return MyVertices;
-}
-
-
-//--------------------------------------------------------------------
-Handle(PCollection_SetOfEdge) PCollection_HDirectedGraph::GetEdges() const
-{
- return MyEdges;
-}
-
-
-
-
-
-
-
-
+++ /dev/null
--- Copyright (c) 1992-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
----Version:
-
--- Version Date Purpose
--- 10/12/92 Creation
-
-
-generic class HDoubleMap from PCollection ( Key as Storable ;
- Item as Storable ;
- KeyHash as Hash(Key) ;
- ItemHash as Hash(Item) )
-
----Purpose: A double map is a Collection of bindings between two objects.
--- It can be retrieved either by its Key or its Item;a hash code
--- value must be computed for both.
-
-inherits Persistent from Standard
-
-raises
-
- MultiplyDefined from Standard,
- NoMoreObject from Standard,
- NoSuchObject from Standard
-
-
-class DoubleMapNode from PCollection inherits PManaged from PMMgt
----Purpose: Class used in the implementation of the DoubleMap class. It stores
--- Key and Item and two references to DoubleMapNode, one used to make Hashed
--- list for Key , the other to make Hashed list for Item.
-
-is
-
- Create( aKey : Key ; anItem : Item ; nextKey : DoubleMapNode ;
- nextItem : DoubleMapNode ) returns mutable DoubleMapNode;
- ---Purpose: Creates a DoubleMapNode.
-
- SetNextKey ( me : mutable ; aNode : DoubleMapNode ) is static;
- ---Level: Internal
- ---Purpose: Sets the next node of Key hashed list.
-
- SetNextItem ( me : mutable ; aNode : DoubleMapNode ) is static;
- ---Level: Internal
- ---Purpose: Sets the next node of Item hashed list.
-
- GetKey ( me ) returns any Key is static;
- ---Level: Internal
- ---Purpose: Returns the key.
-
- GetItem ( me ) returns any Item is static;
- ---Level: Internal
- ---Purpose: Returns the item.
-
- NextKey ( me ) returns any DoubleMapNode is static;
- ---Level: Internal
- ---Purpose: Returns the next node of Key hashed list.
-
- NextItem ( me ) returns any DoubleMapNode is static;
- ---Level: Internal
- ---Purpose: Returns the next node of Item hashed list.
-
-fields
-
- myKey : Key;
- myItem : Item;
- myNextKey : DoubleMapNode;
- myNextItem : DoubleMapNode;
-
-end DoubleMapNode;
-
-class ArrayDoubleMap instantiates HArray1 from PCollection (DoubleMapNode);
-
-
-class DoubleMapIterator
-
----Purpose: This class provides services to iterate on all bindings of
--- a DoubleMap.
-
-raises
-
- NoMoreObject from Standard,
- NoSuchObject from Standard
-
-is
-
- Create ( aDoubleMap : HDoubleMap from PCollection)
- returns DoubleMapIterator;
- ---Purpose: Creates an iterator of <aDoubleMap>.
-
- More ( me ) returns Boolean;
- ---Level: Public
- ---Purpose: Returns True if there are others couples (Item,Key).
-
- Next ( me : in out )
- ---Level: Public
- ---Purpose: Sets the iterator to the next couple (Item,Key).
- raises NoMoreObject from Standard;
-
- KeyValue ( me ) returns Key
- ---Level: Public
- ---Purpose: Returns the Key value corresponding to the current position
- -- of the iterator.
- raises NoSuchObject from Standard;
-
- ItemValue ( me ) returns Item
- ---Level: Public
- ---Purpose: Returns the Item value corresponding to the current position
- -- of the iterator.
- raises NoSuchObject from Standard;
-
-fields
-
- myBuckets : ArrayDoubleMap;
- myCurrentIndex : Integer;
- myCurrentNode : DoubleMapNode;
-
-end DoubleMapIterator;
-
-is
-
- Create ( NbBuckets : Integer; fhKey : KeyHash; fhItem : ItemHash )
- returns mutable HDoubleMap;
- ---Purpose: Creates a double map of <NbBuckets> entries.
-
- NbBuckets ( me ) returns Integer;
- ---Level: Public
- ---Purpose: Returns the number of entries in the double map <me>.
-
- Extent ( me ) returns Integer;
- ---Level: Public
- ---Purpose: Returns the number of couples (<Key>,<Item>) stored in <me>.
-
- Bind ( me : mutable ; aKey : Key; anItem : Item )
- ---Level: Public
- ---Purpose: Adds the pair (<aKey>,<anItem>) to <me>.
- ---Trigger: Raises an exception if the binding already exists.
- raises MultiplyDefined from Standard;
-
- FindItem ( me ; aKey : Key ) returns any Item
- ---Level: Public
- ---Purpose: Returns the item bounded by <aKey>.
- ---Trigger: Raises an exception if the binding does not exist.
- raises NoSuchObject from Standard;
-
- FindKey ( me ; anItem : Item ) returns any Key
- ---Level: Public
- ---Purpose: Returns the key bounded by <anItem>.
- raises NoSuchObject from Standard;
- ---Trigger: Raises if the binding does not exist.
-
- UnbindKey ( me : mutable ; aKey : Key )
- ---Level: Public
- ---Purpose: Unbinds the couple keyed by <aKey>.
- raises NoSuchObject from Standard;
- ---Trigger: Raises if the binding does not exist.
-
- UnbindItem ( me : mutable ; anItem : Item )
- ---Level: Public
- ---Purpose: Unbinds the couple keyed by <anItem>.
- raises NoSuchObject from Standard;
- ---Trigger: Raises if the binding does not exist.
-
- Clear ( me : mutable );
- ---Level: Public
- ---Purpose: Clears the double map.
-
- IsBoundByKey ( me ; aKey : Key ) returns Boolean;
- ---Level: Public
- ---Purpose: Returns True if an element is bound by <aKey>.
-
- IsBoundByItem ( me ; anItem : Item ) returns Boolean;
- ---Level: Public
- ---Purpose: Returns True if an element is bound by <anItem>.
-
- IsEmpty ( me ) returns Boolean;
- ---Level: Public
- ---Purpose: Returns True if the DoubleMap <me> is empty.
-
- GetArrayKey ( me ) returns ArrayDoubleMap is static private;
- ---Level: Internal
- ---Purpose: Returns the ArrayDoubleMap for Key.
-
-fields
-
- myNumber : Integer; -- Number of couples
- myArrayKey : ArrayDoubleMap;
- myArrayItem : ArrayDoubleMap;
- myKeyHash : KeyHash;
- myItemHash : ItemHash;
-
-friends
-
- class DoubleMapIterator from PCollection
-
-end HDoubleMap;
-
-
+++ /dev/null
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-Version:
-
-// Version Date Purpose
-// 14/12/92 Creation
-
-//-Language C++2.0
-
-//-Declarations
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-//=======================================================================
-// Function : HDoubleMap
-//=======================================================================
-
-PCollection_HDoubleMap::PCollection_HDoubleMap
- (
- const Standard_Integer NbBuckets ,
- const KeyHash &fhKey,
- const ItemHash &fhItem )
-{
-
- myArrayKey = new PCollection_ArrayDoubleMap(1,NbBuckets);
- myArrayItem = new PCollection_ArrayDoubleMap(1,NbBuckets);
- myKeyHash = fhKey;
- myItemHash = fhItem;
- myNumber = 0;
-
-}
-
-//=======================================================================
-// Function : NbBuckets
-//=======================================================================
-
-Standard_Integer PCollection_HDoubleMap::NbBuckets() const
-{
- return myArrayKey->Length();
-}
-
-//=======================================================================
-// Function : Extent
-//=======================================================================
-
-Standard_Integer PCollection_HDoubleMap::Extent() const
-{
- return myNumber;
-}
-
-//=======================================================================
-// Function : Bind
-//=======================================================================
-
-void PCollection_HDoubleMap::Bind (const Key &aKey , const Item &anItem)
-{
- Standard_Integer ResHashKey,ResHashItem;
- Handle(PCollection_DoubleMapNode) theNewNode;
-
- if ( IsBoundByKey(aKey) || IsBoundByItem(anItem) )
- Standard_MultiplyDefined::Raise();
- else {
- ResHashKey = myKeyHash.HashCode(aKey,myArrayKey->Length());
- ResHashItem = myItemHash.HashCode(anItem,myArrayItem->Length());
- theNewNode =
- new PCollection_DoubleMapNode(aKey,anItem,
- myArrayKey->Value(ResHashKey),
- myArrayItem->Value(ResHashItem));
- myArrayKey->SetValue(ResHashKey,theNewNode);
- myArrayItem->SetValue(ResHashItem,theNewNode);
- myNumber++;
- }
-}
-
-//=======================================================================
-// Function : FindItem
-//=======================================================================
-
-Item PCollection_HDoubleMap::FindItem ( const Key &aKey ) const
-{
- Standard_Integer ResHashKey;
- Handle(PCollection_DoubleMapNode) theKeyNode;
-
- ResHashKey = myKeyHash.HashCode(aKey,myArrayKey->Length());
- theKeyNode = myArrayKey->Value(ResHashKey);
- while ( ! theKeyNode.IsNull() ) {
- if ( myKeyHash.Compare(theKeyNode->GetKey(),aKey) )
- return theKeyNode->GetItem();
- else theKeyNode = theKeyNode->NextKey();
- }
- Standard_NoSuchObject::Raise();
-}
-
-//=======================================================================
-// Function : FindKey
-//=======================================================================
-
-Key PCollection_HDoubleMap::FindKey ( const Item &anItem ) const
-{
- Standard_Integer ResHashItem;
- Handle(PCollection_DoubleMapNode) theItemNode;
-
- ResHashItem = myItemHash.HashCode(anItem,myArrayItem->Length());
- theItemNode = myArrayItem->Value(ResHashItem);
- while ( ! theItemNode.IsNull() ) {
- if ( myItemHash.Compare(theItemNode->GetItem(),anItem) )
- return theItemNode->GetKey();
- else theItemNode = theItemNode->NextItem();
- }
- Standard_NoSuchObject::Raise();
-}
-
-//=======================================================================
-// Function : UnbindKey
-//=======================================================================
-
-void PCollection_HDoubleMap::UnbindKey ( const Key &aKey )
-{
- Standard_Integer ResHashKey,ResHashItem;
- Handle(PCollection_DoubleMapNode)
- currentKeyNode,previousKeyNode,previousItemNode,currentItemNode,nullNode;
- Standard_Boolean NoKey = Standard_True;
- Standard_Boolean NoItem = Standard_True;
-
- ResHashKey = myKeyHash.HashCode(aKey,myArrayKey->Length());
- currentKeyNode = myArrayKey->Value(ResHashKey);
- while ( NoKey && !currentKeyNode.IsNull() ) {
- if ( myKeyHash.Compare(currentKeyNode->GetKey(),aKey) )
- NoKey = Standard_False;
- else {
- previousKeyNode = currentKeyNode;
- currentKeyNode = currentKeyNode->NextKey();
- }
- }
-
- if ( NoKey ) Standard_NoSuchObject::Raise();
- else {
- ResHashItem =
- myItemHash.HashCode(currentKeyNode->GetItem(),myArrayItem->Length());
- currentItemNode = myArrayItem->Value(ResHashItem);
- while ( NoItem && !currentItemNode.IsNull() ) {
- if ( currentItemNode == currentKeyNode ) NoItem = Standard_False;
- else {
- previousItemNode = currentItemNode;
- currentItemNode = currentItemNode->NextItem();
- }
- }
- if ( NoItem ) Standard_NoSuchObject::Raise();
- else {
- if ( previousKeyNode.IsNull() )
- myArrayKey->SetValue(ResHashKey,currentKeyNode->NextKey());
- else
- previousKeyNode->SetNextKey(currentKeyNode->NextKey());
-
- if ( previousItemNode.IsNull() )
- myArrayItem->SetValue(ResHashItem,currentItemNode->NextItem());
- else
- previousItemNode->SetNextItem(currentItemNode->NextItem());
-
- myNumber--;
- currentKeyNode->SetNextKey(nullNode);
- currentKeyNode->SetNextItem(nullNode);
- currentKeyNode.Delete();
- }
- }
-
-}
-
-//=======================================================================
-// Function : UnbindItem
-//=======================================================================
-
-void PCollection_HDoubleMap::UnbindItem ( const Item &anItem )
-{
- Standard_Integer ResHashKey,ResHashItem;
- Handle(PCollection_DoubleMapNode)
- currentKeyNode,previousKeyNode,previousItemNode,currentItemNode,nullNode;
- Standard_Boolean NoKey = Standard_True;
- Standard_Boolean NoItem = Standard_True;
-
- ResHashItem = myItemHash.HashCode(anItem,myArrayItem->Length());
- currentItemNode = myArrayItem->Value(ResHashItem);
- while ( NoItem && !currentItemNode.IsNull() ) {
- if ( myItemHash.Compare(currentItemNode->GetItem(),anItem) )
- NoItem = Standard_False;
- else {
- previousItemNode = currentItemNode;
- currentItemNode = currentItemNode->NextItem();
- }
- }
-
- if ( NoItem ) Standard_NoSuchObject::Raise();
- else {
- ResHashKey =
- myKeyHash.HashCode(currentItemNode->GetKey(),myArrayKey->Length());
- currentKeyNode = myArrayKey->Value(ResHashKey);
- while ( NoKey && !currentKeyNode.IsNull() ) {
- if ( currentKeyNode == currentItemNode ) NoKey = Standard_False;
- else {
- previousKeyNode = currentKeyNode;
- currentKeyNode = currentKeyNode->NextKey();
- }
- }
- if ( NoKey ) Standard_NoSuchObject::Raise();
- else {
- if ( previousItemNode.IsNull() )
- myArrayItem->SetValue(ResHashItem,currentItemNode->NextItem());
- else
- previousItemNode->SetNextItem(currentItemNode->NextItem());
-
- if ( previousKeyNode.IsNull() )
- myArrayKey->SetValue(ResHashKey,currentKeyNode->NextKey());
- else
- previousKeyNode->SetNextKey(currentKeyNode->NextKey());
-
- myNumber--;
- currentItemNode->SetNextItem(nullNode);
- currentItemNode->SetNextKey(nullNode);
- currentItemNode.Delete();
- }
- }
-
-}
-
-//=======================================================================
-// Function : Clear
-//=======================================================================
-
-void PCollection_HDoubleMap::Clear ()
-{
- Handle(PCollection_DoubleMapNode) nullNode,theNode,delNode;
- Standard_Integer I;
-
- myNumber = 0;
-
- for ( I = 1 ; I <= myArrayItem->Length() ; I++ ) {
- theNode = myArrayItem->Value(I);
- myArrayKey->SetValue(I,nullNode);
- myArrayItem->SetValue(I,nullNode);
- while ( !theNode.IsNull() ) {
- delNode = theNode;
- theNode = theNode->NextItem();
- delNode->SetNextKey(nullNode);
- delNode->SetNextItem(nullNode);
- delNode.Delete();
- }
- }
-}
-
-//=======================================================================
-// Function : IsBoundByKey
-//=======================================================================
-
-Standard_Boolean PCollection_HDoubleMap::IsBoundByKey ( const Key &aKey ) const
-{
- Standard_Integer ResHashKey;
- Handle(PCollection_DoubleMapNode) theKeyNode;
-
- ResHashKey = myKeyHash.HashCode(aKey,myArrayKey->Length());
- theKeyNode = myArrayKey->Value(ResHashKey);
- while ( ! theKeyNode.IsNull() ) {
- if ( myKeyHash.Compare(theKeyNode->GetKey(),aKey) )
- return Standard_True;
- else theKeyNode = theKeyNode->NextKey();
- }
- return Standard_False;
-}
-
-//=======================================================================
-// Function : IsBoundByItem
-//=======================================================================
-
-Standard_Boolean PCollection_HDoubleMap::IsBoundByItem(const Item &anItem) const
-{
- Standard_Integer ResHashItem;
- Handle(PCollection_DoubleMapNode) theItemNode;
-
- ResHashItem = myItemHash.HashCode(anItem,myArrayItem->Length());
- theItemNode = myArrayItem->Value(ResHashItem);
- while ( ! theItemNode.IsNull() ) {
- if ( myItemHash.Compare(theItemNode->GetItem(),anItem) )
- return Standard_True;
- else theItemNode = theItemNode->NextItem();
- }
- return Standard_False;
-}
-
-//=======================================================================
-// Function : IsEmpty
-//=======================================================================
-
-Standard_Boolean PCollection_HDoubleMap::IsEmpty () const
-{
- Standard_Boolean Empty = Standard_True;
-
- for ( Standard_Integer I = 1 ; I <= myArrayKey->Length() && Empty ; I++ )
- if ( ! myArrayKey->Value(I).IsNull() ) Empty = Standard_False;
-
- return Empty;
-}
-
-//=======================================================================
-// Function : GetArrayKey
-//=======================================================================
-
-Handle(PCollection_ArrayDoubleMap) PCollection_HDoubleMap::
- GetArrayKey () const
-{
- return myArrayKey;
-}
-
+++ /dev/null
--- Copyright (c) 1992-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
----Version:
-
--- Version Date Purpose
--- 18/12/92 Creation
-
-generic class HIndexedDataMap from PCollection ( Key as Storable;
- Item as Storable;
- KeyHash as Hash(Key)
- )
-
----Purpose: The HIndexedDataMap is a hashed set of objects of Type Key, called
--- Keys. Keys can be inserted in the Map but not removed. The Map
--- keeps the number of keys called NbKeys. Each time a Key is
--- inserted the Map tests if this Key is already in the Map. If
--- it is, nothing is done. If not, NbKeys is incremented and it's
--- value is bound to the Key and called the Index.
---
--- The Map provides methods to inquire the Index of a Key and to
--- retrieve a Key from an Index in the range 1..NbKeys.
---
--- Another Datum of the type Item can be stored with the Key. The
--- Item can be retrieved from the Key and from the Index of the
--- Key. The Item stored with a Key can be modified.
-
-inherits Persistent from Standard
-
-raises
-
- OutOfRange from Standard
-
-
-class IndexedDataMapNode from PCollection inherits PManaged from PMMgt
-
----Purpose: This class is used in the implementation of the IndexedDataMap class.
--- It stores three elements : a Key, an Item and an Integer Index.
--- It also stores two references to IndexedDataMapNode objects,
--- IndexedDataMapNode are used to make lists in the Hashed IndexedDataMap.
-
-is
-
- Create(aKey : Key; Index : Integer; anItem : Item; NextKey,NextIndex
- : IndexedDataMapNode )returns mutable IndexedDataMapNode;
- ---Purpose: Creates a IndexedDataMapNode;
-
- Set(me : mutable; aKey : Key; Index : Integer; anItem : Item;
- NextK,NextI : IndexedDataMapNode) is static;
- ---Level: Internal
- ---Purpose: Sets the values of <me>.
-
- SetItem ( me : mutable; anItem : Item) is static;
- ---Level: Internal
- ---Purpose: Sets the item.
-
- SetNextKey ( me : mutable ; aNode : IndexedDataMapNode ) is static;
- ---Level: Internal
- ---Purpose: Sets the next node of Key hashed list.
-
- SetNextIndex ( me : mutable ; aNode : IndexedDataMapNode ) is static;
- ---Level: Internal
- ---Purpose: Sets the next node of Key hashed list.
-
- GetKey ( me ) returns any Key is static;
- ---Level: Internal
- ---Purpose: Returns the key.
-
- Index ( me ) returns Integer is static;
- ---Level: Internal
- ---Purpose: Returns the index.
-
- GetItem ( me ) returns any Item is static;
- ---Level: Internal
- ---Purpose: Returns the item.
-
- IndexAndItem(me; Index : out Integer; theItem : out any Item) is static;
- ---Level: Internal
- ---Purpose: Returns index and item.
-
- KeyAndItem(me; theKey : out any Key; theItem : out any Item) is static;
- ---Level: Internal
- ---Purpose: Returns key and item.
-
- NextKey ( me ) returns any IndexedDataMapNode is static;
- ---Level: Internal
- ---Purpose: Returns the next node of Key hashed list.
-
- NextIndex ( me ) returns any IndexedDataMapNode is static;
- ---Level: Internal
- ---Purpose: Returns the next node of Index hashed list.
-
-fields
-
- myKey : Key;
- myIndex : Integer;
- myItem : Item;
- myNextKey : IndexedDataMapNode;
- myNextIndex : IndexedDataMapNode;
-
-end IndexedDataMapNode;
-
-class ArrayIndexedDataMap instantiates
- HArray1 from PCollection (IndexedDataMapNode);
-
-is
-
- Create ( NbBuckets : Integer; fhKey : KeyHash ) returns mutable HIndexedDataMap;
- ---Purpose: Creates an empty HIndexedDataMap, NbBuckets is an estimation of the
- -- number of Keys that will be stored in the Map. It is not
- -- limited, but a too small number may reduce performance.
-
- NbBuckets ( me ) returns Integer;
- ---Level: Public
- ---Purpose: Returns the number of entries in the indexed map.
-
- NbKeys(me) returns Integer;
- ---Level: Public
- ---Purpose: Returns the number of Keys stored in the Map.
-
- Bind(me : mutable ; aKey : Key; anItem : Item; OverWrite : Boolean )
- returns Integer;
- ---Level: Public
- ---Purpose: Adds a new Key and returns the Index.
- -- If the Key is new in the Map the Item is bound with the Key.
- -- If the Key is already present the Item replaces the existing
- -- Item if Overwrite is True.
-
- FindIndex ( me ; aKey : Key ) returns Integer;
- ---Level: Public
- ---Purpose: Returns the Index of the Key in the Map. If the Key is not
- -- stored the returned Index is 0.
-
- FindKey ( me ; Index : Integer ) returns any Key
- ---Level: Public
- ---Purpose: Returns the Key stored with the Index, Index must be in the
- -- range 1..NbKeys.
- raises OutOfRange from Standard;
-
- FindItemFromKey ( me ; aKey : Key ) returns any Item
- ---Level: Public
- ---Purpose: Returns the Item stored with the Key <aKey>.
- ---Trigger: An exception is raised if the key <aKey> is not stored in the Map.
- raises OutOfRange from Standard;
-
- FindItemFromIndex ( me ; Index : Integer ) returns any Item
- ---Level: Public
- ---Purpose: Returns the Item stored with the index <Index>. This is
- -- similar to but faster than K = GetKey(Index); GetItem(K,I)
- ---Trigger: An exception is raised if <Index> is not in the range 1..NbKeys.
- raises OutOfRange from Standard;
-
- FindIndexAndItem(me; aKey : Key; Index : out Integer; theItem : out Item)
- ---Level: Public
- ---Purpose: Returns the index and the item stored with the Key <aKey>.
- ---Trigger: An exception is raised if the key <aKey> is not stored in the Map.
- raises OutOfRange from Standard;
-
- FindKeyAndItem(me; Index : Integer; theKey : out Key; theItem : out Item)
- ---Level: Public
- ---Purpose: Returns the key and the item stored with the index <Index>.
- ---Trigger: An exception is raised if <Index> is not in the range 1..NbKeys.
- raises OutOfRange from Standard;
-
- SetItemToKey(me : mutable; aKey : Key; anItem : Item)
- ---Level: Public
- ---Purpose: Modifies the item stored with the key <aKey>.
- ---Trigger: An exception is raised if the key <aKey> is not stored in the Map.
- raises OutOfRange from Standard;
-
- SetItemToIndex(me : mutable; Index : Integer; anItem : Item)
- ---Level: Public
- ---Purpose: Modifies the item stored with the index <Index>.
- ---Trigger: An exception is raised if <Index> is not in the range 1..NbKeys.
- raises OutOfRange from Standard;
-
- Clear ( me : mutable );
- ---Level: Public
- ---Purpose: Clears the Map content.
-
- IsBound ( me ; aKey : Key) returns Boolean;
- ---Level: Public
- ---Purpose: Returns True if an element is bound by <aKey>.
-
- LocateKey(me; aKey : Key) returns any IndexedDataMapNode
- ---Level: Internal
- ---Purpose: Returns the node containing <aKey>.
- is static private;
-
- LocateIndex(me; Index : Integer) returns any IndexedDataMapNode
- ---Level: Internal
- ---Purpose: Returns the node containing <Index>.
- is static private;
-
-fields
-
- myNumber : Integer;
- myKeyHash : KeyHash;
- myArrayKey : ArrayIndexedDataMap;
- myArrayIndices : ArrayIndexedDataMap;
-
-end HIndexedDataMap;
-
-
-
-
+++ /dev/null
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-Version:
-
-// Version Date Purpose
-// 14/12/92 Creation
-
-//-Language C++2.0
-
-//-Declarations
-#include <Standard_OutOfRange.hxx>
-
-//=======================================================================
-// Function : PCollection_HIndexedDataMap
-// Purpose :
-//=======================================================================
-
-PCollection_HIndexedDataMap::PCollection_HIndexedDataMap
- (const Standard_Integer NbBuckets, const KeyHash &fhKey)
-{
- myNumber = 0;
- myArrayKey = new PCollection_ArrayIndexedDataMap(1,NbBuckets);
- myArrayIndices = new PCollection_ArrayIndexedDataMap(0,NbBuckets-1);
- myKeyHash = fhKey;
-}
-
-//=======================================================================
-// Function : NbBuckets
-// Purpose :
-//=======================================================================
-
-Standard_Integer PCollection_HIndexedDataMap::NbBuckets() const
-{
- return myArrayKey->Length();
-}
-
-//=======================================================================
-// Function : NbKeys
-// Purpose :
-//=======================================================================
-
-Standard_Integer PCollection_HIndexedDataMap::NbKeys() const
-{
- return myNumber;
-}
-
-//=======================================================================
-// Function : Bind
-// Purpose :
-//=======================================================================
-
-Standard_Integer PCollection_HIndexedDataMap::Bind(const Key& aKey,
- const Item& anItem,
- const Standard_Boolean OverWrite)
-{
- Standard_Integer theSize = myArrayKey->Length();
-
- Standard_Integer hcode = myKeyHash.HashCode(aKey,theSize);
- Handle(PCollection_IndexedDataMapNode) theNode = myArrayKey->Value(hcode);
- while (! theNode.IsNull()) {
- if ( myKeyHash.Compare(theNode->GetKey(),aKey)) {
- // if the Key already exists, update the item and return the index
- if (OverWrite) {
- theNode->SetItem(anItem);
- }
- return theNode->Index();
- }
- else {
- theNode = theNode->NextKey();
- }
- }
-
- // the Key was not Found, create a new Elem
- myNumber++;
- Standard_Integer hint = myNumber % theSize;
- Handle(PCollection_IndexedDataMapNode) theNewNode =
- new PCollection_IndexedDataMapNode(aKey, myNumber, anItem,
- myArrayKey->Value(hcode),
- myArrayIndices->Value(hint));
- myArrayKey->SetValue(hcode,theNewNode);
- myArrayIndices->SetValue(hint,theNewNode);
-
- return myNumber;
-}
-
-//=======================================================================
-// Function : FindIndex
-// Purpose : returns the Index of the Key, 0 if the Key is not stored
-//=======================================================================
-
-Standard_Integer PCollection_HIndexedDataMap::FindIndex(const Key& aKey) const
-{
- Standard_Integer ResHash;
- Handle(PCollection_IndexedDataMapNode) theKeyNode;
-
- // search the Key in the map
- ResHash = myKeyHash.HashCode(aKey,myArrayKey->Length());
- theKeyNode = myArrayKey->Value(ResHash);
- while (! theKeyNode.IsNull()) {
- if ( myKeyHash.Compare(theKeyNode->GetKey(),aKey))
- // if the Key already exists stop the search
- return theKeyNode->Index();
-
- else
- // go to next element
- theKeyNode = theKeyNode->NextKey();
- }
- // not found, return 0
- return 0;
-}
-
-//=======================================================================
-// Function : FindKey
-// Purpose :
-//=======================================================================
-
-Key PCollection_HIndexedDataMap::FindKey(const Standard_Integer Index) const
-{
- // search the index
- Handle(PCollection_IndexedDataMapNode) theNode = LocateIndex(Index);
- // get the Key
- return theNode->GetKey();
-}
-
-//=======================================================================
-// Function : FindItemFromKey
-// Purpose : return the Item stored with the Key
-//=======================================================================
-
-Item PCollection_HIndexedDataMap::FindItemFromKey(const Key& aKey) const
-{
- // find the Key
- Handle(PCollection_IndexedDataMapNode) theNode = LocateKey(aKey);
-
- // get the Item
- return theNode->GetItem();
-}
-
-//=======================================================================
-// Function : FindItemFromIndex
-// Purpose : Find an Item from the index
-//=======================================================================
-
-Item PCollection_HIndexedDataMap::FindItemFromIndex
- (const Standard_Integer Index) const
-{
- // search the index
- Handle(PCollection_IndexedDataMapNode) theNode = LocateIndex(Index);
- // get the Item
- return theNode->GetItem();
-}
-
-//=======================================================================
-// Function : FindIndexAndItem
-// Purpose : find the index and the Item for a key
-//=======================================================================
-
-void PCollection_HIndexedDataMap::FindIndexAndItem(const Key& aKey,
- Standard_Integer& Index,
- Item& theItem) const
-{
- // find the Key
- Handle(PCollection_IndexedDataMapNode) theNode = LocateKey(aKey);
-
- // get Index and Item
- theNode->IndexAndItem(Index,theItem);
-}
-
-//=======================================================================
-// Function : FindKeyAndItem
-// Purpose : find the Key and the Item for an Index
-//=======================================================================
-
-void PCollection_HIndexedDataMap::FindKeyAndItem(const Standard_Integer Index,
- Key& theKey,
- Item& theItem) const
-{
- // find the index
- Handle(PCollection_IndexedDataMapNode) TheNode = LocateIndex(Index);
-
- // get Key and Item
- TheNode->KeyAndItem(theKey,theItem);
-}
-
-//=======================================================================
-// Function : SetItemToKey
-// Purpose : change the Item stored with a Key
-//=======================================================================
-
-void PCollection_HIndexedDataMap::SetItemToKey(const Key& aKey,
- const Item& anItem)
-{
- // find the Key
- Handle(PCollection_IndexedDataMapNode) TheNode = LocateKey(aKey);
-
- // set the Item
- TheNode->SetItem(anItem);
-}
-
-//=======================================================================
-// Function : SetItemToIndex
-// Purpose : change the Item stored with an Index
-//=======================================================================
-
-void PCollection_HIndexedDataMap::SetItemToIndex(const Standard_Integer Index,
- const Item& anItem)
-{
- // find the Key
- Handle(PCollection_IndexedDataMapNode) TheNode = LocateIndex(Index);
-
- // set the Item
- TheNode->SetItem(anItem);
-}
-
-//=======================================================================
-// Function : Clear
-// Purpose :
-//=======================================================================
-
-void PCollection_HIndexedDataMap::Clear()
-{
- Handle(PCollection_IndexedDataMapNode) nullNode,theNode,delNode;
- Standard_Integer I;
-
- myNumber = 0;
-
- for ( I = 0 ; I < myArrayKey->Length() ; I++ ) {
- theNode = myArrayKey->Value(I+1);
- myArrayKey->SetValue(I+1,nullNode);
- myArrayIndices->SetValue(I,nullNode);
- while ( !theNode.IsNull() ) {
- delNode = theNode;
- theNode = theNode->NextKey();
- delNode->SetNextKey(nullNode);
- delNode->SetNextIndex(nullNode);
- delNode.Delete();
- }
- }
-}
-
-//=======================================================================
-// Function : IsBound
-// Purpose : Standard_True if the Map contains the Key
-//=======================================================================
-
-Standard_Boolean PCollection_HIndexedDataMap::IsBound(const Key& aKey) const
-{
- return (FindIndex(aKey) != 0);
-}
-
-//=======================================================================
-// Function : LocateKey
-// Purpose : find the Map Element containing a Shape, Null if none
-//=======================================================================
-
-Handle(PCollection_IndexedDataMapNode)
- PCollection_HIndexedDataMap::LocateKey(const Key& aKey) const
-{
- Standard_Integer ResHash = myKeyHash.HashCode(aKey,myArrayKey->Length());
- // search the Key in the map
- Handle(PCollection_IndexedDataMapNode) theNode = myArrayKey->Value(ResHash);
- while (! theNode.IsNull()) {
- if ( myKeyHash.Compare(aKey,theNode->GetKey()))
- // if the Key already exists stop the search
- return theNode;
- else
- // go to next element
- theNode = theNode->NextKey();
- }
-
- // raises Standard_OutOfRange
- Standard_OutOfRange::Raise("HIndexedDataMap : Key not in Map");
- return theNode;
-}
-
-//=======================================================================
-// Function : LocateIndex
-// Purpose : find the Map Element containing an Index, check bounds
-//=======================================================================
-
-Handle(PCollection_IndexedDataMapNode) PCollection_HIndexedDataMap::LocateIndex
- (const Standard_Integer Index) const
-{
- // check bounds
- if ((Index < 1)||(Index > myNumber))
- Standard_OutOfRange::Raise("HIndexedDataMap : Bad Index");
- // search the Index in the map
- Handle(PCollection_IndexedDataMapNode) theNode =
- myArrayIndices->Value(Index % myArrayIndices->Length());
- // the Index SHOULD be in the list, so no NULL checking
- while (theNode->Index() != Index)
- theNode = theNode->NextIndex();
-
- // return the element
- return theNode;
-}
-
-
-
+++ /dev/null
--- Created on: 1993-02-10
--- Created by: Mireille MERCIEN
--- Copyright (c) 1993-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-generic class HQueue from PCollection (Item as Storable)
-inherits Persistent
-
- ---Purpose: A queue is a sequence of items in which items
- -- are added at one end (called the back of the
- -- queue) and removed at the other end (called
- -- the front)
- -- The Queue is empty if there are no elements.
-
-raises NoSuchObject from Standard
-
-
- class QueueNode instantiates HSingleList from PCollection(Item);
-
- class QueueIterator from PCollection
-
- ---Purpose: Iterator of the class Queue.
-
- raises NoMoreObject from Standard,
- NoSuchObject from Standard
- is
-
- Create(Q : HQueue from PCollection)
- returns QueueIterator from PCollection;
- ---Purpose: Creates an iterator on the queue Q.
- -- Sets the iterator at the beginning of the Queue Q.
-
- More(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if there are other items.
-
- Next(me: in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next item.
-
- Value(me) returns any Item raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Returns the item value corresponding to
- -- the current position of the iterator.
-
- fields
- TheIterator : QueueNode;
- end;
-
-
-is
- Create returns mutable HQueue from PCollection;
- ---Purpose: Creates an empty queue.
-
- Length(me) returns Integer from Standard;
- ---Level: Public
- ---Purpose: Returns the number of items in the queue.
- ---Example: before
- -- me = (A B C)
- -- returns 3
-
- IsEmpty(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if the queue contains no element.
-
- Front(me) returns any Item raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Returns the item at the front of the queue.
- -- Raises an exception if the queue is empty.
- ---Example: before
- -- me = (A B C)
- -- after
- -- me = (A B C)
- -- returns
- -- A
-
- FFront(me) returns QueueNode;
- ---Level: Public
- ---Purpose: Returns the field TheFront(the front of the queue).
-
- FBack(me) returns QueueNode;
- ---Level: Public
- ---Purpose: Returns the field Theback(the back of the queue).
-
- Clear(me : mutable);
- ---Level: Public
- ---Purpose: Removes all the elements from the queue
- ---Example: before
- -- me = (A B C)
- -- after
- -- me = ()
-
- Push(me : mutable; T : Item);
- ---Level: Public
- ---Purpose: Inserts an item at the back of the queue.
- ---Example: before
- -- me = (A B) , T = C
- -- after
- -- me = (A B C)
-
- Pop(me : mutable) raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Removes an item from the front of the queue.
- -- Raises an exception if the queue is empty
- ---Example: before
- -- me = (A B C)
- -- after
- -- me = (B C)
- -- returns
- -- A
-
- ChangeFront(me:mutable ; T : Item) raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Replaces the front element of the queue with T.
- -- Raises an exception if the queue is empty.
- ---Example: before
- -- me = (A B C) , T = D
- -- after
- -- me = (D B C)
-
- ShallowCopy(me)
- returns mutable like me
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
- Destroy(me : mutable);
- ---C++: alias ~
-
-fields
- TheFront : QueueNode;
- TheBack : QueueNode;
- TheLength : Integer from Standard;
-end;
-
-
-
-
-
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// ------------
-// constructor
-// -----------
-
-PCollection_HQueue::PCollection_HQueue()
-{
- TheLength = 0;
- TheFront = new PCollection_QueueNode;
- TheBack = TheFront;
-}
-
-// -----------------------------
-// IsEmpty : is the queue empty ?
-// -----------------------------
-Standard_Boolean PCollection_HQueue::IsEmpty() const {
- return TheLength == 0;
-}
-
-// --------------------------------------
-// Front : item at the front of the Queue
-// --------------------------------------
-Item PCollection_HQueue::Front() const
-{
- if (TheFront->IsEmpty()) Standard_NoSuchObject::Raise();
- return TheFront->Value();
-}
-
-// --------------------------------------
-// Clear : remove all items in the Queue
-// --------------------------------------
-void PCollection_HQueue::Clear()
-{
- Handle(PCollection_QueueNode) temp;
- while (TheLength != 0) {
- temp = TheFront;
- TheFront = TheFront->Tail();
- if (TheLength == 1) TheBack = TheFront;
- temp.Delete();
- --TheLength;
- }
-}
-
-// ------------------------------------
-// Push : insert an item at the back
-// ------------------------------------
-void PCollection_HQueue::Push(const Item& T)
-{
- Handle(PCollection_QueueNode) L;
- L = new PCollection_QueueNode;
- if (TheLength == 0)
- {
- L->ChangeForwardPointer(TheFront);
- TheBack = L;
- TheFront = TheBack;
- }
- else
- {
- L->ChangeForwardPointer(TheBack->Tail());
- TheBack->ChangeForwardPointer(L);
- TheBack = L;
- };
- TheBack->SetValue(T);
- TheLength = TheLength + 1;
- }
-
-// ------------------------------------
-// Pop : remove an item from the front
-// ------------------------------------
-void PCollection_HQueue::Pop()
-{
- if (TheFront->IsEmpty()) Standard_NoSuchObject::Raise();
- Handle(PCollection_QueueNode) temp = TheFront;
- TheFront = TheFront->Tail();
- temp.Delete();
- TheLength = TheLength - 1;
- if (TheLength == 0) TheBack = TheFront;
-}
-
-// ------------------------------------
-// ChangeFront : replace the front by T
-// ------------------------------------
-void PCollection_HQueue::ChangeFront(const Item& T)
-{
- if (TheFront->IsEmpty()) Standard_NoSuchObject::Raise();
- TheFront->SetValue(T);
-}
-
-// ------------------------------------
-// ShallowCopy
-// ------------------------------------
-Handle(Standard_Persistent) PCollection_HQueue::ShallowCopy() const
-{
- Handle(PCollection_HQueue) TheCopy;
- Handle(PCollection_QueueNode) TheList;
-
- TheCopy = new PCollection_HQueue;
- TheList = TheFront;
-
-
- for (Standard_Integer I = 1; I <= TheLength; I++){
- TheCopy->Push(TheList->Value());
- TheList = TheList->Tail();
- }
-
- return TheCopy;
-
-}
-
-// ------------------------------------
-// ShallowDump
-// ------------------------------------
-void PCollection_HQueue::ShallowDump(Standard_OStream& S) const
-{
- S << "begin class Queue "<< endl;
- S << "Length of Queue : "<< TheLength << endl;
- TheFront->ShallowDump(cout);
- S << "end of class Queue." << endl;
-}
-
-
-
-// -----------------------------
-// Length : numbers of items
-// -----------------------------
-Standard_Integer PCollection_HQueue::Length() const {
- return TheLength;
-}
-
-// -----------------------------
-// FFront : front of the queue
-// -----------------------------
-Handle(PCollection_QueueNode) PCollection_HQueue::FFront() const {
- return TheFront;
-}
-
-// -----------------------------
-// FBack : the back of the queue
-// -----------------------------
-Handle(PCollection_QueueNode) PCollection_HQueue::FBack() const {
- return TheBack;
-}
-
-void PCollection_HQueue::Destroy()
-{
-#ifdef CSFDB
- Clear();
-#endif
-}
+++ /dev/null
--- Created on: 1991-09-02
--- Created by: Mireille MERCIEN
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-generic class HSet from PCollection (Item as Storable)
-inherits Persistent
-
- ---Purpose: A set is an unordered collection of items.
- -- We can not have duplicated items in a given set.
-
-raises NoSuchObject from Standard
-
-
- class SetNode instantiates HSingleList from PCollection(Item);
-
- class SetIterator from PCollection
- ---Purpose: Iterator of the Set class.
-
- raises NoMoreObject from Standard,
- NoSuchObject from Standard
- is
-
- Create(S : HSet from PCollection)
- returns SetIterator from PCollection;
- ---Purpose: Creates an iterator on the set S.
- -- Set the iterator at the beginning of the set S.
-
- More(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if there are other items.
-
- Next(me: in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next item.
-
- Value(me) returns any Item raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Returns the item value corresponding to
- -- the current position of the iterator.
-
- fields
- TheIterator : SetNode;
- end;
-
-
-is
-
- Create returns mutable HSet from PCollection;
- ---Purpose: Creation of an empty set.
-
- Extent(me) returns Integer from Standard;
- ---Level: Public
- ---Purpose: Number of items in the set me
- ---Example: if S is the set {a,b,c,d,e}
- -- Extent returns 5
-
- Last(me) returns SetNode;
- ---Level: Public
- ---Purpose: Returns the field TheLast .
- -- (the last item enterred in the set)
-
- IsEmpty(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if the set me is empty.
-
- Clear(me : mutable);
- ---Level: Public
- ---Purpose: Removes all the items of the set me.
- ---Example: before
- -- me = {a,b,c,d}
- -- after
- -- me = {}
-
- Add(me : mutable; T : Item) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Adds an item T in the set me if it does not already exist.
- -- Returns False if the item T already exists, True otherwise.
- ---Example: before
- -- me = {a,b,c,d}, T = y
- -- after
- -- me = {a,b,c,d,y}
-
- Remove(me : mutable; T : Item) raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Removes the item T in the set me
- -- Raises an exception if the item is not in the set.
- ---Example: before
- -- me = {a,b,c,d}, T = a
- -- after
- -- me = {b,c,d}
- -- returns ()
-
- Union(me; B : HSet from PCollection) returns mutable HSet from PCollection;
- ---Level: Public
- ---Purpose: Creation of a set containing all the items
- -- of the set me and all the items of the set B which
- -- are not in me.
- ---Example: before
- -- me = {a,b,c}, B = {d,a,f}
- -- after
- -- me = {a,b,c}, B = {d,a,f}
- -- returns
- -- {a,b,c,d,f}
-
- Intersection(me; B : HSet from PCollection) returns mutable HSet from PCollection;
- ---Level: Public
- ---Purpose: Creation of a set containing all the
- -- items which are both in the set <me> and in the set B.
- ---Example: before
- -- me = {a,b,c}, B = {d,a,f}
- -- after
- -- me = {a,b,c}, B = {d,a,f}
- -- returns
- -- {a}
-
- Difference(me; B: HSet from PCollection) returns mutable HSet from PCollection;
- ---Level: Public
- ---Purpose: Creation of a set containing the items
- -- which are in the set me and not in the set B.
- ---Example: before
- -- me = {a,b,c}, B = {d,a,f}
- -- after
- -- me = {a,b,c}, B = {d,a,f}
- -- returns
- -- {b,c}
-
- Contains(me; T : Item) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if an item is in the set me.
-
- IsASubset(me; S : HSet from PCollection) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if a set is contained in the set me.
- -- The two sets can be identical.
-
- IsAProperSubset(me; S : HSet from PCollection) returns Boolean from
- Standard;
- ---Level: Public
- ---Purpose: Returns True if a set is contained in the set me.
- -- The two sets cannot be identical.
-
- ShallowCopy(me)
- returns mutable like me
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
-
-fields
- TheExtent : Integer from Standard;
- TheLast : SetNode;
-end;
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NotImplemented.hxx>
-
-// ------------
-// constructor
-// -----------
-
-PCollection_HSet::PCollection_HSet()
-{
- TheExtent = 0;
- TheLast = new PCollection_SetNode;
-}
-
-// -----------------------------
-// IsEmpty : is the Set empty ?
-// -----------------------------
-Standard_Boolean PCollection_HSet::IsEmpty() const
-{
- return TheLast->IsEmpty();
-}
-
-// ----------------
-// Contains an item
-// ----------------
-Standard_Boolean PCollection_HSet::Contains(const Item& T) const
-{
- Standard_Boolean Ilela;
- Handle(PCollection_SetNode) TheCurrent;
- TheCurrent = TheLast;
- Ilela = Standard_False;
- while (!Ilela && !TheCurrent->IsEmpty())
- {
- if (TheCurrent->Value() == T)
- Ilela = Standard_True;
- else
- TheCurrent = TheCurrent->Tail();
- };
- return Ilela;
-}
-
-// ---------------------------------
-// The Set S IsASubset of the set me
-// ---------------------------------
-Standard_Boolean PCollection_HSet::IsASubset(const Handle(PCollection_HSet)& S) const
-{
- Standard_Boolean Ilela,Ilsonla;
- Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
- TheCurrent1 = TheLast;
- TheCurrent2 = S->Last();
- Ilela = Standard_False;
- Ilsonla = Standard_True;
- while (Ilsonla && !TheCurrent2->IsEmpty())
- {
- while (!Ilela && !TheCurrent1->IsEmpty())
- {
- if (TheCurrent1->Value() == TheCurrent2->Value())
- Ilela = Standard_True;
- else
- TheCurrent1 = TheCurrent1->Tail();
- };
- if (!Ilela)
- Ilsonla = Standard_False;
- else
- {
- TheCurrent2 = TheCurrent2->Tail();
- TheCurrent1 = TheLast;
- };
- };
- return Ilsonla;
-
-}
-
-
-// ----------------------------------------
-// The Set S IsAProperSubset of the set me
-// ----------------------------------------
-Standard_Boolean PCollection_HSet::IsAProperSubset(const Handle(PCollection_HSet)& S) const
-{
- Standard_Boolean Ilela,Ilsonla;
- Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
- TheCurrent1 = TheLast;
- TheCurrent2 = S->Last();
- Ilela = Standard_False;
- Ilsonla = Standard_True;
- if (S->Extent() >= TheExtent) Ilsonla = Standard_False;
- while (Ilsonla && !TheCurrent2->IsEmpty())
- {
- while (!Ilela && !TheCurrent1->IsEmpty())
- {
- if (TheCurrent1->Value() == TheCurrent2->Value())
- Ilela = Standard_True;
- else
- TheCurrent1 = TheCurrent1->Tail();
- };
- if (!Ilela)
- Ilsonla = Standard_False;
- else
- {
- TheCurrent2 = TheCurrent2->Tail();
- TheCurrent1 = TheLast;
- };
- };
- return Ilsonla;
-
-}
-
-// ------------------------------------
-// Clear : remove all items
-// ------------------------------------
-void PCollection_HSet::Clear()
-{
- Handle(PCollection_SetNode) temp;
- while (TheExtent != 0) {
- temp = TheLast;
- TheLast = TheLast->Tail();
-#ifndef CSFDB
- temp.Delete();
-#endif
- --TheExtent;
- }
-}
-
-// -------------------------------------------
-// Add : insert an item
-// returns Standard_True if the item has been inserted,
-// Standard_False otherwise
-// -------------------------------------------
-Standard_Boolean PCollection_HSet::Add(const Item& T)
-{
- Standard_Boolean Dejala;
- Handle(PCollection_SetNode) TheCurrent;
- TheCurrent = TheLast;
- Dejala = Standard_False;
- while (!Dejala && !TheCurrent->IsEmpty())
- { if (TheCurrent->Value() == T) Dejala = Standard_True;
- TheCurrent = TheCurrent->Tail();
- };
- if (!Dejala)
- {
- TheLast = TheLast->Construct(T);
- TheExtent = TheExtent + 1;
- };
- return !Dejala;
-}
-
-// ------------------------
-// Remove : remove an item
-// from the set me.
-// Raises Standard_NoSuchObject
-// ------------------------
-void PCollection_HSet::Remove(const Item& T)
-{
- Standard_Boolean Nepala;
- Handle(PCollection_SetNode) TheCurrent,ThePrevious;
- TheCurrent = TheLast;
- ThePrevious = TheLast;
- Nepala = Standard_True;
- while (Nepala && !TheCurrent->IsEmpty()) {
- if (TheCurrent->Value() == T)
- Nepala = Standard_False;
- else {
- ThePrevious = TheCurrent;
- TheCurrent = TheCurrent->Tail();
- }
- }
- if (Nepala)
- Standard_NoSuchObject::Raise();
- else {
- if (TheCurrent == ThePrevious)
- TheLast = TheLast->Tail();
- else
- ThePrevious->ChangeForwardPointer(TheCurrent->Tail());
- TheExtent = TheExtent - 1;
-#ifndef CSFDB
- TheCurrent.Delete();
-#endif
- }
-}
-
-// ------------------------------------
-// Union with the set S
-// returns a set containing all the
-// items of the set me and all the items
-// of the set B which are not in me
-// ------------------------------------
-Handle(PCollection_HSet) PCollection_HSet::Union(const Handle(PCollection_HSet)& S)
-const
-{
- Standard_Boolean Insere;
- Handle(PCollection_SetNode) TheCurrent;
- Handle(PCollection_HSet) Lunion;
- Lunion = new PCollection_HSet;
-// copier this dans Lunion
- TheCurrent = TheLast;
- while (!TheCurrent->IsEmpty())
- {
- Insere = Lunion->Add(TheCurrent->Value());
- TheCurrent = TheCurrent->Tail();
- };
-// Inserer dans Lunion les items de S
- TheCurrent = S->Last();
- while (!TheCurrent->IsEmpty())
- {
- Insere = Lunion->Add(TheCurrent->Value());
- TheCurrent = TheCurrent->Tail();
- };
- return Lunion;
-}
-
-// -----------------------------
-// Intersection with the set S
-// -----------------------------
-Handle(PCollection_HSet) PCollection_HSet::
- Intersection(const Handle(PCollection_HSet)& S)
-const
-{
- Item Litem;
- Standard_Boolean Insere;
- Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
- Handle(PCollection_HSet) Linter;
- Linter = new PCollection_HSet;
- TheCurrent1 = TheLast;
- while (!TheCurrent1->IsEmpty())
- {
- Litem = TheCurrent1->Value();
- TheCurrent2 = S->Last();
- while (!TheCurrent2->IsEmpty())
- {
- if (TheCurrent2->Value() == Litem)
- Insere = Linter->Add(Litem);
- TheCurrent2 = TheCurrent2->Tail();
- };
- TheCurrent1 = TheCurrent1->Tail();
- };
- return Linter;
-}
-
-
-// -----------------------------
-// Difference with the set S
-// returns a set containing the
-// items which are in the set me
-// and not in the set B
-// -----------------------------
-Handle(PCollection_HSet) PCollection_HSet::
- Difference(const Handle(PCollection_HSet)& S)
-const
-{
- Item Litem;
- Standard_Boolean Insere,Ilela;
- Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
- Handle(PCollection_HSet) Ladif;
- Ladif = new PCollection_HSet;
- TheCurrent1 = TheLast;
- while (!TheCurrent1->IsEmpty())
- {
- Litem = TheCurrent1->Value();
- TheCurrent2 = S->Last();
- Ilela = Standard_False;
- while (!TheCurrent2->IsEmpty() && !Ilela)
- {
- if (TheCurrent2->Value() == Litem)
- Ilela = Standard_True;
- else
- TheCurrent2 = TheCurrent2->Tail();
- };
- if (!Ilela)
- Insere = Ladif->Add(Litem);
- TheCurrent1 = TheCurrent1->Tail();
- };
- return Ladif;
-}
-
-
-//---------------------------------------------------------------------
-// ShallowCopy
-//---------------------------------------------------------------------
-Handle(Standard_Persistent) PCollection_HSet::ShallowCopy() const
-{
-
- PCollection_HSet* TheCopy = new PCollection_HSet (*this);
- TheCopy->TheLast =
- Handle(PCollection_SetNode)::DownCast(::ShallowCopy(TheLast));
- return TheCopy;
-
-}
-
-//---------------------------------------------------------------------
-// ShallowDump
-//---------------------------------------------------------------------
-void PCollection_HSet::ShallowDump(Standard_OStream& S) const
-{
-
- S << "begin class Set "<<endl;
- S << "extent of Set : "<< TheExtent << endl;
- TheLast->ShallowDump(S);
- S << "end of class Set." << endl;
-
-}
-
-
-
-
-
-// -----------------------------
-// Extent : numbers of items
-// -----------------------------
-Standard_Integer PCollection_HSet::Extent() const {
- return TheExtent;
-}
-
-// -----------------------------
-// Last : last enterred item
-// -----------------------------
-Handle(PCollection_SetNode) PCollection_HSet::Last() const {
- return TheLast;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
--- Created on: 1991-09-02
--- Created by: Mireille MERCIEN
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-generic class HStack from PCollection (Item as Storable)
-inherits Persistent
-
- ---Purpose: A stack is a list of items in which items are
- -- added and removed from the same end, called the
- -- top of the stack.
-
-raises NoSuchObject from Standard
-
-
- class StackNode instantiates HSingleList from PCollection(Item);
-
- class StackIterator from PCollection
-
- ---Purpose: Iterator of the Stack class.
-
- raises NoMoreObject from Standard,
- NoSuchObject from Standard
- is
-
- Create(S : HStack from PCollection)
- returns StackIterator from PCollection;
- ---Purpose: Creates an iterator on the stack S.
- -- Set the iterator at the beginning of the stack S.
-
- More(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if there are other items.
-
- Next(me: in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Sets the iterator to the next item.
-
- Value(me) returns any Item raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Returns the item value corresponding to
- -- the current position of the iterator.
-
- fields
- TheIterator : StackNode;
- end;
-
-
-is
- Create returns mutable HStack from PCollection;
- ---Purpose: Creates an empty stack.
-
- Depth(me) returns Integer from Standard;
- ---Level: Public
- ---Purpose: Returns the number of items in the stack.
- ---Example: if me = (A B C)
- -- returns 3
-
- IsEmpty(me) returns Boolean from Standard;
- ---Level: Public
- ---Purpose: Returns True if the stack contains no item.
-
- Top(me) returns any Item
- ---Level: Public
- ---Purpose: Returns the item on the top of the stack.
- -- Raises an exception if the stack is empty.
- ---Example: before
- -- me = (A B C)
- -- after
- -- me = (A B C)
- -- returns
- -- C
- raises NoSuchObject from Standard;
-
- FTop(me) returns StackNode;
- ---Level: Public
- ---Purpose: Returns the field TheTop (the top of the stack).
-
- Push(me : mutable; T : Item);
- ---Level: Public
- ---Purpose: Inserts an item on the top of the stack.
- ---Example: before
- -- me = (A B) , T = C
- -- after
- -- me = (A B C)
-
- Pop(me : mutable) raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Removes an item from the top of the stack.
- -- Raises an exception if the stack is empty.
- ---Example: before
- -- me = (A B C)
- -- after
- -- me = (A B)
- -- returns
- -- C
-
- Clear(me : mutable);
- ---Level: Public
- ---Purpose: Removes all the items from the stack.
- ---Example: before
- -- me = (A B C)
- -- after
- -- me = ()
-
- ChangeTop(me:mutable; T : Item) raises NoSuchObject from Standard;
- ---Level: Public
- ---Purpose: Replaces the top of the stack with T.
- -- Raises an exception if the stack is empty.
- ---Example: before
- -- me = (A B C) , T = D
- -- after
- -- me = (A B D)
-
-
- ShallowCopy(me)
- returns mutable like me
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
- ShallowDump (me; s: in out OStream)
- is redefined;
- ---Level: Advanced
- ---C++: function call
-
-
-
-fields
- TheTop : StackNode;
- TheDepth : Integer from Standard;
-
-end;
-
-
-
-
-
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// ------------
-// constructor
-// -----------
-
-PCollection_HStack::PCollection_HStack()
-{
- TheDepth = 0;
- TheTop = new PCollection_StackNode;
-}
-
-// ------------------------------------
-// Push : insert an item on the top
-// ------------------------------------
-void PCollection_HStack::Push(const Item& T)
-{
- TheTop = TheTop->Construct(T);
- TheDepth = TheDepth + 1;
-
- }
-
-// ------------------------------------
-// Pop : remove an item from the top
-// ------------------------------------
-void PCollection_HStack::Pop()
-{
- if (TheTop->IsEmpty()) Standard_NoSuchObject::Raise();
- Handle(PCollection_StackNode) temp = TheTop;
- TheTop = TheTop->Tail();
- temp.Delete();
- TheDepth = TheDepth - 1;
-}
-
-
-// -----------------------------
-// IsEmpty : is the stack empty ?
-// -----------------------------
-Standard_Boolean PCollection_HStack::IsEmpty() const
-{
- return TheTop->IsEmpty();
-}
-
-// ------------------------------------
-// Clear : remove all items
-// ------------------------------------
-void PCollection_HStack::Clear()
-{
- Handle(PCollection_StackNode) temp;
- while (TheDepth != 0) {
- temp = TheTop;
- TheTop = TheTop->Tail();
- temp.Delete();
- --TheDepth;
- }
-}
-
-// ------------------------------------
-// ChangeTop : replace the top by T
-// ------------------------------------
-void PCollection_HStack::ChangeTop(const Item& T)
-{
- if (TheTop->IsEmpty()) Standard_NoSuchObject::Raise();
- TheTop->SetValue(T);
-}
-
-// -----------------------------
-// Top : item on the Top
-// -----------------------------
-Item PCollection_HStack::Top() const
-{
- if (TheTop->IsEmpty()) Standard_NoSuchObject::Raise();
- return TheTop->Value();
-}
-
-
-// ------------------------------------
-// ShallowCopy redefinition
-// ------------------------------------
-Handle(Standard_Persistent) PCollection_HStack::ShallowCopy() const
-{
- PCollection_HStack* TheCopy = new PCollection_HStack (*this);
- TheCopy->TheTop =
- Handle(PCollection_StackNode)::DownCast(::ShallowCopy(TheTop));
- return TheCopy;
-}
-
-// ------------------------------------
-// ShallowDump redefinition
-// ------------------------------------
-void PCollection_HStack::ShallowDump(Standard_OStream& S) const
-{
- S << "begin class Stack "<< endl;
- S << "Length of Stack : "<< TheDepth << endl;
- TheTop->ShallowDump(S);
- S << "end of class Stack." << endl;
-}
-
-
-
-// -----------------------------
-// Depth : numbers of items
-// -----------------------------
-Standard_Integer PCollection_HStack::Depth() const {
- return TheDepth;
-}
-
-// -----------------------------
-// FTop : Top of the Stack
-// -----------------------------
-Handle(PCollection_StackNode) PCollection_HStack::FTop() const {
- return TheTop;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-Version:
-
-// Version Date Purpose
-// 14/12/92 Creation
-
-//-Language C++2.0
-
-//=======================================================================
-// Function : PCollection_IndexedDataMapNode
-// Purpose :
-//=======================================================================
-
-PCollection_IndexedDataMapNode::PCollection_IndexedDataMapNode
- (
- const Key& aKey,
- const Standard_Integer Index,
- const Item& anItem,
- const Handle(PCollection_IndexedDataMapNode)& NextKey,
- const Handle(PCollection_IndexedDataMapNode)& NextIndex) :
-
- myKey(aKey), myIndex(Index), myItem(anItem),
- myNextKey(NextKey), myNextIndex(NextIndex)
-{
-}
-
-//=======================================================================
-// Function : Set
-// Purpose :
-//=======================================================================
-
-void PCollection_IndexedDataMapNode::Set
- (
- const Key& aKey,
- const Standard_Integer Index,
- const Item& anItem,
- const Handle(PCollection_IndexedDataMapNode)& NextK,
- const Handle(PCollection_IndexedDataMapNode)& NextI)
-
-{
- myKey = aKey;
- myIndex = Index;
- myItem = anItem;
- myNextKey = NextK;
- myNextIndex = NextI;
-}
-
-//=======================================================================
-// Function : GetKey
-// Purpose :
-//=======================================================================
-
-Key PCollection_IndexedDataMapNode::GetKey() const
-{
- return myKey;
-}
-
-
-//=======================================================================
-// Function : Index
-// Purpose :
-//=======================================================================
-
-Standard_Integer PCollection_IndexedDataMapNode::Index() const
-{
- return myIndex;
-}
-
-
-//=======================================================================
-// Function : GetItem
-// Purpose :
-//=======================================================================
-
-Item PCollection_IndexedDataMapNode::GetItem() const
-{
- return myItem;
-}
-
-//=======================================================================
-// Function : KeyAndItem
-// Purpose : get two fields
-//=======================================================================
-
-void PCollection_IndexedDataMapNode::KeyAndItem(Key& theKey, Item& theItem) const
-{
- theKey = myKey;
- theItem = myItem;
-}
-
-//=======================================================================
-// Function : IndexAndItem
-// Purpose : get two fields
-//=======================================================================
-
-void PCollection_IndexedDataMapNode::IndexAndItem(Standard_Integer& Index,
- Item& theItem) const
-{
- Index = myIndex;
- theItem = myItem;
-}
-
-
-//=======================================================================
-// Function : NextKey
-// Purpose :
-//=======================================================================
-
-Handle(PCollection_IndexedDataMapNode)
- PCollection_IndexedDataMapNode::NextKey() const
-{
- return myNextKey;
-}
-
-//=======================================================================
-// Function : NextIndex
-// Purpose :
-//=======================================================================
-
-Handle(PCollection_IndexedDataMapNode)
- PCollection_IndexedDataMapNode::NextIndex() const
-{
- return myNextIndex;
-}
-
-//=======================================================================
-// Function : SetItem
-// Purpose :
-//=======================================================================
-
-void PCollection_IndexedDataMapNode::SetItem(const Item& anItem)
-{
- myItem = anItem;
-}
-
-//=======================================================================
-// Function : SetNextKey
-// Purpose :
-//=======================================================================
-
-void PCollection_IndexedDataMapNode::
- SetNextKey(const Handle(PCollection_IndexedDataMapNode)& aNode)
-{
- myNextKey = aNode;
-}
-
-//=======================================================================
-// Function : SetNextIndex
-// Purpose :
-//=======================================================================
-
-void PCollection_IndexedDataMapNode::
- SetNextIndex(const Handle(PCollection_IndexedDataMapNode)& aNode)
-{
- myNextIndex = aNode;
-}
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_LeavesIterator::PCollection_LeavesIterator
- (const Handle(PCollection_HDirectedGraph)& G):MyVertexIterator(G->GetVertices())
-{
- HasMore = False;
- while ((MyVertexIterator.More()) && (!HasMore)) {
- if (MyVertexIterator.Value()->IsLeaf())
- HasMore = True;
- else
- MyVertexIterator.Next();
- }
-}
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_LeavesIterator::More () const
-{
- return HasMore;
-}
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_LeavesIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- HasMore = False;
- MyVertexIterator.Next();
- while (MyVertexIterator.More() && !HasMore) {
- if (MyVertexIterator.Value()->IsLeaf())
- HasMore = True;
- else
- MyVertexIterator.Next();
- }
-}
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_LeavesIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return MyVertexIterator.Value();
-}
-
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_LeavesIterator::Clear ()
-{
-// Nullify sur les champs
- HasMore = False;
-}
-
+++ /dev/null
-// Created on: 1992-10-09
-// Created by: Mireille MERCIEN
-// Copyright (c) 1992-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_OutOfRange.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// ----------------------------------------------------------------------
-// ----------------------------------------------------------------------
-
-//----------------------------------------------------------------
-// Create
-//----------------------------------------------------------------
-PCollection_MapIterator::PCollection_MapIterator
- (const Handle(PCollection_HDataMap)& AMap)
-{
- if (AMap->IsEmpty()) {
- Index = 0;
- Node.Nullify();
- Buckets.Nullify();
- HasMore = False;
- }
- else {
-// stop at the first element of the first "no empty" bucket entry
- HasMore = True;
- Buckets = AMap->GetArray();
- NbBuck = AMap->NbBuckets();
- Boolean Found = False;
- Index = 1 ;
- while ( Index <= NbBuck && !Found ) {
- Node = Buckets->Value(Index);
- if (Node.IsNull())
- Index++;
- else
- Found = True;
- }
- if (!Found) HasMore = False;
- }
-}
-
-//----------------------------------------------------------------
-// More
-//----------------------------------------------------------------
-Standard_Boolean PCollection_MapIterator::More() const
-{
- return HasMore;
-}
-
-
-//----------------------------------------------------------------
-// Value
-//----------------------------------------------------------------
-Item PCollection_MapIterator::Value() const
-{
- if (Node.IsNull()) Standard_NoSuchObject::Raise();
- return (Node->Value());
-}
-
-//----------------------------------------------------------------
-// GetKey
-//----------------------------------------------------------------
-Key PCollection_MapIterator::GetKey() const
-{
- if (Node.IsNull()) Standard_NoSuchObject::Raise();
- return (Node->GetKey());
-}
-
-//----------------------------------------------------------------
-// Next
-//----------------------------------------------------------------
-void PCollection_MapIterator::Next()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- Node = Node->Next();
- if (Node.IsNull()) {
- Boolean Found = False;
- Index++;
- while ( Index <= NbBuck && !Found ) {
- Node = Buckets->Value(Index);
- if (Node.IsNull())
- Index++;
- else
- Found = True;
- }
- if (!Found) HasMore = False;
- }
-}
-
-
+++ /dev/null
-// Created on: 1993-01-11
-// Created by: Mireille MERCIEN
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-----------------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------------
-PCollection_MapNode::PCollection_MapNode(const Key& aKey,
- const Item& anItem,
- const Handle(PCollection_MapNode)& aNext)
-{
- myKey = aKey;
- myItem = anItem;
- myNext = aNext;
-}
-
-//-----------------------------------------------------------------
-// GetKey
-//-----------------------------------------------------------------
-Key PCollection_MapNode::GetKey() const
-{
- return myKey;
-}
-
-//-----------------------------------------------------------------
-// Value
-//-----------------------------------------------------------------
-Item PCollection_MapNode::Value() const
-{
- return myItem;
-}
-
-//-----------------------------------------------------------------
-// Next
-//-----------------------------------------------------------------
-Handle(PCollection_MapNode) PCollection_MapNode::Next() const
-{
- return myNext;
-}
-
-
-//-----------------------------------------------------------------
-// SetKey
-//-----------------------------------------------------------------
-void PCollection_MapNode::SetKey(const Key& aKey)
-{
- myKey = aKey;
-}
-
-
-//-----------------------------------------------------------------
-// SetValue
-//-----------------------------------------------------------------
-void PCollection_MapNode::SetValue(const Item& anItem)
-{
- myItem = anItem;
-}
-
-//-----------------------------------------------------------------
-// SetNext
-//-----------------------------------------------------------------
-void PCollection_MapNode::SetNext
- (const Handle(PCollection_MapNode)& aNext)
-{
- myNext = aNext;
-}
-
-//-----------------------------------------------------------------
-// ShallowCopy : ShallowCopy redefinition
-//-----------------------------------------------------------------
-Handle(Standard_Persistent) PCollection_MapNode::ShallowCopy() const
-{
- Handle(PCollection_MapNode) TheCopy;
- TheCopy = new PCollection_MapNode(myKey,myItem,myNext);
- return TheCopy;
-}
-
-//-----------------------------------------------------------------
-// ShallowDump : ShallowDump redefinition
-//-----------------------------------------------------------------
-void PCollection_MapNode::ShallowDump(Standard_OStream& S) const
-{
- S << "begin class MapNode "<< endl;
- Handle(PCollection_MapNode) anode;
- anode = this;
- ::ShallowDump(anode->GetKey(),S);
- ::ShallowDump(anode->Value(),S);
- if (!myNext.IsNull()) myNext->ShallowDump(S);
- S << "end of class MapNode." << endl;
-}
-
-
-
-
-
-
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// --------------------------------
-// constructor of QueueIterator
-// --------------------------------
-
-PCollection_QueueIterator::PCollection_QueueIterator
- (const Handle(PCollection_HQueue)& S)
-{
- TheIterator = S->FFront();
-}
-
-// -----------------------------------
-// More : returns Standard_True if there
-// are other items
-// -----------------------------------
-Standard_Boolean PCollection_QueueIterator::More() const
-{
- return ( ! TheIterator->IsEmpty() );
-}
-
-// -----------------------------------------
-// Next : set the iterator to the next item
-// -----------------------------------------
-void PCollection_QueueIterator::Next()
-{
- if (TheIterator->IsEmpty()) Standard_NoMoreObject::Raise();
- TheIterator = TheIterator->Tail();
-}
-
-// ---------------------------------------
-// Value : returns the current item value
-// of the iterator
-// ---------------------------------------
-Item PCollection_QueueIterator::Value() const
-{
- if (TheIterator->IsEmpty()) Standard_NoSuchObject::Raise();
- return TheIterator->Value();
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_RootsIterator::PCollection_RootsIterator
- (const Handle(PCollection_HDirectedGraph)& G):MyVertexIterator(G->GetVertices())
-{
- HasMore = False;
- while ((MyVertexIterator.More()) && (!HasMore)) {
- if (MyVertexIterator.Value()->IsRoot())
- HasMore = True;
- else
- MyVertexIterator.Next();
- }
-}
-
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_RootsIterator::More () const
-{
- return HasMore;
-}
-
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_RootsIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- HasMore = False;
- MyVertexIterator.Next();
- while ((MyVertexIterator.More()) && (!HasMore)) {
- if (MyVertexIterator.Value()->IsRoot())
- HasMore = True;
- else
- MyVertexIterator.Next();
- }
-}
-
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_RootsIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return MyVertexIterator.Value();
-}
-
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_RootsIterator::Clear ()
-{
-// Nullify sur les champs
- HasMore = False;
-}
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// --------------------------------
-// constructor of SetIterator
-// --------------------------------
-PCollection_SetIterator::PCollection_SetIterator
- (const Handle(PCollection_HSet)& S)
-{
- TheIterator = S->Last();
-}
-
-// -----------------------------------
-// More : returns Standard_True if there
-// are other items
-// -----------------------------------
-Standard_Boolean PCollection_SetIterator::More() const
-{
- return ! ( TheIterator->IsEmpty() ) ;
-}
-
-// -----------------------------------------
-// Next : set the iterator to the next item
-// -----------------------------------------
-void PCollection_SetIterator::Next()
-{
- if (TheIterator->IsEmpty()) Standard_NoMoreObject::Raise();
- TheIterator = TheIterator->Tail();
-}
-
-// ---------------------------------------
-// Value : returns the current item value
-// of the iterator
-// ---------------------------------------
-Item PCollection_SetIterator::Value() const
-{
- if (TheIterator->IsEmpty()) Standard_NoSuchObject::Raise();
- return TheIterator->Value();
-}
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-// --------------------------------
-// constructor of StackIterator
-// --------------------------------
-
-PCollection_StackIterator::PCollection_StackIterator
- (const Handle(PCollection_HStack)& S)
-{
- TheIterator = S->FTop();
-}
-
-// -----------------------------------
-// More : returns Standard_True if there
-// are other items
-// -----------------------------------
-Standard_Boolean PCollection_StackIterator::More() const
-{
- return (! TheIterator->IsEmpty());
-}
-
-// -----------------------------------------
-// Next : Set the iterator to the next item
-// -----------------------------------------
-void PCollection_StackIterator::Next()
-{
- if (TheIterator->IsEmpty()) Standard_NoMoreObject::Raise();
- TheIterator = TheIterator->Tail();
-}
-
-// ---------------------------------------
-// Value : returns the current item value
-// of the iterator
-// ---------------------------------------
-Item PCollection_StackIterator::Value() const
-{
- if (TheIterator->IsEmpty()) Standard_NoSuchObject::Raise();
- return TheIterator->Value();
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_NoMoreObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_Vertex::
- PCollection_Vertex (const Item& Value,
- const Handle(PCollection_HDirectedGraph)& InGraph)
-{
- MyItem = Value;
- MyGraph = InGraph;
- MyFrontEdges = new PCollection_SetOfEdge;
- MyBackEdges = new PCollection_SetOfEdge;
-}
-
-//---------------------------------------------------------------------------
-// GetItem
-//---------------------------------------------------------------------------
-Item PCollection_Vertex::GetItem () const
-{
- return MyItem;
-}
-
-//---------------------------------------------------------------------------
-// SetItem
-//---------------------------------------------------------------------------
-void PCollection_Vertex::SetItem (const Item& Value)
-{
- MyItem = Value;
-}
-
-//---------------------------------------------------------------------------
-// GetGraph
-//---------------------------------------------------------------------------
-Handle(PCollection_HDirectedGraph) PCollection_Vertex::GetGraph () const
-{
- return MyGraph;
-}
-
-//---------------------------------------------------------------------------
-// AddFrontEdge
-//---------------------------------------------------------------------------
-Boolean PCollection_Vertex::AddFrontEdge (const Handle(PCollection_Edge)& E)
-{
- if (MyFrontEdges->Contains(E)) {
- return False;
- }
- else {
- MyFrontEdges->Add(E);
- return True;
- }
-}
-
-//---------------------------------------------------------------------------
-// RemoveFrontEdge
-//---------------------------------------------------------------------------
-void PCollection_Vertex::RemoveFrontEdge (const Handle(PCollection_Edge)& E)
-{
- if (MyFrontEdges->Contains(E)) {
- MyFrontEdges->Remove(E);
- }
- else {
- Standard_NoSuchObject::Raise();
- }
-}
-
-//---------------------------------------------------------------------------
-// NbFrontEdges
-//---------------------------------------------------------------------------
-Integer PCollection_Vertex::NbFrontEdges () const
-{
- return MyFrontEdges->Extent();
-}
-
-//---------------------------------------------------------------------------
-// GetFrontEdges
-//---------------------------------------------------------------------------
-Handle(PCollection_SetOfEdge) PCollection_Vertex::GetFrontEdges () const
-{
- return MyFrontEdges;
-}
-
-//---------------------------------------------------------------------------
-// AddBackEdge
-//---------------------------------------------------------------------------
-Boolean PCollection_Vertex::AddBackEdge (const Handle(PCollection_Edge)& E)
-{
- if (MyBackEdges->Contains(E)) {
- return False;
- }
- else {
- MyBackEdges->Add(E);
- return True;
- }
-}
-
-//---------------------------------------------------------------------------
-// RemoveBackEdge
-//---------------------------------------------------------------------------
-void PCollection_Vertex::RemoveBackEdge (const Handle(PCollection_Edge)& E)
-{
- if (MyBackEdges->Contains(E)) {
- MyBackEdges->Remove(E);
- }
- else {
- Standard_NoSuchObject::Raise();
- }
-}
-
-//---------------------------------------------------------------------------
-// NbBackEdges
-//---------------------------------------------------------------------------
-Integer PCollection_Vertex::NbBackEdges () const
-{
- return MyBackEdges->Extent();
-}
-
-//---------------------------------------------------------------------------
-// GetBackEdges
-//---------------------------------------------------------------------------
-Handle(PCollection_SetOfEdge) PCollection_Vertex::GetBackEdges () const
-{
- return MyBackEdges;
-}
-
-//---------------------------------------------------------------------------
-// IsRoot
-//---------------------------------------------------------------------------
-Boolean PCollection_Vertex::IsRoot () const
-{
- return (NbBackEdges() == 0);
-}
-
-//---------------------------------------------------------------------------
-// IsLeaf
-//---------------------------------------------------------------------------
-Boolean PCollection_Vertex::IsLeaf () const
-{
- return (NbFrontEdges() == 0);
-}
-
-//---------------------------------------------------------------------------
-// IsDestination
-//---------------------------------------------------------------------------
-Boolean PCollection_Vertex::
- IsDestination (const Handle(PCollection_Vertex)& V) const
-{
- PCollection_SetIteratorOfSetOfEdge It(MyBackEdges);
- while (It.More()) {
- Handle(PCollection_Edge) E = It.Value();
- if (E->Source() == V) return True;
- It.Next();
- }
- return False;
-}
-
-//---------------------------------------------------------------------------
-// IsSource
-//---------------------------------------------------------------------------
-Boolean PCollection_Vertex::
- IsSource (const Handle(PCollection_Vertex)& V) const
-{
- PCollection_SetIteratorOfSetOfEdge It(MyFrontEdges);
- while (It.More()) {
- Handle(PCollection_Edge) E = It.Value();
- if ( E->Destination() == V) return True;
- It.Next();
- }
- return False;
-}
-
+++ /dev/null
-// Created on: 1991-05-29
-// Created by: Denis PASCAL
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// <dp>
-// Revised by: Mireille MERCIEN
-// Sep,7 1992
-
-#include <Standard_NoMoreObject.hxx>
-#include <Standard_NoSuchObject.hxx>
-
-
-//---------------------------------------------------------------------------
-// Constructor
-//---------------------------------------------------------------------------
-PCollection_VerticesIterator::PCollection_VerticesIterator
- (const Handle(PCollection_HDirectedGraph)& G):MyVertexIterator(G->GetVertices())
-{
- HasMore = MyVertexIterator.More();
-}
-
-
-//---------------------------------------------------------------------------
-// More
-//---------------------------------------------------------------------------
-Boolean PCollection_VerticesIterator::More () const
-{
- return HasMore;
-}
-
-//---------------------------------------------------------------------------
-// Next
-//---------------------------------------------------------------------------
-void PCollection_VerticesIterator::Next ()
-{
- if (!HasMore) Standard_NoMoreObject::Raise();
- MyVertexIterator.Next();
- HasMore = MyVertexIterator.More();
-}
-
-
-//---------------------------------------------------------------------------
-// Value
-//---------------------------------------------------------------------------
-Handle(PCollection_Vertex) PCollection_VerticesIterator::Value () const
-{
- if (!HasMore) Standard_NoSuchObject::Raise();
- return MyVertexIterator.Value();
-}
-
-
-//---------------------------------------------------------------------------
-// Clear
-//---------------------------------------------------------------------------
-void PCollection_VerticesIterator::Clear ()
-{
- HasMore = False;
-}
-
-
-
-
-
-
-
-
-
TCollection_Compare.gxx
-TCollection_AVLNode.hxx
TCollection_CMPLRS.edl
TCollection_WOKSteps.edl
class CompareOfReal;
- class AVLBaseNode;
- pointer AVLBaseNodePtr to AVLBaseNode from TCollection;
- generic class AVLSearchTree,AVLNode,AVLList,AVLIterator;
-
NextPrimeForMap(I : Integer) returns Integer;
---Purpose: Returns a prime number greater than <I> suitable
+++ /dev/null
--- Created on: 1998-01-21
--- Created by: Kernel
--- Copyright (c) 1998-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
-class AVLBaseNode from TCollection
- inherits TShared from MMgt
- uses AVLBaseNodePtr from TCollection,
- Side from TCollection
- is
- Create(L,R : AVLBaseNodePtr from TCollection) returns mutable AVLBaseNode from TCollection;
- ---C++: inline
-
- SetChild(me : mutable; theNode : AVLBaseNodePtr from TCollection; theSide : Side from TCollection);
- ---C++: inline
-
- Height(myclass; ANode : AVLBaseNodePtr from TCollection) returns Integer;
- RecursiveExtent(myclass; ANode : AVLBaseNodePtr from TCollection) returns Integer;
- RecursiveTotalExtent(myclass; ANode : AVLBaseNodePtr from TCollection) returns Integer;
-
- Right(me) returns AVLBaseNodePtr from TCollection;
- ---C++: inline
- ---C++: return &
-
- Left(me) returns AVLBaseNodePtr from TCollection;
- ---C++: inline
- ---C++: return &
-
- Count(me) returns Integer;
- ---C++: inline
- ---C++: return &
-
- fields
- myLeft : AVLBaseNodePtr from TCollection is protected;
- myRight : AVLBaseNodePtr from TCollection is protected;
- myCount : Integer from Standard is protected;
- end;
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <TCollection_AVLBaseNode.ixx>
-
-Standard_Integer TCollection_AVLBaseNode::Height(const TCollection_AVLBaseNodePtr& ANode)
- // Length of the longest child
-{
- if (!ANode) return 0;
- else return (1 + Max(Height(ANode->myLeft),Height(ANode->myRight)));
-}
-
-
-Standard_Integer TCollection_AVLBaseNode::RecursiveExtent(const TCollection_AVLBaseNodePtr & ANode)
- // Number of different items in the current tree
-{
- if ( ! ANode ) return 0;
- else return (1 + RecursiveExtent(ANode->myLeft)
- + RecursiveExtent(ANode->myRight) );
-}
-
-Standard_Integer TCollection_AVLBaseNode::RecursiveTotalExtent(const TCollection_AVLBaseNodePtr& ANode)
-{
- // Number of different items in the current tree according to
- // the multiplicity
- if ( ! ANode ) return 0;
- else return ( RecursiveTotalExtent(ANode->myLeft) + RecursiveTotalExtent(ANode->myRight) + ANode->myCount);
-}
-
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline TCollection_AVLBaseNode::TCollection_AVLBaseNode(const TCollection_AVLBaseNodePtr& L, const TCollection_AVLBaseNodePtr& R)
-: myLeft(L),myRight(R),myCount(1)
-{
-}
-
-inline void TCollection_AVLBaseNode::SetChild(const TCollection_AVLBaseNodePtr& theNode, const TCollection_Side theSide)
- // According to the side changes a child by another
-{
- if (theSide == TCollection_Left) {myLeft = theNode;}
- else {myRight = theNode;}
-}
-
-inline TCollection_AVLBaseNodePtr& TCollection_AVLBaseNode::Right() const
-{
- return (TCollection_AVLBaseNodePtr&)myRight;
-}
-
-inline TCollection_AVLBaseNodePtr& TCollection_AVLBaseNode::Left() const
-{
- return (TCollection_AVLBaseNodePtr&)myLeft;
-}
-
-inline Standard_Integer& TCollection_AVLBaseNode::Count() const
-{
- return (Standard_Integer&)myCount;
-}
-
+++ /dev/null
-// Created on: 1991-05-23
-// Created by: Jean-Pierre TIRAULT
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Transient implementation
-
-#include <Standard_Address.hxx>
-
-// Global variable
-static Standard_Address LastNode;
-// Global variable
-
-
-void TCollection_AVLIterator::InOrderTraversal (const Standard_Address A) {
- if (A) {
- InOrderTraversal (((TCollection_AVLNode*)A)->Left());
- TCollection_AVLList* S = new TCollection_AVLList;
- S->Value() = ((TCollection_AVLNode*)A)->Value();
- if (!FirstNode) {
- FirstNode = (Standard_Address*)S;
- LastNode = FirstNode;
- }
- else {
- ((TCollection_AVLList*)LastNode)->Next() = S;
- LastNode = (Standard_Address)S;
- }
- InOrderTraversal (((TCollection_AVLNode*)A)->Right());
- }
-}
-
-
-
-
-//-----------------------------------------------------------------------------
-TCollection_AVLIterator::
- TCollection_AVLIterator ( const TCollection_AVLSearchTree& aTree)
-{
- LastNode = FirstNode = NULL;
- Standard_Address Root = (Standard_Address) aTree.GetRoot(); // Current node = root of tree
- if (!Root) {
- HasMore = Standard_False;
- }
- else {
- HasMore = Standard_True;
- InOrderTraversal(Root);
- }
-}
-//-----------------------------------------------------------------------------
-TCollection_AVLIterator::TCollection_AVLIterator ( const TCollection_AVLSearchTree& aTree, const Item& anItem)
-{
- LastNode = FirstNode = NULL;
- Standard_Address Root;
-
- if (aTree.Find(anItem,Root)) {
- HasMore = Standard_True;
- InOrderTraversal(Root);
- }
- else {
- HasMore = Standard_False;
- }
-}
-
-//-----------------------------------------------------------------------------
-void TCollection_AVLIterator::Clear ()
-{
- LastNode = NULL ;
- TCollection_AVLList* S = (TCollection_AVLList*)FirstNode;
- TCollection_AVLList* P;
- while (S) { // Memory management
- P = S;
- S = (TCollection_AVLList*)S->Next();
- delete P;
- }
- FirstNode = NULL ;
- HasMore = Standard_False;
-}
-
-//-----------------------------------------------------------------------------
-const Item& TCollection_AVLIterator::Value () const
-{
- Standard_NoSuchObject_Raise_if(!HasMore,"TCollection_AVLIterator - No more object");
- return ((TCollection_AVLList*)FirstNode)->Value();
-}
-
-//-----------------------------------------------------------------------------
-void TCollection_AVLIterator::Next ()
-{
- Standard_NoSuchObject_Raise_if(!HasMore,"TCollection_AVLIterator - No more object");
- TCollection_AVLList* S = (TCollection_AVLList*)FirstNode;
- FirstNode = ((TCollection_AVLList*)FirstNode)->Next();
- HasMore = (FirstNode != NULL);
- delete S;
-}
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Standard_NoSuchObject.hxx>
-
-inline Standard_Boolean TCollection_AVLIterator::More () const {
- return HasMore;
-}
+++ /dev/null
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline TCollection_AVLList::TCollection_AVLList()
-: myNext(0L)
-{
-}
-
-inline Item & TCollection_AVLList::Value() const
-{
- return (Item&)myValue;
-}
-
-inline Standard_Address & TCollection_AVLList::Next() const
-{
- return (Standard_Address&)myNext;
-}
-
+++ /dev/null
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-void TCollection_AVLNode::RecursiveCopy (const TCollection_AVLBaseNodePtr& ANode,const TCollection_AVLBaseNodePtr& copy)
-{
- if (ANode) {
- ((TCollection_AVLNode*)copy)->Value() = ((TCollection_AVLNode*)ANode)->Value();
- if (ANode->Left()) {
- copy->Left() = new TCollection_AVLNode(((TCollection_AVLNode*)copy)->Value(),(TCollection_AVLBaseNodePtr)0L,(TCollection_AVLBaseNodePtr)0L);
- TCollection_AVLNode::RecursiveCopy(ANode->Left(),copy->Left());
- }
- if (ANode->Right()) {
- copy->Right() = new TCollection_AVLNode(((TCollection_AVLNode*)copy)->Value(),(TCollection_AVLBaseNodePtr)0L,(TCollection_AVLBaseNodePtr)0L);
- TCollection_AVLNode::RecursiveCopy(ANode->Right(),copy->Right());
- }
- }
-}
-
-// ----------------------------------------------------------------------
-TCollection_AVLBaseNodePtr TCollection_AVLNode::Copy(const TCollection_AVLBaseNodePtr& ANode)
-{
- TCollection_AVLNode *copy = NULL;
- if (ANode) {
- copy = new TCollection_AVLNode(((TCollection_AVLNode*)ANode)->Value(),(TCollection_AVLBaseNodePtr)0L,(TCollection_AVLBaseNodePtr)0L);
- TCollection_AVLNode::RecursiveCopy (ANode,copy);
- }
- return copy;
-}
-
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// ----------------------------------------------------------------------
-// Internal C++ class that provides tool to manipulate a tree node.
-// ----------------------------------------------------------------------
-
-//void ShallowDump(const Item&, Standard_OStream& );
-
-class AVLNode{
- public :
-
- Item Value;
- AVLNode* Left ;
- AVLNode* Right;
- Standard_Integer Count;
-
- friend class AVLList; // For iterator
-};
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline Item& TCollection_AVLNode::Value() const
-{
- return (Item&)myValue;
-}
-
-inline TCollection_AVLNode::TCollection_AVLNode(const Item& I,const TCollection_AVLBaseNodePtr& r,const TCollection_AVLBaseNodePtr& l)
-: TCollection_AVLBaseNode(r,l)
-{
- myValue = I;
-}
+++ /dev/null
--- Created on: 1991-05-21
--- Created by: Annick PANCHER
--- Copyright (c) 1991-1999 Matra Datavision
--- Copyright (c) 1999-2014 OPEN CASCADE SAS
---
--- This file is part of Open CASCADE Technology software library.
---
--- This library is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License version 2.1 as published
--- by the Free Software Foundation, with special exception defined in the file
--- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
--- distribution for complete text of the license and disclaimer of any warranty.
---
--- Alternatively, this file may be used under the terms of Open CASCADE
--- commercial license or contractual agreement.
-
--- Revised: Mireille MERCIEN
--- J.P. TIRAULT
--- Feb,19 1993
--- Adaptation of this persistent structure to a transient
--- structure.
--- J.P. TIRAULT -- R.BARRETO
--- Aug,11 1993
--- Update of method AVLSearchTree::Find. This method returns
--- a boolean status according to the method finds the Item or not.
--- Update of method AVLIterator::Value. This method returns an
--- Item.
-
-
-generic class AVLSearchTree from TCollection (
- Item as any;
- Comparator as Compare(Item))
-
-
-
- ---Purpose: Defines a binary search tree, e.g. an ordered and
- -- balanced binary tree. An AVLSearchTree is created
- -- with a kind of Item and a Comparator. It's
- -- composed with Nodes. One item is contained only by
- -- one Node, and a 'count' stores the number of its
- -- occurences.
- -- The only public operations on an AVLSearchTree,
- -- except reading ( the number of its Nodes, its Root
- -- or the Node containing an item) are to insert or
- -- remove an item, plus, of course, to find an item.
- -- Then, it's possible to ask to a Node its value,
- -- the number of occurences of this value, and its
- -- right and left children. Other methods of Node are
- -- private and called by the private methods of
- -- AVLSearchTree which manage the Find method, and
- -- Insert and Remove operations, always ensuring
- -- order and balance.
- -- 1. ORDER :
- -- If the tree contains three elements A,B,C, which
- -- are ordered, regarding to a comparator Comp, as
- -- following:
- -- A < B < C
- -- Then TheRoot of the tree will contain B, with A as
- -- LeftChild and C as RightChild.
- -- Each element on the left of a node A are 'lower'
- -- than A in respect with the used comparator, and
- -- each element on its right are greater.
- -- 2. BALANCE : The height of two children of a Node
- -- will never have a difference of more than one
- -- level. An AVLSearch Tree is ALWAYS balanced.
- -- Keywords: binary tree, ordered, balanced
- -- Warning: To use an AVLSearchTree, since it's ordered and
- -- balanced each time an item is inserted or removed,
- -- may be a bad choice if there are more changing
- -- operations than searching requests, for
- -- performances criterias. It can be judicious to
- -- use it when there are many items to consult
- -- frequently.
- -- References: Classix, Reusable C++ Components( Empathy
- -- incorporated, 1990).
- -- Algorithms are attributed to
- -- G.M.Adel'son-Vel'skii and E.M.Landis, 1962.
-
-uses Side
-raises NoSuchObject from Standard,
- NoMoreObject from Standard
-
-
-
- class AVLList from TCollection
- inherits TShared from MMgt
- is
- Create returns mutable AVLList from TCollection;
- ---C++: inline
-
- Value(me) returns Item;
- ---C++: inline
- ---C++: return &
-
- Next(me) returns Address;
- ---C++: inline
- ---C++: return &
-
- fields
- myValue : Item;
- myNext : Address from Standard;
- end;
-
- class AVLNode from TCollection
- inherits AVLBaseNode from TCollection
- uses AVLBaseNodePtr from TCollection
- is
- Create(I : Item; r,l : AVLBaseNodePtr from TCollection) returns AVLNode from TCollection;
- ---C++: inline
- Copy(myclass; ANode : AVLBaseNodePtr from TCollection) returns AVLBaseNodePtr from TCollection;
- RecursiveCopy(myclass; ANode,aCopy : AVLBaseNodePtr from TCollection);
-
- Value(me) returns Item;
- ---C++: inline
- ---C++: return &
-
- fields
- myValue : Item;
-
- friends class AVLList from TCollection
- end;
-
- class AVLIterator
-
- raises NoMoreObject from Standard, NoSuchObject from Standard
- is
- ---Purpose: This class provides to iterate on an AVLSearchTree.
- -- The type of traversal is the in-order traversal.
- -- Example : If the AVLTree is the following:
- -- 5
- -- 2 7
- -- 1 3 6 8
- --
- -- The result is:
- -- 1 2 3 5 6 7 8
- --
- -- During the exploration of the tree no updating of the
- -- tree must be done.
- --
-
- Create( aTree: AVLSearchTree)
- ---Purpose: Creates an iterator on <aTree> from the root of the
- -- AVLSearchtree.
- returns AVLIterator;
-
- Create( aTree: AVLSearchTree; theItem : Item)
- ---Purpose: Creates an iterator on <aTree> from the node that
- -- contains the Item (It is not necessary the root of the tree).
- returns AVLIterator;
-
- More( me )
- ---Level: Public
- ---Purpose: Returns True if there is still an element to be read
- ---C++: inline
- returns Boolean from Standard is static;
-
- Next( me: in out) raises NoMoreObject from Standard;
- ---Level: Public
- ---Purpose: Goes to next element of <me>
-
- Value( me)
- returns Item
- raises NoSuchObject from Standard;
- ---Level: Public
- ---C++: return const &
-
- Clear (me: in out) is static ;
- ---Level: Public
- ---Purpose: Empties my structure, so that if next call on <me>,
- -- it will raise an exception NoMoreObject
-
- InOrderTraversal (me : in out ; A : Address) is static private;
- ---Level: Internal
- ---Purpose: Internal method.
-
-fields
- FirstNode : Address;
- HasMore : Boolean;
-end;
-
-
------------------------------- AVLSearchTree --------------------------------
-is
-
- Create( aComparator: Comparator)
- ---Purpose: creates an empty tree (root points to NULL)
- returns AVLSearchTree;
-
-
- IsEmpty( me)
- ---Level: Public
- ---Purpose: Returns true if the tree is empty.
- ---Category: Reading
- ---C++: inline
- returns Boolean from Standard
- is static;
-
-
- Extent( me)
- ---Level: Public
- ---Purpose: Returns number of different items contained by <me>
- ---Category: Reading
- returns Integer from Standard
- is static;
-
- TotalExtent( me)
- ---Level: Public
- ---Purpose: Returns total number of items (considers account
- -- of each Node)
- ---Category: Reading
- returns Integer from Standard
- is static;
-
- Find( me; theItem: Item)
- ---Level: Public
- ---Purpose: Returns the Node containing <theItem>
- ---Category: Reading
- returns Boolean
- is static;
-
- Find( me; theItem: Item; theOrig: in out Item)
- ---Level: Public
- ---Purpose: Returns the Node containing <theItem>
- ---Category: Reading
- returns Boolean
- is static;
-
-
- GetRoot( me)
- returns Address
- is static;
- ---Level: Public
- ---Purpose: Returns the Root of the tree <me>.
- ---Category: Reading
- ---C++: inline
-
- GetComparator( me)
- returns Comparator
- is static;
- ---Level: Public
- ---Purpose: Returns the Comparator of the tree <me>.
- ---Category: Reading
- ---C++: inline
-
- Insert( me : in out ; theItem: Item)
- is static;
- ---Level: Public
- ---Purpose: Inserts <theItem> at the right place; if it's
- -- already in <me>, only changes its <count>.
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i2
- -- After
- -- me = ( i5( i2( i1 -i3)) -i7))
- -- ( i means LeftChild, -i means RightChild)
- ---Category: Writing
-
- InsertOnce(me : in out ; theItem: Item)
- ---Level: Public
- ---Purpose: Inserts <theItem> at the right place, but only if
- -- it isn't already in <me>; Returns False if already there.
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i3
- -- After
- -- me = ( i5( i3( i1)) -i7) and return False
- ---Category: Writing
- returns Boolean from Standard
- is static;
-
- Remove( me : in out; theItem : Item)
- ---Level: Public
- ---Purpose: Removes from <me> the Node containing <theItem>,
- -- if its count=1, or reduces its count if count>1;
- -- in this aim, calls the recursive method
- -- RecursiveRemove, with <forAll>=False;
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i7
- -- After
- -- me = ( i3( i1 -i5)) if count(i7)=1
- -- Or
- -- me = ( i5( i3( i1)) -i7) if count(i7)>1
- ---Category: Writing
- raises NoSuchObject from Standard
- is static;
-
- RemoveAll( me : in out; theItem: Item)
- ---Level: Public
- ---Purpose: removes from <me> the Node containing <theItem>;
- -- in this aim, calls the recursive method
- -- RecursiveRemove, with <forAll>=True;
- -- Before
- -- me = ( i5( i3( i1)) -i7) and theItem = i7
- -- After
- -- me = ( i3( i1 -i5))
- ---Category: Writing
- raises NoSuchObject from Standard
- is static;
-
- Merge (me; another:AVLSearchTree)
- ---Level: Public
- ---Purpose: creates a third one from <me> and <another>
- ---Category: Writing
- returns AVLSearchTree
- is static;
-
-
-
- SetRoot(me : in out ; theNode: Address)
- ---Level: Internal
- is static private;
- ---C++: inline
-
- RotateLeft( me ; theNode : in out Address)
- ---Level: Internal
- ---Purpose: Right child A of <theNode> becomes the parent, and
- -- <theNode> becomes its left child; left child of A
- -- becomes the right child of <theNode>. This
- -- rotation will permit to balance <me> after a
- -- pertubating action ( insert or remove) on it.
- is static private;
-
- RotateRight( me ; theNode : in out Address)
- ---Level: Internal
- ---Purpose: left child A of <theNode> becomes the parent, and
- -- <theNode> becomes its right child; right child of
- -- A becomes the left child of <theNode>. This
- -- rotation will permit to balance <me> after a
- -- pertubating action ( insert or remove) on it.
- is static private;
-
- LeftBalance( me; theNode : in out Address)
- ---Level: Internal
- ---Purpose: called after inserting or removing an item, if the
- -- left branch of <theNode> is too long
- is static private;
-
- RightBalance( me ; theNode : in out Address)
- ---Level: Internal
- ---Purpose: Called after inserting or removing an item, if the
- -- right branch of <theNode> is too long.
- is static private;
-
- InsertBalance( me ; theNode : in out Address;
- theFather: Address;
- theSide : Side)
- ---Level: Internal
- ---Purpose: Balances <me> after inserting an item.
- returns Boolean from Standard
- is static private;
-
- RemoveBalance( me ; theNode : in out Address;
- theFather: Address;
- theSide : Side)
- ---Level: Internal
- ---Purpose: Balances <me> after removing an item.
- returns Boolean from Standard
- is static private;
-
- RecursiveInsert( me ; theNode : in out Address;
- theFather: Address;
- theSide : Side;
- theItem : Item;
- forOnce : in out Boolean from Standard)
- ---Level: Internal
- ---Purpose: Recursive method to insert a new Node OR to find
- -- the existing one containing <theItem> and increase
- -- its count.
- -- Returns True when a new Node has been created to
- -- know it needs to be balanced, and then returns
- -- False again.
- returns Boolean from Standard
- is static private;
-
- Find ( me ; theItem : Item ; theNode : in out Address)
- returns Boolean is static private;
- ---Level: Internal
- ---Purpose: Returns the Node associated to the Item.
-
- RecursiveRemove( me ; theNode : in out Address;
- theFather: Address;
- theSide : Side;
- theItem : Item;
- forAll : Boolean from Standard)
- ---Level: Internal
- ---Purpose: Recursive method to find the Node containing
- -- <theItem>. In case it's <theNode>, removes it if
- -- <forAll> is True, or reduces its count if <forAll>
- -- is False.
- -- Returns True when theItem has been found
- returns Boolean from Standard
- is static private;
-
-
- ShallowCopy(me) returns AVLSearchTree;
- ---Level: Advanced
- ---C++: function call
-
-
-
-
-fields
-
- TheRoot : Address from Standard;
- TheComparator : Comparator;
-
-
-friends
- class AVLIterator from TCollection
-
-end;
-
-
-
+++ /dev/null
-// Created on: 1991-05-23
-// Created by: Jean-Pierre TIRAULT
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Transient implementation
-
-#define TCollection_AVLSearchTreeTrace 0
-// K_TRACE_A_METHOD used also in Engine.cxx, Engine_Signature.cxx,
-// Engine_Argument.cxx, Engine_MyClassCompareOfSignature.cxx and
-// TCollection_AVLSearchTree.gxx (! pour Kernel)
-#define K_TRACE_A_METHOD 0
-#if K_TRACE_A_METHOD
-extern K_Trace_a_Method ;
-#endif
-
-#include <Standard_NoSuchObject.hxx>
-#include <Standard_Address.hxx>
-#include <TCollection_Side.hxx>
-#if TCollection_AVLSearchTreeTrace
-#include <Engine_Signature.hxx>
-#endif
-
-
-//-----------------------------------------------------------------------------
-// Create : creates an empty AVLSearchTCollection_AVLSearchTree
-//-----------------------------------------------------------------------------
-TCollection_AVLSearchTree::
- TCollection_AVLSearchTree(const Comparator& AComparator) : TheRoot(NULL)
-{
- TheComparator = AComparator;
-}
-
-
-//----------------------------------------------------------------------------
-Standard_Integer TCollection_AVLSearchTree::Extent () const
-{
- return TCollection_AVLNode::RecursiveExtent((TCollection_AVLNode*) TheRoot);
-}
-
-
-//----------------------------------------------------------------------------
-Standard_Integer TCollection_AVLSearchTree::TotalExtent () const
-{
- return TCollection_AVLNode::RecursiveTotalExtent((TCollection_AVLNode*)TheRoot);
-}
-
-//----------------------------------------------------------------------------
-// Find the Node where an item is located
-//----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::Find(const Item& TheItem) const
-{
- TCollection_AVLNode* aNode = (TCollection_AVLNode*) TheRoot;
-#if TCollection_AVLSearchTreeTrace
- cout << " ++++++++++++++++++ SEARCH1 +++++++++++++++++++++++++++++" << endl ;
- cout << "BEGINNING OF SEARCH OF " << TheItem->PForMapOfMethods()->Name()
- << " in " << hex << TheRoot << dec << endl ;
-#endif
- while (aNode) {
- if ( TheComparator.IsLower(TheItem, aNode->Value()) ) {
- aNode = (TCollection_AVLNode*)aNode->Left();
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsLower : Left : " << hex
- << aNode << dec << endl ;
-#endif
- }
- else if ( TheComparator.IsGreater(TheItem, aNode->Value()) ) {
- aNode = (TCollection_AVLNode*)aNode->Right();
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsGreater : Right : " << hex
- << aNode << dec << endl ;
-#endif
- }
- else {
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsEqual : " << hex << aNode
- << dec << endl ;
-#endif
- break;
- }
- }
- if ( aNode ) {
-#if TCollection_AVLSearchTreeTrace
- cout << "FOUND " << aNode->Value()->PForMapOfMethods()->Name() << endl ;
-#endif
- return Standard_True;
- }
-#if TCollection_AVLSearchTreeTrace
- cout << " NOT FOUND" << endl ;
-#endif
- return Standard_False;
-
-}
-
-//----------------------------------------------------------------------------
-// Find the Node where an item is located and returns the node associated
-//----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::Find(const Item& TheItem,
- Standard_Address& TheNode) const
-{
- TCollection_AVLNode* aNode = (TCollection_AVLNode*) TheRoot;
-#if TCollection_AVLSearchTreeTrace
- cout << " ++++++++++++++++++ SEARCH2 +++++++++++++++++++++++++++++" << endl ;
- cout << "BEGINNING OF SEARCH OF " << TheItem->PForMapOfMethods()->Name()
- << " in " << hex << TheRoot << dec << endl ;
-#endif
- while (aNode) {
- if ( TheComparator.IsLower(TheItem, aNode->Value()) ) {
- aNode = (TCollection_AVLNode*)aNode->Left();
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsLower : Left : " << hex
- << aNode << dec << endl ;
-#endif
- }
- else if ( TheComparator.IsGreater(TheItem, aNode->Value()) ) {
- aNode = (TCollection_AVLNode*)aNode->Right();
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsGreater : Right : " << hex
- << aNode << dec << endl ;
-#endif
- }
- else {
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsEqual : " << hex << aNode
- << dec << endl ;
-#endif
- break;
- }
- }
- if ( aNode ) {
- TheNode = (Standard_Address) aNode;
-#if TCollection_AVLSearchTreeTrace
- cout << "FOUND " << aNode->Value()->PForMapOfMethods()->Name() << endl ;
-#endif
- return Standard_True;
- }
-#if TCollection_AVLSearchTreeTrace
- cout << " NOT FOUND" << endl ;
-#endif
- return Standard_False;
-
-}
-
-//----------------------------------------------------------------------------
-// Find the Node where an item is located
-//----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::Find(const Item& TheItem,
- Item& TheOrig) const
-{
- TCollection_AVLNode* aNode = (TCollection_AVLNode*) TheRoot;
-#if TCollection_AVLSearchTreeTrace
- cout << " ++++++++++++++++++ SEARCH3 +++++++++++++++++++++++++++++" << endl ;
- cout << "BEGINNING OF SEARCH OF " << TheItem->PForMapOfMethods()->Name()
- << " in " << hex << TheRoot << dec << endl ;
-#endif
- while (aNode) {
- if ( TheComparator.IsLower(TheItem, aNode->Value()) ) {
- aNode = (TCollection_AVLNode*)aNode->Left();
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsLower : Left : " << hex
- << aNode << dec << endl ;
-#endif
- }
- else if ( TheComparator.IsGreater(TheItem, aNode->Value()) ) {
- aNode = (TCollection_AVLNode*)aNode->Right();
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsGreater : Right : " << hex
- << aNode << dec << endl ;
-#endif
- }
- else {
-#if K_TRACE_A_METHOD
- if ( K_Trace_a_Method )
- cout << "TCollection_AVLSearchTree::Find IsEqual : " << hex << aNode
- << dec << endl ;
-#endif
- break;
- }
- }
- if ( aNode ) {
- TheOrig = aNode->Value();
-#if TCollection_AVLSearchTreeTrace
- cout << "FOUND " << aNode->Value()->PForMapOfMethods()->Name() << endl ;
-#endif
- return Standard_True;
- }
-#if TCollection_AVLSearchTreeTrace
- cout << " NOT FOUND" << endl ;
-#endif
- return Standard_False;
-
-}
-
-//----------------------------------------------------------------------------
-// RotateRight
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::RotateRight(Standard_Address& TheNode) const
-{
-// the left child becomes the parent...
- TCollection_AVLNode* Temp = (TCollection_AVLNode*)((TCollection_AVLNode *)TheNode)->Left();
- ((TCollection_AVLNode *)TheNode)->Left() = Temp->Right();
- Temp->Right() = (TCollection_AVLNode *)TheNode;
- TheNode = (Standard_Address)Temp;
-}
-
-//-----------------------------------------------------------------------------
-// RotateLeft
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::
- RotateLeft(Standard_Address& TheNode) const
-{
-// the right child becomes the parent...
- TCollection_AVLNode* Temp = (TCollection_AVLNode*)((TCollection_AVLNode *)TheNode)->Right();
- ((TCollection_AVLNode *)TheNode)->Right() = Temp->Left();
- Temp->Left() = (TCollection_AVLNode *)TheNode;
- TheNode = (Standard_Address)Temp;
-}
-
-//-----------------------------------------------------------------------------
-// LeftBalance
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::LeftBalance(Standard_Address& Root) const
-{
- TCollection_AVLNode* TheNode = (TCollection_AVLNode*)((TCollection_AVLNode*)Root)->Left();
- if( TCollection_AVLNode::Height(TheNode->Left()) >= TCollection_AVLNode::Height(TheNode->Right()) ) {
- RotateRight(Root);
- return;
- }
- Standard_Address Ptr = TheNode;
- RotateLeft(Ptr);
- TheNode = (TCollection_AVLNode*)Ptr;
- ((TCollection_AVLNode*)Root)->Left() = TheNode;
- RotateRight(Root);
-}
-
-//----------------------------------------------------------------------------
-// RightBalance
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::RightBalance(Standard_Address& Root) const
-{
- TCollection_AVLNode* TheNode = (TCollection_AVLNode*)((TCollection_AVLNode *)Root)->Right();
- if( TCollection_AVLNode::Height(TheNode->Right()) >= TCollection_AVLNode::Height(TheNode->Left())) {
- RotateLeft(Root);
- return;
- }
- Standard_Address Ptr = TheNode;
- RotateRight(Ptr);
- TheNode = (TCollection_AVLNode*)Ptr;
- ((TCollection_AVLNode*)Root)->Right() = TheNode;
- RotateLeft(Root);
-}
-
-//-----------------------------------------------------------------------------
-// InsertBalance
-//-----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::InsertBalance(Standard_Address& Child,
- const Standard_Address Father,
- const TCollection_Side theSide) const
-{
-// Balance after insertion
- switch (TCollection_AVLNode::Height(((TCollection_AVLNode*)Child)->Left()) -
- TCollection_AVLNode::Height(((TCollection_AVLNode*)Child)->Right())) {
- case 2 : LeftBalance(Child);
- if ( Father )
- ((TCollection_AVLNode*)Father)->SetChild((TCollection_AVLNode*)Child, theSide);
- return Standard_False;
- case -2 : RightBalance(Child);
- if ( Father )
- ((TCollection_AVLNode*)Father)->SetChild((TCollection_AVLNode*)Child, theSide);
- return Standard_False;
- case 0 : return Standard_False;
- default : return Standard_True;
- }
-}
-
-//----------------------------------------------------------------------------
-// RemoveBalance
-//-----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::
- RemoveBalance(Standard_Address& Child,
- const Standard_Address Father,
- const TCollection_Side theSide) const
-{
-// Balance after Remove
- switch (TCollection_AVLNode::Height(((TCollection_AVLNode*)Child)->Left()) -
- TCollection_AVLNode::Height(((TCollection_AVLNode*)Child)->Right())) {
- case 2 : LeftBalance(Child);
- if (Father)
- ((TCollection_AVLNode*)Father)->SetChild((TCollection_AVLNode*)Child, theSide);
- return Standard_True;
- case -2 : RightBalance(Child);
- if ( Father )
- ((TCollection_AVLNode*)Father)->SetChild((TCollection_AVLNode*)Child, theSide);
- return Standard_True;
- default : return Standard_True;
- }
-}
-
-//---------------------------------------------------------------------------
-// RecursiveInsert
-//-----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::
- RecursiveInsert(
- Standard_Address& Child,
- const Standard_Address Father,
- const TCollection_Side theSide,
- const Item& theItem,
- Standard_Boolean& forOnce) const
-{
-
- TCollection_AVLNode* Temp;
-// DEC C++ need
- Standard_Address MyTemp;
-// end of DEC C++ need
- Standard_Boolean Result = Standard_False;
- Standard_Integer Number;
-
- //-- Firstly find where the item should be insert
-
- if(TheComparator.IsLower(theItem, ((TCollection_AVLNode*)Child)->Value() ) )
- //---------------
- //-- If the item is lower than the root go to left child
-
- {
- Temp = (TCollection_AVLNode*)((TCollection_AVLNode*)Child)->Left();
- //-- If it's a leaf insert it
- if ( ! Temp ) {
- ((TCollection_AVLNode*)Child)->Left() = new TCollection_AVLNode(theItem,(TCollection_AVLNode*)0L,(TCollection_AVLNode*)0L);
- return Standard_True;
- }
- //-- else recursive insert...
- MyTemp = (Standard_Address)Temp;
- Result = RecursiveInsert( MyTemp, Child, TCollection_Left,
- theItem, forOnce);
- //-- and rebuild the tree, if no problem.
- if(Result) return InsertBalance(Child, Father, theSide) ;
- else return Standard_False;
- }
-
- else if (TheComparator.IsGreater(theItem, ((TCollection_AVLNode*)Child)->Value()))
- //---------------
- //-- If the item is greater than the root go to right child
-
- {
- Temp = (TCollection_AVLNode*)((TCollection_AVLNode*)Child)->Right();
- //-- If it's a leaf insert it
- if ( ! Temp ) {
- ((TCollection_AVLNode*)Child)->Right() = new TCollection_AVLNode(theItem,(TCollection_AVLNode*)0L,(TCollection_AVLNode*)0L);
- return Standard_True;
- }
- //-- else recursive insert...
-
- MyTemp = (Standard_Address)Temp;
- Result = RecursiveInsert( MyTemp, Child, TCollection_Right,
- theItem, forOnce);
- //-- and rebuild the tree, if no problem.
- if(Result) return InsertBalance(Child, Father, theSide);
- else return Standard_False;
- }
-
- else
- {
- //--------------
- //-- Item is already there; add 1 to its count
- if (forOnce) {
- forOnce = Standard_False;
- }
- else {
- Number = ((TCollection_AVLNode*)Child)->Count();
- ((TCollection_AVLNode*)Child)->Count() = ++Number;
- }
- return Standard_False;
- }
-}
-
-//-----------------------------------------------------------------------------
-// RecursiveRemove
-//-----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::RecursiveRemove(
- Standard_Address& Child,
- const Standard_Address Father,
- const TCollection_Side theSide,
- const Item& TheItem,
- const Standard_Boolean ForAll) const
-{
- Standard_Boolean Result;
-
- if ( ! Child ) Standard_NoSuchObject::Raise();// if Child points to something
-
- TCollection_AVLNode* TheLeft = (TCollection_AVLNode*)((TCollection_AVLNode*)Child)->Left(); // left children
- TCollection_AVLNode* TheRight = (TCollection_AVLNode*)((TCollection_AVLNode*)Child)->Right();// right children
-// DEC C++ need
- Standard_Address MyTheLeft;
- Standard_Address MyTheRight;
-//
- if (TheComparator.IsLower(TheItem,((TCollection_AVLNode*)Child)->Value()))
- { // TheItem < Value
- MyTheLeft = (Standard_Address)TheLeft;
- Result = RecursiveRemove( MyTheLeft, // left child becomes root
- Child , // child becomes father
- TCollection_Left, // go to left
- TheItem , // same Item
- ForAll);
- }
- else if (TheComparator.IsGreater(TheItem,(((TCollection_AVLNode*)Child)->Value())))
- { // TheItem > Value
- MyTheRight = (Standard_Address)TheRight;
- Result = RecursiveRemove( MyTheRight,// right child becomes root
- Child,// child becomes father
- TCollection_Right,// go to right
- TheItem ,// same Item
- ForAll);
- }
- else
- {
- //-- The Item has been found
- ((TCollection_AVLNode*)Child)->Count()--;
- //-- Is it necessary to remove it ?
- if (!ForAll && ((TCollection_AVLNode*)Child)->Count() > 0) return Standard_True;
- //-- In this case we must remove it and rebuild the subtree.
- if ( TheLeft && TheRight )
- {
- //-- The subtree has 2 children
- TCollection_AVLNode* T;
- TCollection_AVLNode* Temp = TheRight; // From the right child go to
- while ( Temp ) { // the left leaf
- T = Temp;
- Temp = (TCollection_AVLNode*)Temp->Left();
- }
- //-- We have the left leaf. Push it at the same level than the
- //-- node we have removed.
- ((TCollection_AVLNode*)Child)->Value() = T->Value() ;
- ((TCollection_AVLNode*)Child)->Count() = T->Count() ;
- //-- Now we must remove in the right subtree this value; because
- //-- now it appears twice.
- MyTheRight = (Standard_Address)TheRight;
- Result = RecursiveRemove( MyTheRight, Child, TCollection_Right,
- ((TCollection_AVLNode*)Child)->Value(), ForAll);
- }
- else
- {
- //-- only one subtree exists (left OR right)
- //-- First delete the node
- delete ((TCollection_AVLNode*)Child);
- //-- Secondly see what is the child not empty
- if ( ! TheLeft ) { Child = (Standard_Address) TheRight; }
- else { Child = (Standard_Address) TheLeft; }
- //-- Thirdly update the father node
-// "mip-avril-94 : if (Father is null) => Raise"
-// ((TCollection_AVLNode*)Father)->SetChild((TCollection_AVLNode*)Child, theSide);
- if ((TCollection_AVLNode*)Father != NULL)
- ((TCollection_AVLNode*)Father)->SetChild((TCollection_AVLNode*)Child, theSide);
- return Standard_True;
- }
- }
- //-- Result = Standard_True means we must reorder the tree.
- if (Result) return RemoveBalance(Child, Father, theSide);
- return Standard_False; // Child has not been found for now
-
-}
-
-//----------------------------------------------------------------------------
-// Insert
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::Insert (const Item& theItem)
-{
- if ( ! TheRoot ) {
- TheRoot = new TCollection_AVLNode(theItem,(TCollection_AVLNode*)0L,(TCollection_AVLNode*)0L);
- return;
- }
- TCollection_AVLNode* Father = NULL;
- Standard_Boolean forOnce = Standard_False;
- RecursiveInsert( TheRoot, (Standard_Address)Father, TCollection_Left, theItem,
- forOnce);
-}
-
-//-----------------------------------------------------------------------------
-// InsertOnce
-//-----------------------------------------------------------------------------
-Standard_Boolean TCollection_AVLSearchTree::InsertOnce (const Item& theItem)
-{
- if ( ! TheRoot ) {
- TheRoot = new TCollection_AVLNode(theItem,(TCollection_AVLNode*)0L,(TCollection_AVLNode*)0L);
- return Standard_True;
- }
- TCollection_AVLNode* Father = NULL;
- Standard_Boolean forOnce = Standard_True;
- RecursiveInsert( TheRoot, (Standard_Address)Father, TCollection_Left, theItem,
- forOnce);
- //-- forOnce = Standard_False if the item was already in the tree
- return forOnce;
-}
-
-//-----------------------------------------------------------------------------
-// Remove
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::Remove (const Item& theItem)
-{
- TCollection_AVLNode* Father = NULL;
- //-- remove ONLY ONE item of the tree
- RecursiveRemove( TheRoot, (Standard_Address)Father, TCollection_Left, theItem,Standard_False);
-}
-
-//----------------------------------------------------------------------------
-// RemoveAll
-//-----------------------------------------------------------------------------
-void TCollection_AVLSearchTree::RemoveAll (const Item& theItem)
-{
- TCollection_AVLNode* Father = NULL;
- //-- Remove ALL item of the tree
- RecursiveRemove( TheRoot, (Standard_Address)Father, TCollection_Left, theItem,Standard_True);
-}
-
-//----------------------------------------------------------------------------
-// Merge
-//-----------------------------------------------------------------------------
-TCollection_AVLSearchTree TCollection_AVLSearchTree::Merge(const TCollection_AVLSearchTree& aTree) const
-{
- Item theItem;
- // First, make a shallowcopy and push the result into a new tree
- //
- TCollection_AVLSearchTree newTree = ShallowCopy();
- // for test-- newTree.ShallowDump(cout);
- //
- TCollection_AVLIterator Iter( aTree );
- //-- Secondly, make an iterator on the second tree
- //
- while( Iter.More()) {
- //-- Thirdly get back its value
- // theItem = ((TCollection_AVLNode*)Iter.Value())->Value();
- //
- theItem = Iter.Value();
-
- //-- and push them into the new tree.
- //
- newTree.Insert(theItem);
- Iter.Next();
- }
-
- return newTree;
-}
-
-//----------------------------------------------------------------------------
-// ShallowCopy
-//-----------------------------------------------------------------------------
-TCollection_AVLSearchTree TCollection_AVLSearchTree::ShallowCopy() const
-{
- // Construct a new tree
- // with same comparator
- //
- TCollection_AVLSearchTree newtree (TheComparator);
-
- // Copy an TCollection_AVLNode and put
- // the result as root of new tree
- //
- newtree.SetRoot(TCollection_AVLNode::Copy((TCollection_AVLNode*)TheRoot)) ;
-
- return newtree;
-}
-
+++ /dev/null
-// Created by: J.P. TIRAULT
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//-----------------------------------------------------------------------------
-// inline methods for AVLSearchTree
-//-----------------------------------------------------------------------------
-#include <Standard_Address.hxx>
-
-//-----------------------------------------------------------------------------
-// IsEmpty : Is the current tree empty ?
-//-----------------------------------------------------------------------------
-inline Standard_Boolean TCollection_AVLSearchTree::IsEmpty () const
-{
- return TheRoot == NULL;
-}
-
-//-----------------------------------------------------------------------------
-// GetRoot : Returns the root of the current tree
-//-----------------------------------------------------------------------------
-inline Standard_Address TCollection_AVLSearchTree::GetRoot () const
-{
- return TheRoot;
-}
-
-//-----------------------------------------------------------------------------
-// GetComparator : Returns the Comparator of the current tree
-//-----------------------------------------------------------------------------
-inline Comparator TCollection_AVLSearchTree::GetComparator () const
-{
- return TheComparator;
-}
-
-// ---------------------------------------------------------------------------
-// SetRoot : Replaces the root of the current tree
-//-----------------------------------------------------------------------------
-inline void TCollection_AVLSearchTree::SetRoot(const Standard_Address ANode)
-{
- TheRoot = ANode;
-}
-
-