1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0024742: Remove rarely used collection classes: Queue

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).
This commit is contained in:
dln
2014-04-04 13:15:11 +04:00
committed by abv
parent b439bc5856
commit 3125ebb6f3
22 changed files with 23 additions and 746 deletions

View File

@@ -23,7 +23,7 @@
-- - Sequence, HSequence
-- - Set, HSet
-- - List, SList
-- - Stack, Queue
-- - Stack
-- - BasicMap, BasicMapIterator
-- - Map, DataMap, DoubleMap, IndexedMap, IndexedDataMap
@@ -55,9 +55,6 @@ is
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.

View File

@@ -1,151 +0,0 @@
-- 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;

View File

@@ -1,151 +0,0 @@
// 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();
}

View File

@@ -1,36 +0,0 @@
// 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;
}

View File

@@ -1,13 +0,0 @@
// 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.

View File

@@ -1,25 +0,0 @@
// 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;
}