Generic "TCollection_Queue" class removed (along with "TCollection_QueueNode" and three instantiations in TColStd). Template class TCollection_Queue removed.
The code using queue classes converted to use lists for the same purpose (replacing Push -> Append, Front -> First, Pop -> RemoveFirst). In OpenGl_Context, list is used as stack instead of queue, for it looks more natural for release of resources (last allocated - first released).
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
-#include <TColStd_QueueOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
//=======================================================================
//function : GraphTools_BFSIterator
{
Standard_Integer index;
myVisited.Clear();
- TColStd_QueueOfInteger myReady;
+ TColStd_ListOfInteger myReady;
index = myVisited.Add(V);
- myReady.Push(index);
+ myReady.Append(index);
while (!myReady.IsEmpty()) {
- Vertex w1 = myVisited (myReady.Front());
- myReady.Pop();
+ Vertex w1 = myVisited (myReady.First());
+ myReady.RemoveFirst();
for (VIterator it(G,w1); it.More(); it.Next()) {
Vertex w2 = it.Value();
if (!myVisited.Contains(w2)) {
index = myVisited.Add(w2);
- myReady.Push(index);
+ myReady.Append(index);
}
}
}
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_DomainError.hxx>
-#include <TColStd_QueueOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
#include <GraphTools_TSNode.hxx>
//=======================================================================
indexcurrent++;
}
// current root vertices queue
- TColStd_QueueOfInteger processQueue;
+ TColStd_ListOfInteger processQueue;
Standard_Integer nbVertices = myVertices.Extent();
for (i = 1 ; i <= nbVertices; i++) {
- if (myVertices(i).NbRef() == 0) processQueue.Push(i);
+ if (myVertices(i).NbRef() == 0) processQueue.Append(i);
}
// acyclic processing
while (!processQueue.IsEmpty()) {
- indexcurrent = processQueue.Front();
+ indexcurrent = processQueue.First();
mySort.Append(indexcurrent);
nbadjacent = myVertices(indexcurrent).NbSuccessors();
for (i = 1; i <= nbadjacent; i++) {
indexadjacent = myVertices(indexcurrent).GetSuccessor(i);
myVertices(indexadjacent).DecreaseRef();
if (myVertices(indexadjacent).NbRef() == 0) {
- processQueue.Push (indexadjacent);
+ processQueue.Append(indexadjacent);
}
}
- processQueue.Pop();
+ processQueue.RemoveFirst();
}
// cyclic processing
myCycles = mySort.Length() + 1;
NCollection_HArray1.hxx
NCollection_Array2.hxx
NCollection_HArray2.hxx
-NCollection_Queue.hxx
NCollection_Stack.hxx
NCollection_List.hxx
NCollection_SList.hxx
NCollection_DefineDoubleMap.hxx
NCollection_DefineIndexedMap.hxx
NCollection_DefineIndexedDataMap.hxx
-NCollection_DefineQueue.hxx
NCollection_DefineSList.hxx
NCollection_DefineSequence.hxx
NCollection_DefineHSequence.hxx
+++ /dev/null
-// Created on: 2002-04-17
-// Created by: Alexander Kartomin (akm)
-// Copyright (c) 2002-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.
-
-// Automatically created from NCollection_Queue.hxx by GAWK
-// Purpose: A queue is a structure where Items are added at
-// the end and removed from the front. The first
-// entered Item will be the first removed. This is
-// called a FIFO (First In First Out).
-// Inherits BaseList, adds the data item to each node.
-
-
-#ifndef NCollection_DefineQueue_HeaderFile
-#define NCollection_DefineQueue_HeaderFile
-
-#include <NCollection_Queue.hxx>
-
-// **************************************** Template for Queue class ********
-
-#define DEFINE_QUEUE(_ClassName_, _BaseCollection_, TheItemType) \
-typedef NCollection_Queue<TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-17
-// Created by: Alexander Kartomin (akm)
-// Copyright (c) 2002-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.
-
-#ifndef NCollection_Queue_HeaderFile
-#define NCollection_Queue_HeaderFile
-
-#include <NCollection_TListIterator.hxx>
-
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-#include <Standard_NoSuchObject.hxx>
-#endif
-
-/**
- * Purpose: A queue is a structure where Items are added at
- * the end and removed from the front. The first
- * entered Item will be the first removed. This is
- * called a FIFO (First In First Out).
- * Inherits BaseList, adds the data item to each node.
- */
-template <class TheItemType> class NCollection_Queue
- : public NCollection_BaseCollection<TheItemType>,
- public NCollection_BaseList
-{
- public:
- typedef NCollection_TListNode<TheItemType> QueueNode;
- typedef NCollection_TListIterator<TheItemType> Iterator;
-
- public:
- // ---------- PUBLIC METHODS ------------
-
- //! Constructor
- NCollection_Queue(const Handle(NCollection_BaseAllocator)& theAllocator=0L) :
- NCollection_BaseCollection<TheItemType>(theAllocator),
- NCollection_BaseList() {}
-
- //! Copy constructor
- NCollection_Queue (const NCollection_Queue& theOther) :
- NCollection_BaseCollection<TheItemType>(theOther.myAllocator),
- NCollection_BaseList()
- { *this = theOther; }
-
- //! Size - Number of items
- virtual Standard_Integer Size (void) const
- { return Extent(); }
-
- //! Length - number of items
- Standard_Integer Length (void) const
- { return Extent(); }
-
- //! Replace this list by the items of theOther collection
- virtual void Assign (const NCollection_BaseCollection<TheItemType>& theOther)
- {
- if (this == &theOther)
- return;
- Clear();
- TYPENAME NCollection_BaseCollection<TheItemType>::Iterator& anIter =
- theOther.CreateIterator();
- for (; anIter.More(); anIter.Next())
- {
- QueueNode* pNew = new (this->myAllocator) QueueNode(anIter.Value());
- PAppend(pNew);
- }
- }
-
- //! Replace this list by the items of theOther queue
- NCollection_Queue& operator= (const NCollection_Queue& theOther)
- {
- if (this == &theOther)
- return *this;
- Clear ();
- QueueNode * pCur = (QueueNode *) theOther.PFirst();
- while (pCur)
- {
- QueueNode* pNew = new (this->myAllocator) QueueNode(pCur->Value());
- PAppend(pNew);
- pCur = (QueueNode *) pCur->Next();
- }
- return *this;
- }
-
- //! Clear this queue
- void Clear (void)
- { PClear (QueueNode::delNode, this->myAllocator); }
-
- //! Frontal item - constant
- const TheItemType& Front (void) const
- {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
- if (IsEmpty())
- Standard_NoSuchObject::Raise ("NCollection_Queue::Front");
-#endif
- return ((const QueueNode *) PFirst())->Value();
- }
-
- //! Frontal item - variable
- TheItemType& ChangeFront (void)
- {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
- if (IsEmpty())
- Standard_NoSuchObject::Raise ("NCollection_Queue::ChangeFront");
-#endif
- return ((QueueNode *) PFirst())->ChangeValue();
- }
-
- //! Push one item
- void Push (const TheItemType& theItem)
- {
- QueueNode * pNew = new (this->myAllocator) QueueNode(theItem);
- PAppend(pNew);
- }
-
- //! Pop first item
- void Pop (void)
- { PRemoveFirst (QueueNode::delNode, this->myAllocator); }
-
- //! Destructor - clears the List
- ~NCollection_Queue (void)
- { Clear(); }
-
- private:
- // ----------- PRIVATE METHODS -----------
-
- //! Creates Iterator for use on BaseCollection
- virtual TYPENAME NCollection_BaseCollection<TheItemType>::Iterator&
- CreateIterator(void) const
- { return *(new (this->IterAllocator()) Iterator(*this)); }
-
-};
-
-#endif
nvxMem (Standard_False),
mySharedResources (new OpenGl_ResourcesMap()),
myDelayed (new OpenGl_DelayReleaseMap()),
- myReleaseQueue (new OpenGl_ResourcesQueue()),
+ myUnusedResources (new OpenGl_ResourcesStack()),
myClippingState (),
myGlLibHandle (NULL),
myFuncs (new OpenGl_GlFunctions()),
{
mySharedResources = theShareCtx->mySharedResources;
myDelayed = theShareCtx->myDelayed;
- myReleaseQueue = theShareCtx->myReleaseQueue;
+ myUnusedResources = theShareCtx->myUnusedResources;
myShaderManager = theShareCtx->myShaderManager;
}
}
// =======================================================================
void OpenGl_Context::DelayedRelease (Handle(OpenGl_Resource)& theResource)
{
- myReleaseQueue->Push (theResource);
+ myUnusedResources->Prepend (theResource);
theResource.Nullify();
}
void OpenGl_Context::ReleaseDelayed()
{
// release queued elements
- while (!myReleaseQueue->IsEmpty())
+ while (!myUnusedResources->IsEmpty())
{
- myReleaseQueue->Front()->Release (this);
- myReleaseQueue->Pop();
+ myUnusedResources->First()->Release (this);
+ myUnusedResources->RemoveFirst();
}
// release delayed shared resources
#include <NCollection_DataMap.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_Handle.hxx>
-#include <NCollection_Queue.hxx>
+#include <NCollection_List.hxx>
#include <Message.hxx>
#include <OpenGl_Caps.hxx>
#include <OpenGl_Resource.hxx>
typedef NCollection_Handle<OpenGl_DelayReleaseMap> Handle(OpenGl_DelayReleaseMap);
typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_Resource)> OpenGl_ResourcesMap;
typedef NCollection_Handle<OpenGl_ResourcesMap> Handle(OpenGl_ResourcesMap);
- typedef NCollection_Queue<Handle(OpenGl_Resource)> OpenGl_ResourcesQueue;
- typedef NCollection_Handle<OpenGl_ResourcesQueue> Handle(OpenGl_ResourcesQueue);
+ typedef NCollection_List<Handle(OpenGl_Resource)> OpenGl_ResourcesStack;
+ typedef NCollection_Handle<OpenGl_ResourcesStack> Handle(OpenGl_ResourcesStack);
Handle(OpenGl_ResourcesMap) mySharedResources; //!< shared resources with unique identification key
Handle(OpenGl_DelayReleaseMap) myDelayed; //!< shared resources for delayed release
- Handle(OpenGl_ResourcesQueue) myReleaseQueue; //!< queue of resources for delayed clean up
+ Handle(OpenGl_ResourcesStack) myUnusedResources; //!< stack of resources for delayed clean up
OpenGl_Clipping myClippingState; //!< state of clip planes
is
class ListOfPnt instantiates List from TCollection (Pnt from gp);
- class QueueOfPnt instantiates Queue from TCollection (Pnt from gp);
class StackOfPnt instantiates Stack from TCollection (Pnt from gp);
class SListOfPnt instantiates SList from TCollection (Pnt from gp);
class DataMapOfRealPnt instantiates DataMap from TCollection
return 0;
}
-//=======================================================================
-//function : QANColTestQueue
-//purpose :
-//=======================================================================
-static Standard_Integer QANColTestQueue(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- if ( argc != 1) {
- di << "Usage : " << argv[0] << "\n";
- return 1;
- }
- QANCollection_QueueFunc aQueue;
- TestQueue(aQueue);
- return 0;
-}
-
//=======================================================================
//function : QANColTestStack
//purpose :
theCommands.Add("QANColTestIndexedMap", "QANColTestIndexedMap", __FILE__, QANColTestIndexedMap, group);
theCommands.Add("QANColTestIndexedDataMap", "QANColTestIndexedDataMap", __FILE__, QANColTestIndexedDataMap, group);
theCommands.Add("QANColTestList", "QANColTestList", __FILE__, QANColTestList, group);
- theCommands.Add("QANColTestQueue", "QANColTestQueue", __FILE__, QANColTestQueue, group);
theCommands.Add("QANColTestStack", "QANColTestStack", __FILE__, QANColTestStack, group);
theCommands.Add("QANColTestSet", "QANColTestSet", __FILE__, QANColTestSet, group);
theCommands.Add("QANColTestSList", "QANColTestSList", __FILE__, QANColTestSList, group);
return 0;
}
-//=======================================================================
-//function : QANColPerfQueue
-//purpose :
-//=======================================================================
-static Standard_Integer QANColPerfQueue(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- Standard_Integer Repeat, Size;
- if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
- return 1;
- }
- CompQueue(Repeat,Size);
- return 0;
-}
-
//=======================================================================
//function : QANColPerfStack
//purpose :
theCommands.Add("QANColPerfArray1", "QANColPerfArray1 Repeat Size", __FILE__, QANColPerfArray1, group);
theCommands.Add("QANColPerfArray2", "QANColPerfArray2 Repeat Size", __FILE__, QANColPerfArray2, group);
theCommands.Add("QANColPerfList", "QANColPerfList Repeat Size", __FILE__, QANColPerfList, group);
- theCommands.Add("QANColPerfQueue", "QANColPerfQueue Repeat Size", __FILE__, QANColPerfQueue, group);
theCommands.Add("QANColPerfStack", "QANColPerfStack Repeat Size", __FILE__, QANColPerfStack, group);
theCommands.Add("QANColPerfSet", "QANColPerfSet Repeat Size", __FILE__, QANColPerfSet, group);
theCommands.Add("QANColPerfSList", "QANColPerfSList Repeat Size", __FILE__, QANColPerfSList, group);
DEFINE_INDEXEDDATAMAP(QANCollection_IDMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
#include <NCollection_DefineList.hxx>
-#include <NCollection_DefineQueue.hxx>
#include <NCollection_DefineStack.hxx>
#include <NCollection_DefineSet.hxx>
#include <NCollection_DefineHSet.hxx>
////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
-////////////////////////////////DEFINE_QUEUE(QANCollection_Queue,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_STACK(QANCollection_Stack,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_SET(QANCollection_Set,QANCollection_Key2BaseCol,Key2Type)
////////////////////////////////DEFINE_HSET(QANCollection_HSet,QANCollection_Set)
DEFINE_LIST(QANCollection_ListFunc,QANCollection_BaseColFunc,ItemType)
-DEFINE_QUEUE(QANCollection_QueueFunc,QANCollection_BaseColFunc,ItemType)
DEFINE_STACK(QANCollection_StackFunc,QANCollection_BaseColFunc,ItemType)
DEFINE_SET(QANCollection_SetFunc,QANCollection_Key2BaseColFunc,Key2Type)
DEFINE_HSET(QANCollection_HSetFunc,QANCollection_SetFunc)
DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
#include <NCollection_DefineList.hxx>
-#include <NCollection_DefineQueue.hxx>
#include <NCollection_DefineStack.hxx>
#include <NCollection_DefineSet.hxx>
#include <NCollection_DefineHSet.hxx>
////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
-////////////////////////////////DEFINE_QUEUE(QANCollection_Queue,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_STACK(QANCollection_Stack,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_SET(QANCollection_Set,QANCollection_Key2BaseCol,Key2Type)
////////////////////////////////DEFINE_HSET(QANCollection_HSet,QANCollection_Set)
DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
-DEFINE_QUEUE(QANCollection_QueuePerf,QANCollection_BaseColPerf,ItemType)
DEFINE_STACK(QANCollection_StackPerf,QANCollection_BaseColPerf,ItemType)
DEFINE_SET(QANCollection_SetPerf,QANCollection_Key2BaseColPerf,Key2Type)
DEFINE_HSET(QANCollection_HSetPerf,QANCollection_SetPerf)
aL.Clear();
}
-// ===================== Test methods of Queue type ===========================
-////////////////////////////////void TestQueue (QANCollection_Queue& theQ)
-void TestQueue (QANCollection_QueueFunc& theQ)
-{
- // Length
- Standard_Integer iLen=theQ.Length();
- Standard_Integer i;
-
- printf ("Info: testing Queue(%d)\n", iLen);
- // Push, Pop, Front, ChangeFront
- ItemType anItem;
- ////////////////////////////////QANCollection_Queue aQ;
- QANCollection_QueueFunc aQ;
- for (i=0; i<4; i++)
- {
- Random (anItem);
- aQ.Push (anItem);
- Random(aQ.ChangeFront());
- Random (anItem);
- aQ.Push (anItem);
- PrintItem(aQ.Front());
- aQ.Pop();
- }
- // Copy constructor + operator=
- ////////////////////////////////theQ = QANCollection_Queue(aQ);
- theQ = QANCollection_QueueFunc(aQ);
-
- // Assign
- AssignCollection (theQ, aQ);
-
- // Clear
- aQ.Clear();
-}
-
// ===================== Test methods of Stack type ===========================
////////////////////////////////void TestStack (QANCollection_Stack& theS)
void TestStack (QANCollection_StackFunc& theS)
// Standard_EXPORT void TestInDaMap (QANCollection_IDMap& theNM);
#include <QANCollection_FuncMaps.hxx>
// Standard_EXPORT void TestList (QANCollection_List& theLi);
-// Standard_EXPORT void TestQueue (QANCollection_Queue& theQ);
// Standard_EXPORT void TestStack (QANCollection_Stack& theSt);
// Standard_EXPORT void TestSet (QANCollection_Set& theSe);
// Standard_EXPORT void TestSList (QANCollection_SList& theSL);
#include <QANCollection_ListOfPnt.hxx>
#include <QANCollection_SListOfPnt.hxx>
-#include <QANCollection_QueueOfPnt.hxx>
#include <QANCollection_StackOfPnt.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TColStd_SetOfInteger.hxx>
PERF_PRINT_ALL
}
-// ===================== Test perform of Queue type ==========================
-void CompQueue (const Standard_Integer theRep,
- const Standard_Integer theSize)
-{
- Standard_Integer i,j;
-
- ////////////////////////////////Perf_Meter aNPush ("NCollection_Queue pushing",0);
- ////////////////////////////////Perf_Meter aTPush ("TCollection_Queue pushing",0);
- ////////////////////////////////Perf_Meter aNPopp ("NCollection_Queue popping",0);
- ////////////////////////////////Perf_Meter aTPopp ("TCollection_Queue popping",0);
- ////////////////////////////////Perf_Meter aNOper ("NCollection_Queue operator=",0);
- ////////////////////////////////Perf_Meter aTOper ("TCollection_Queue operator=",0);
- ////////////////////////////////Perf_Meter aNClea ("NCollection_Queue clearing",0);
- ////////////////////////////////Perf_Meter aTClea ("TCollection_Queue clearing",0);
- ////////////////////////////////Perf_Meter aNAssi ("NCollection_Queue Assign",0);
- for (i=0; i<theRep; i++)
- {
- ////////////////////////////////QANCollection_Queue a1, a2;
- QANCollection_QueuePerf a1, a2;
- ////////////////////////////////aNPush.Start();
- PERF_START_METER("NCollection_Queue pushing")
- for (j=1; j<=theSize; j++)
- {
- ItemType anItem;
- Random(anItem);
- a1.Push(anItem);
- }
- ////////////////////////////////aNPush.Stop();
- PERF_STOP_METER("NCollection_Queue pushing")
- ////////////////////////////////aNOper.Start();
- PERF_START_METER("NCollection_Queue operator=")
- a2 = a1;
- ////////////////////////////////aNOper.Stop();
- PERF_STOP_METER("NCollection_Queue operator=")
- ////////////////////////////////aNAssi.Start();
- PERF_START_METER("NCollection_Queue Assign")
- a2.Assign(a1);
- ////////////////////////////////aNAssi.Stop();
- PERF_STOP_METER("NCollection_Queue Assign")
- ////////////////////////////////aNPopp.Start();
- PERF_START_METER("NCollection_Queue popping")
- for (j=1; j<=theSize; j++)
- a1.Pop();
- ////////////////////////////////aNPopp.Stop();
- PERF_STOP_METER("NCollection_Queue popping")
- ////////////////////////////////aNClea.Start();
- PERF_START_METER("NCollection_Queue clearing")
- a2.Clear();
- ////////////////////////////////aNClea.Stop();
- PERF_STOP_METER("NCollection_Queue clearing")
- }
-
- for (i=0; i<theRep; i++)
- {
- QANCollection_QueueOfPnt a1, a2;
- ////////////////////////////////aTPush.Start();
- PERF_START_METER("TCollection_Queue pushing")
- for (j=1; j<=theSize; j++)
- {
- ItemType anItem;
- Random(anItem);
- a1.Push(anItem);
- }
- ////////////////////////////////aTPush.Stop();
- PERF_STOP_METER("TCollection_Queue pushing")
- ////////////////////////////////aTOper.Start();
- PERF_START_METER("TCollection_Queue operator=")
- a2 = a1;
- ////////////////////////////////aTOper.Stop();
- PERF_STOP_METER("TCollection_Queue operator=")
- ////////////////////////////////aTPopp.Start();
- PERF_START_METER("TCollection_Queue popping")
- for (j=1; j<=theSize; j++)
- a1.Pop();
- ////////////////////////////////aTPopp.Stop();
- PERF_STOP_METER("TCollection_Queue popping")
- ////////////////////////////////aTClea.Start();
- PERF_START_METER("TCollection_Queue clearing")
- a2.Clear();
- ////////////////////////////////aTClea.Stop();
- PERF_STOP_METER("TCollection_Queue clearing")
- }
- PERF_PRINT_ALL
-}
// ===================== Test perform of Stack type ==========================
void CompStack (const Standard_Integer theRep,
class StackOfReal instantiates Stack from TCollection(Real );
class StackOfTransient instantiates Stack from TCollection(Transient);
---
--- Instantiations Queue (Integer,Real,Transient)
--- *********************************************
---
-class QueueOfInteger instantiates Queue from TCollection(Integer );
-class QueueOfReal instantiates Queue from TCollection(Real );
-class QueueOfTransient instantiates Queue from TCollection(Transient);
-
--
-- Instantiations MapHasher (Integer,Real, Transient, Persistent)
-- **************************************************************
-- - Sequence, HSequence
-- - Set, HSet
-- - List, SList
--- - Stack, Queue
+-- - Stack
-- - BasicMap, BasicMapIterator
-- - Map, DataMap, DoubleMap, IndexedMap, IndexedDataMap
generic class Stack, StackNode, StackIterator;
---Purpose: A stack handled by value.
- generic class Queue, QueueNode;
- ---Purpose: A queue handled by value.
-
generic class List, ListNode, ListIterator;
---Purpose: A single list handled by value.
+++ /dev/null
--- Created on: 1993-01-18
--- Created by: Remi LEQUETTE
--- 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 Queue from TCollection (Item as any)
-
- ---Purpose: A queue is a structure where Items are added at
- -- the end and removed from the front. The first
- -- entered Item will be the first removed. This is
- -- called a FIFO (First In First Out).
- -- Queue is a generic class, which depends on Item, the
- -- type of element in the structure.
-raises
- NoSuchObject from Standard
-
- class QueueNode from TCollection
- inherits MapNode from TCollection
- uses MapNodePtr from TCollection
- is
- Create(I : Item; n : MapNodePtr from TCollection) returns QueueNode from TCollection;
- ---C++: inline
-
- Value(me) returns Item;
- ---C++: return &
- ---C++: inline
-
- fields
- myValue : Item;
- end;
-
-is
- Create returns Queue from TCollection;
- ---Purpose: Creates an empty Queue.
-
- Create(Other : Queue from TCollection)
- returns Queue from TCollection
- ---Purpose: Constructs an empty queue.
- -- Use:
- -- - the function Push to insert an item at the end of the queue,
- -- - the function Front to read the item at the front of the queue,
- -- - the function Pop to remove the item at the front of the queue.
- -- Warning
- -- To copy a queue, you must explicitly call the assignment
- -- operator (operator=). A copy operation is an expensive operation it is
- -- incorrect to do it implicitly. This constructor is private and
- -- will raise a warning if the Queue is not empty.
- -- To copy the content of a Queue use the Assign method (operator =).
- is private;
-
- Assign(me : in out; Other : Queue from TCollection)
- returns Queue from TCollection
- ---Purpose: Copies in this Queue the content of <Other>.
- -- If this queue is not empty, it is automatically cleared before the copy
- ---C++: alias operator =
- ---C++: return const &
- is static;
-
- Length(me) returns Integer
- ---Purpose: Returns the length of the queue.
- -- Example:
- -- before
- -- me = (A B C)
- -- returns 3
- ---C++: inline
- is static;
-
- IsEmpty(me) returns Boolean
- ---Purpose: Returns True if the queue is empty.
- -- i.e. Length() == 0.
- ---C++: inline
- is static;
-
- Front(me) returns any Item
- ---Purpose: returns the item at the front of the queue
- -- Example:
- -- before
- -- me = (A B C)
- -- after
- -- me = (A B C)
- -- returns
- -- A
- -- Trigger: Raises an exception if <me> is Empty
- ---C++: return const &
- raises NoSuchObject from Standard
- is static;
-
-
- Clear(me : in out)
- ---Purpose: remove all the elements from the queue
- -- Example:
- -- before
- -- me = (A B C)
- -- after
- -- me = ()
- ---C++: alias ~
- is static;
-
- Push(me : in out; T : Item)
- ---Purpose: Insert an item at the end of the queue.
- -- Example:
- -- before
- -- me = (A B) , T = C
- -- after
- -- me = (A B C)
- is static;
-
- Pop(me : in out)
- ---Purpose: Removes the item at the front of the queue.
- -- Example:
- -- before
- -- me = (A B C)
- -- after
- -- me = (B C)
- -- Trigger: Raises an exception if <me> is empty.
- raises NoSuchObject from Standard
- is static;
-
- ChangeFront(me: in out) returns any Item
- ---Purpose: Returns a modifiable reference on the front of the queue.
- -- The purpose of this syntax is to modify the item at the front of this queue.
- -- Example:
- -- before
- -- me = (A B C)
- -- me.ChangeFront() = D
- -- after
- -- me = (D B C)
- -- Trigger: Raises an exception if <me> is empty.
- ---C++: return &
- raises NoSuchObject from Standard
- is static;
-
-fields
- myFront : Address from Standard;
- myEnd : Address from Standard;
- myLength : Integer from Standard;
-
-end Queue;
-
-
+++ /dev/null
-// Created on: 1993-01-18
-// Created by: Remi LEQUETTE
-// 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.
-
-#include <Standard_NoSuchObject.hxx>
-
-//=======================================================================
-//function : TCollection_Queue
-//purpose :
-//=======================================================================
-
-TCollection_Queue::TCollection_Queue() :
- myFront(NULL),
- myEnd(NULL),
- myLength(0)
-{
-}
-
-//=======================================================================
-//function : TCollection_Queue
-//purpose :
-//=======================================================================
-
-TCollection_Queue::TCollection_Queue(const TCollection_Queue& Other)
-{
- if (!Other.IsEmpty()) {
- cout << "WARNING copy constructor of non empty Queue !"<<endl;
- }
- TCollection_QueueNode* p = (TCollection_QueueNode*) Other.myFront;
- TCollection_QueueNode* q = NULL;
- TCollection_QueueNode* r = NULL;
- myFront = NULL;
- while (p) {
- q = new TCollection_QueueNode(p->Value(),(TCollection_MapNode*)0L);
- if (r) r->Next() = q;
- else myFront = q;
- r = q;
- p = (TCollection_QueueNode*)p->Next();
- }
- myEnd = q;
- myLength = Other.myLength;
-}
-
-//=======================================================================
-//function : Assign
-//purpose :
-//=======================================================================
-
-const TCollection_Queue& TCollection_Queue::Assign
- (const TCollection_Queue& Other)
-{
- if (this == &Other) return *this;
- Clear();
- TCollection_QueueNode* p = (TCollection_QueueNode*) Other.myFront;
- TCollection_QueueNode* q=NULL;
- TCollection_QueueNode* r = NULL;
- while (p) {
- q = new TCollection_QueueNode(p->Value(),(TCollection_MapNode*)0L);
- if (r) r->Next() = q;
- else myFront = q;
- r = q;
- p = (TCollection_QueueNode*)p->Next();
- }
- myEnd = q;
- myLength = Other.myLength;
- return *this;
-}
-
-
-
-//=======================================================================
-//function : Front
-//purpose :
-//=======================================================================
-
-const Item& TCollection_Queue::Front() const
-{
- Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_Queue");
- return ((TCollection_QueueNode*)myFront)->Value();
-}
-
-//=======================================================================
-//function : Push
-//purpose :
-//=======================================================================
-
-void TCollection_Queue::Push(const Item& I)
-{
- TCollection_QueueNode* p = new TCollection_QueueNode(I,(TCollection_MapNode*)0L);
- if (myLength) ((TCollection_QueueNode*)myEnd)->Next() = p;
- else myFront = p;
- myEnd = p;
- myLength++;
-}
-
-//=======================================================================
-//function : Pop
-//purpose :
-//=======================================================================
-
-void TCollection_Queue::Pop()
-{
- Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_Queue");
- TCollection_QueueNode* p = (TCollection_QueueNode*) myFront;
- myFront = p->Next();
- delete p;
- myLength--;
- if (myLength == 0) myEnd = NULL;
-}
-
-//=======================================================================
-//function : Clear
-//purpose :
-//=======================================================================
-
-void TCollection_Queue::Clear()
-{
- TCollection_QueueNode* p = (TCollection_QueueNode*) myFront;
- TCollection_QueueNode* q = 0L;
- while(p) {
- q = (TCollection_QueueNode*)p->Next();
- delete p;
- p = q;
- }
- myLength = 0;
- myFront = myEnd = NULL;
-}
-
-//=======================================================================
-//function : ChangeFront
-//purpose :
-//=======================================================================
-
-Item& TCollection_Queue::ChangeFront()
-{
- Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_Queue");
- return ((TCollection_QueueNode*)myFront)->Value();
-}
-
+++ /dev/null
-// Created on: 1993-01-18
-// Created by: Remi LEQUETTE
-// 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.
-
-//=======================================================================
-//function : Length
-//purpose :
-//=======================================================================
-
-inline Standard_Integer TCollection_Queue::Length() const
-{
- return myLength;
-}
-
-
-//=======================================================================
-//function : IsEmpty
-//purpose :
-//=======================================================================
-
-inline Standard_Boolean TCollection_Queue::IsEmpty() const
-{
- return myLength == 0;
-}
+++ /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.
+++ /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_QueueNode::TCollection_QueueNode(const Item& I,const TCollection_MapNodePtr& n)
-: TCollection_MapNode(n)
-{
- myValue = I;
-}
-
-inline Item& TCollection_QueueNode::Value() const
-{
- return (Item&)myValue;
-}
-