1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

4
src/TCollection/FILES Executable file
View File

@@ -0,0 +1,4 @@
TCollection_Compare.gxx
TCollection_AVLNode.hxx
TCollection_CMPLRS.edl
TCollection_WOKSteps.edl

142
src/TCollection/TCollection.cdl Executable file
View File

@@ -0,0 +1,142 @@
-- File: TCollection.cdl
-- Created: Tue Oct 13 18:49:35 1992
-- Author: Ramin BARRETO
-- <rba@sdsun4>
-- Updated J.P. TIRAULT, M. MERCIEN Nov,25 1992
-- Adding classes
-- - Array1Descriptor
-- - Array2Descriptor
-- - Array1
-- - Array2
-- Updated R.LEQUETTE Jan 1993
-- Adding of modifying classes
-- - Sequence, HSequence
-- - Set, HSet
-- - List, SList
-- - Stack, Queue
-- - BasicMap, BasicMapIterator
-- - Map, DataMap, DoubleMap, IndexedMap, IndexedDataMap
--
---Copyright: Matra Datavision 1992
package TCollection
---Purpose: The package <TCollection> provides the services for the
-- transient basic data structures.
uses
Standard,
MMgt
is
class AsciiString;
class ExtendedString;
class HAsciiString;
class HExtendedString;
deferred class Array1Descriptor;
generic class Array1;
generic class HArray1;
deferred class Array2Descriptor;
generic class Array2;
generic class HArray2;
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.
generic class SList,SListNode;
---Purpose: A LISP like sharable list.
class BaseSequence;
class SeqNode;
pointer SeqNodePtr to SeqNode from TCollection;
generic class Sequence,SequenceNode;
---Purpose: An indexed double list handled by value.
generic class HSequence;
---Purpose: An indexed double list handle by reference.
generic class Set, SetIterator, SetList;
---Purpose: A small set handled by value.
generic class HSet;
---Purpose: A small set handled by reference.
generic class MapHasher;
---Purpose: A Tool to instantiate Maps. Providing HashCode and
-- Comparisons on Keys.
private deferred class BasicMap;
private class MapNode;
pointer MapNodePtr to MapNode from TCollection;
---Purpose: Basic class root of all the Maps.
private deferred class BasicMapIterator;
---Purpose: Basic class root of all the Iterators on Maps.
generic class Map, MapIterator,StdMapNode;
---Purpose: A Hashed map to store keys.
generic class DataMap, DataMapIterator,DataMapNode;
---Purpose: A Map where data can be stored with the keys.
generic class DoubleMap, DoubleMapIterator, DoubleMapNode;
---Purpose: A Map to store pair of keys.
generic class IndexedMap,IndexedMapNode;
---Purpose: A Map where the keys are indexed.
generic class IndexedDataMap,IndexedDataMapNode;
---Purpose: An Indexed Map where data can be stored with the keys.
enumeration Side is Left , Right;
deferred generic class Compare ;
---Purpose: Defines a comparison operator which can be used by
-- any ordered structure. The way to compare items
-- has to be described in subclasses, which herit
-- from instantiations of Compare.
private deferred class PrivCompareOfInteger
instantiates Compare from TCollection(Integer from Standard);
private deferred class PrivCompareOfReal
instantiates Compare from TCollection(Real from Standard);
class CompareOfInteger;
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
-- to dimension a Map. When <I> becomes great there
-- is a limit on the result (today the limit is
-- around 1 000 000). This is not a limit of the number of
-- items but a limit in the number of buckets. i.e.
-- there will be more collisions in the map.
end TCollection;

45
src/TCollection/TCollection.cxx Executable file
View File

@@ -0,0 +1,45 @@
// File: TCollection.cxx
// Created: Thu Jan 14 16:15:39 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <TCollection.ixx>
// The array of prime numbers used as consequtive steps for
// size of array of buckets in the map.
//
// The prime numbers are used for array size with the hope that this will
// lead to less probablility of having the same hash codes for
// different map items (note that all hash codes are modulo that size).
//
// The value of each next step is chosen to be ~2 times greater than previous.
// Though this could be thought as too much, actually the amount of
// memory overhead in that case is only ~15% as compared with total size of
// all auxiliary data structures (each map node takes ~24 bytes),
// and this proves to pay off in performance (see OCC13189).
#define NB_PRIMES 12
static const Standard_Integer Primes[NB_PRIMES+1] = {
101,
1009,
2003,
5003,
10007,
20011,
37003,
57037,
65003,
100019,
209953, // The following are Pierpont primes taken from Wikipedia [List of prime numbers]
472393,
995329
};
Standard_Integer TCollection::NextPrimeForMap(const Standard_Integer N)
{
Standard_Integer i;
for (i = 0; i < NB_PRIMES; i++)
if (Primes[i] > N) break;
return Primes[i];
}

View File

@@ -0,0 +1,39 @@
-- File: TCollection_AVLBaseNode.cdl
-- Created: Wed Jan 21 15:32:50 1998
-- Author: Kernel
-- <kernel@parigox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
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;

View File

@@ -0,0 +1,27 @@
#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);
}

View File

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

View File

@@ -0,0 +1,94 @@
// Copyright: Matra-Datavision 1991
// File: TCollection_AVLSearchTree.gxx
// Created: Thu May 23 16:57:42 1991
// Author: Jean-Pierre TIRAULT
// 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;
}

View File

@@ -0,0 +1,5 @@
#include <Standard_NoSuchObject.hxx>
inline Standard_Boolean TCollection_AVLIterator::More () const {
return HasMore;
}

View File

@@ -0,0 +1 @@

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,402 @@
-- File: AVLSearchTree.cdl
-- Created: Tue May 21 17:43:21 1991
-- Author: Annick PANCHER
-- <apc@topsn2>
-- Revised: Mireille MERCIEN
-- <jpt@sdsun3>
-- 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.
---Copyright: Matra Datavision 1992,1993
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;

View File

@@ -0,0 +1,568 @@
// Copyright: Matra-Datavision 1991
// File: TCollection_AVLSearchTree.gxx
// Created: Thu May 23 16:57:42 1991
// Author: Jean-Pierre TIRAULT
// 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;
}

View File

@@ -0,0 +1,41 @@
//-----------------------------------------------------------------------------
//
// inline methods for AVLSearchTree
//
// Author : J.P. TIRAULT
//-----------------------------------------------------------------------------
#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;
}

View File

@@ -0,0 +1,160 @@
generic class Array1 from TCollection (Array1Item as any)
raises RangeError from Standard,
DimensionMismatch from Standard,
OutOfRange from Standard,
OutOfMemory from Standard
---Purpose: The class Array1 represents unidimensionnal arrays
-- of fixed size dynamically dimensioned at construction time..
--
-- The range of the index is user defined.
--
-- As with a C array, the access time to an Array1
-- indexed item is constant and is
-- array-size-independent. Arrays are commonly
-- used as elementary data structures for more complex objects.
-- Array1 is a generic class, which depends on
-- Item, the type of element in the array.
-- An array1 can be constructed with a "C array".
-- This functionality is useful to call methods expecting
-- an Array1. It allows to carry the bounds inside the arrays.
--
-- Examples: Item tab[100]; // An example with a C array
-- Array1OfItem ttab (tab[0],1,100);
--
-- Array1OfItem tttab (ttab(10),10,20); // a slice of ttab
--
-- If you want to reindex an array from 1 to Length do :
--
-- Array1 tab1(tab(tab.Lower()),1,tab.Length());
--
-- Warning: Programs client of such a class must be independant
-- of the range of the first element. Then, a C++ for
-- loop must be written like this
--
-- for (i = A.Lower(); i <= A.Upper(); i++)
is
Create (Low, Up: Integer from Standard)
returns Array1 from TCollection
---Purpose: Creates an array of lower bound <Low> and upper
-- bound <Up>. Range error is raised when <Up> is
-- less than <Low>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Create(Item : Array1Item;
Low, Up: Integer from Standard)
returns Array1 from TCollection
---Purpose: Creates an array sharing datas with a C array.
-- Example:
-- Item tab[100];
-- Array1OfItem thetab (tab[0],1,100);
--
-- Warning: The validity of Low and Up values are under the responsability
-- of the user.
-- The C array must be a validate address during the life of
-- the Array1.
raises
RangeError from Standard;
Init (me: in out; V: Array1Item);
---Purpose: Initializes the array with a given value.
Destroy (me: in out);
---Purpose: Frees the allocated area corresponding to the
-- array. If the array was constructed either from a
-- C Array (when method Allocated returns False)
-- the Destroy doesn't delete the area.
--
---C++: alias ~
IsAllocated (me) returns Boolean from Standard;
---Purpose: Returns True if the data was allocated by the array constructors.
-- (i.e not a slice neither a C array)
---C++: inline
Assign (me: in out; Other: Array1 from TCollection)
returns Array1 from TCollection
---Purpose: Copies the contents of <Other> into <me>. <Other>
-- and <me> must have the same dimension.
-- This method is an alias of operator =.
-- Example
-- TColStd_Array1OfInteger
-- t1(1,20), t2(1,20);
-- t1.Init(3);
-- t2 = t1;
-- assert ( t2(10) == 3 );
-- Exceptions
-- Standard_DimensionMismatch if this array
-- and array Other do not have the same dimension.
---C++: alias operator =
---C++: return const &
raises DimensionMismatch from Standard;
Length (me) returns Integer from Standard;
---Purpose: Returns the number of elements of <me>.
--
---C++: inline
Lower (me) returns Integer from Standard;
---Purpose: Returns the lower bound.
-- Warning
--Client programs of the Array1 class must be independent of the first item range.--
---C++: inline
Upper (me) returns Integer from Standard;
---Purpose: Returns the upper bound.
-- Warning
--Client programs of the Array1 class must be independent of the first item range.--
---C++: inline
SetValue (me : out; Index: Integer from Standard; Value: Array1Item)
---Purpose: Assigns the value <Value> to the <Index>-th item of this array.
-- Example
-- TColStd_Array1OfInteger
-- array(0,100);
-- array.SetValue(3,1515);
-- assert (array(3) == 1515 );
-- Exceptions
-- Standard_OutOfRange if Index lies outside the bounds of this array.
---C++: inline
raises OutOfRange from Standard;
Value (me; Index:Integer from Standard) returns any Array1Item
---Purpose: Return the value of the <Index>th element of the
-- array.
--
---C++: alias operator ()
---C++: return const &
---C++: inline
raises OutOfRange from Standard;
ChangeValue (me: in out; Index:Integer from Standard) returns any Array1Item
---Purpose: return the value of the <Index>th element of the
-- array.
--
---C++: alias operator ()
---C++: return &
---C++: inline
raises OutOfRange from Standard;
Create (AnArray : Array1 from TCollection)
returns Array1 from TCollection
is private;
---Purpose: Creates an Array1 by copy of an Array1.
fields
myLowerBound : Integer;
myUpperBound : Integer;
myStart : Address;
isAllocated : Boolean;
end Array1 ;

View File

@@ -0,0 +1,107 @@
#include <Standard_DimensionMismatch.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard.hxx>
// ###### REFERENCER LE STORAGE MANAGER DES COLLECTIONS ######
//=======================================================================
//function : TCollection_Array1
//purpose :
//=======================================================================
TCollection_Array1::TCollection_Array1 (const Standard_Integer Low,
const Standard_Integer Up) :
myLowerBound(Low),
myUpperBound(Up),
isAllocated(Standard_True)
{
Standard_RangeError_Raise_if(Up < Low,"TCollection_Array1::Create");
Array1Item* p = 0;
#ifdef __OPTIM_ARRAY
// p = new char [(Up-Low+1)*sizeof (Array1Item)];
p = (Array1Item *)Standard::Allocate((Up-Low+1)*sizeof (Array1Item));
#else
p = new Array1Item[Up-Low+1];
#endif
if (!p) Standard_OutOfMemory::Raise("Array1 : Allocation failed");
myStart = (void*)(p - myLowerBound);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TCollection_Array1::Init (const Array1Item& V) {
Array1Item* p = &ChangeValue(myLowerBound);
Standard_Integer i;
for(i = myLowerBound; i <= myUpperBound; i++) {
*p++ = V;
}
}
//=======================================================================
//function : TCollection_Array1
//purpose : C Array constructor
//=======================================================================
TCollection_Array1::TCollection_Array1(const Array1Item& AnItem,
const Standard_Integer Low,
const Standard_Integer Up) :
myLowerBound(Low),
myUpperBound(Up),
isAllocated(Standard_False)
{
Standard_RangeError_Raise_if(Up < Low,"Array1::CArray");
myStart = (void*)( &AnItem - Low );
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void TCollection_Array1::Destroy()
{
if (isAllocated) {
#ifdef __OPTIM_ARRAY
Standard_Address it = (Standard_Address)&((Array1Item *)myStart)[myLowerBound];
Standard::Free(it);
#else
delete [] &ChangeValue(myLowerBound);
#endif
}
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
const TCollection_Array1& TCollection_Array1::Assign
(const TCollection_Array1& Right)
{
if (&Right != this) {
Standard_Integer max = Length() ;
Standard_DimensionMismatch_Raise_if(max != Right.Length(),
"DimensionMismatch in Array1::Operator=");
Array1Item* p = &ChangeValue(myLowerBound);
const Array1Item* q = &Right.Value(Right.Lower());
for (Standard_Integer i=0; i<max; i++){
*p++ = *q++;
}
}
return *this;
}

View File

@@ -0,0 +1,87 @@
#include <Standard_OutOfRange.hxx>
#include Array1Item_hxx
//=======================================================================
//function : Length
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array1::Length () const
{
return myUpperBound - myLowerBound + 1 ;
}
//=======================================================================
//function : Lower
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array1::Lower () const
{
return myLowerBound ;
}
//=======================================================================
//function : Upper
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array1::Upper () const
{
return myUpperBound ;
}
//=======================================================================
//function : IsAllocated
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_Array1::IsAllocated () const
{
return isAllocated;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
inline const Array1Item& TCollection_Array1::Value
(const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if((Index < myLowerBound || Index > myUpperBound),NULL);
return ((Array1Item *)myStart)[Index];
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
inline void TCollection_Array1::SetValue (const Standard_Integer Index,
const Array1Item& Value)
{
Standard_OutOfRange_Raise_if((Index < myLowerBound || Index > myUpperBound),NULL);
((Array1Item *)myStart)[Index] = Value ;
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
inline Array1Item& TCollection_Array1::ChangeValue(const Standard_Integer Index)
{
Standard_OutOfRange_Raise_if((Index < myLowerBound || Index > myUpperBound),NULL);
return ((Array1Item *)myStart)[Index];
}

View File

@@ -0,0 +1,30 @@
-- File: TCollection_Array1Descriptor.cdl
-- Created: Wed Nov 25 10:02:32 1992
-- Author: Jean Pierre TIRAULT
-- <jpt@sdsun3>
---Copyright: Matra Datavision 1992
deferred class Array1Descriptor from TCollection
uses
Integer from Standard,
Address from Standard
is
Initialize (aLower: Integer; aUpper: Integer; anAddress: Address);
Upper (me) returns Integer;
---Level: Advanced
Lower (me) returns Integer;
---Level: Advanced
Address(me) returns Address;
---Level: Advanced
fields
myAddress: Address;
myLower : Integer;
myUpper : Integer;
end;

View File

@@ -0,0 +1,38 @@
//
//
//
#include <TCollection_Array1Descriptor.ixx>
// ---------------------------------------------------------------------
TCollection_Array1Descriptor::TCollection_Array1Descriptor
(const Standard_Integer Lower,
const Standard_Integer Upper,
const Standard_Address anAddress
)
{
myLower = Lower;
myUpper = Upper;
myAddress= anAddress;
}
// ---------------------------------------------------------------------
Standard_Integer TCollection_Array1Descriptor::Upper() const
{
return myUpper;
}
// ---------------------------------------------------------------------
Standard_Integer TCollection_Array1Descriptor::Lower() const
{
return myLower;
}
// ---------------------------------------------------------------------
Standard_Address TCollection_Array1Descriptor::Address() const
{
return myAddress;
}

View File

@@ -0,0 +1,172 @@
-- File: TCollection_Array2.cdl
-- Created: Wed Dec 9 12:22:03 1992
---Copyright: Matra Datavision 1992
generic class Array2 from TCollection (Array2Item as any)
---Purpose: The class Array2 represents bi-dimensionnal arrays
-- of fixed size dynamically dimensioned at construction time.
-- As with a C array, the access time to an Array2 indexed
-- item is constant and independent of the array size. Arrays
-- are commonly used as elementary data structures for more complex objects.
-- Array2 is a generic class, which depends on Item, the type of element in the array.
-- Warning
-- Array2 indexes start and end at a user-defined position.
-- Thus, when accessing an item you must base the indexes
-- on the lower and upper bounds of the array.
raises
RangeError from Standard,
OutOfRange from Standard,
OutOfMemory from Standard,
DimensionMismatch from Standard
is
Create (R1, R2, C1, C2: Integer from Standard)
returns Array2 from TCollection
---Purpose: Creates an array of lower bound <R1><C1> and upper
-- bound <R2><C2>. Range from Standard error is
-- raised when <R2> is less than <R1> or <C2> is less
-- than <C1>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Create (AnArray : Array2)
returns Array2 from TCollection
---Purpose: creates an Array2 by copy of an Array2.
raises OutOfMemory from Standard is private ;
Create (Item : Array2Item; R1, R2, C1, C2: Integer from Standard)
returns Array2 from TCollection
---Purpose: Creates an double array sharing datas with a C array.
-- Examples:
-- Item tab[100][200];
-- Array2OfItem thetab (tab[0][0],1,100,1,200);
-- or
-- Item tab[10000];
-- Array2OfItem thetab (tab[0],1,100,1,100);
--
-- Warning: The validity of R1,R2,C1,C2 values are under the responsability
-- of the user.
-- The C array must be a validate address during the life of
-- the Array2.
raises
RangeError from Standard,
OutOfMemory from Standard;
Init(me : in out; V : Array2Item);
---Purpose: Initializes this array with the value <Value>.
Destroy (me : in out );
---Level: Advanced
---Purpose: Frees the allocated area corresponding to the
-- array. If the array was constructed from a
-- DoubleArray the Destroy doesn't delete the area.
--
---C++: alias ~
Assign (me: in out; Other: Array2)
returns Array2 from TCollection
---Purpose: Copies the contents of <Other> into <me>.
-- <Other> and <me> must have the same dimension.
-- Example
-- TColStd_Array2OfInteger tab1(1,10,1,10);
-- TColStd_Array2OfInteger tab2(11,20,11,20);
-- tab1.Init(4);
-- tab2 = tab1;
-- assert ( tab2(15,15) == 4 );
-- Exceptions
-- Standard_DimensionMismatch if this array and array
-- Other do not have the same dimensions.
---C++: alias operator =
---C++: return const &
raises DimensionMismatch from Standard;
ColLength (me) returns Integer from Standard;
---Level: Public
---Purpose: Return the number of rows of <me>.
--
---C++: inline
RowLength (me) returns Integer from Standard;
---Level: Public
---Purpose: Returns the number of columns of <me>.
--
---C++: inline
LowerCol (me) returns Integer from Standard;
---Level: Public
---Purpose: Returns the lower column number of the array.
--
---C++: inline
LowerRow (me) returns Integer from Standard;
---Level: Public
---Purpose: Returns the lower row number of the array.
--
---C++: inline
UpperCol (me) returns Integer from Standard;
---Level: Public
---Purpose: Returns the upper column number of the array.
--
---C++: inline
UpperRow (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the upper row number of the array.
--
---C++: inline
is static ;
SetValue (me : in out; Row, Col: Integer from Standard; Value: Array2Item)
---Purpose: Purpose
-- Assigns the value Value to the (Row,Col) item of this array.
-- Example
-- TColStd_Array2OfInteger array(0,100,0,100);
-- array.SetValue(3,3,1515);
-- assert ( array(3,3) == 1515 );
-- Exceptions
-- Standard_OutOfRange if Row or Col lies outside the bounds of this array.
---C++: inline
raises OutOfRange from Standard;
Value (me; Row,Col: Integer from Standard) returns any Array2Item
---Level: Public
---Purpose: Returns the value of the element of index
-- <Row><Col>
--
---C++: alias operator()
---C++: return const &
---C++: inline
raises OutOfRange from Standard;
ChangeValue (me: in out; Row,Col: Integer from Standard) returns any Array2Item
---Level: Public
---Purpose: Returns the value of the element of index
-- <Row><Col>
--
---C++: alias operator()
---C++: return &
---C++: inline
raises OutOfRange from Standard;
Allocate (me: in out) raises OutOfMemory is private;
---Level: Private
fields
myLowerRow : Integer from Standard ;
myLowerColumn : Integer from Standard ;
myUpperRow : Integer from Standard ;
myUpperColumn : Integer from Standard ;
myDeletable : Boolean;
myData : Address;
end Array2 ;

View File

@@ -0,0 +1,152 @@
#include <Standard_DimensionMismatch.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard.hxx>
//=======================================================================
//function : Allocate
//purpose : Allocate memory for the array, set up indirection table
//=======================================================================
void TCollection_Array2::Allocate ()
{
Standard_Integer RowSize = myUpperColumn-myLowerColumn+1;
Standard_Integer ColumnSize = myUpperRow-myLowerRow+1;
if (myDeletable) {
// allocation of the data in the array
Standard_Integer Size = RowSize * ColumnSize;
// Modified by Sergey KHROMOV - Mon Feb 10 11:46:14 2003 Begin
// Standard_RangeError_Raise_if(( RowSize < 0 || ColumnSize < 0 ),
// "TCollection_Array2::Create");
Standard_RangeError_Raise_if(( RowSize <= 0 || ColumnSize <= 0 ),
"TCollection_Array2::Create");
// Modified by Sergey KHROMOV - Mon Feb 10 11:46:15 2003 End
#ifdef __OPTIM_ARRAY
myData = Standard::Allocate(Size*sizeof (Array2Item));
// myData = (Array2Item *) new char [Size * sizeof (Array2Item)];
#else
myData = new Array2Item [Size];
#endif
if (!myData) Standard_OutOfMemory::Raise("Array2 : Allocation failed");
}
// allocation of the indirection table (pointers on rows)
Array2Item* p = (Array2Item*) myData;
Array2Item** q = (Array2Item**)Standard::Allocate(ColumnSize * sizeof(Array2Item*));
for (Standard_Integer i = 0; i < ColumnSize; i++) {
q[i] = p - myLowerColumn;
p += RowSize;
}
myData = (void*) (q - myLowerRow);
}
//=======================================================================
//function : TCollection_Array2
//purpose :
//=======================================================================
TCollection_Array2::TCollection_Array2 (const Standard_Integer R1,
const Standard_Integer R2,
const Standard_Integer C1,
const Standard_Integer C2) :
myLowerRow(R1),
myLowerColumn(C1),
myUpperRow(R2),
myUpperColumn(C2),
myDeletable(Standard_True)
{
Allocate ();
}
//=======================================================================
//function : TCollection_Array2
//purpose : User allocated data
//=======================================================================
TCollection_Array2::TCollection_Array2 (const Array2Item& Item,
const Standard_Integer R1,
const Standard_Integer R2,
const Standard_Integer C1,
const Standard_Integer C2) :
myLowerRow(R1),
myLowerColumn(C1),
myUpperRow(R2),
myUpperColumn(C2),
myDeletable(Standard_False),
myData((void*)&Item)
{
Allocate ();
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TCollection_Array2::Init (const Array2Item& V)
{
Standard_Integer Size = RowLength() * ColLength();
Array2Item* p = &(ChangeValue(myLowerRow,myLowerColumn));
for (Standard_Integer I = 0; I < Size ; I++) p[I] = V;
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void TCollection_Array2::Destroy ()
{
Array2Item** anItemPtr = ((Array2Item**)myData + myLowerRow);
// delete the data
//
if (myDeletable)
#ifdef __OPTIM_ARRAY
{
Standard_Integer RowSize = myUpperColumn-myLowerColumn+1;
Standard_Integer ColumnSize = myUpperRow-myLowerRow+1;
Standard_Integer Size = RowSize * ColumnSize;
Standard_Address it = (Standard_Address)&((Array2Item **)myData)[myLowerRow][myLowerColumn];
Standard::Free(it);
}
#else
delete [] &ChangeValue(myLowerRow,myLowerColumn);
#endif
// delete the indirection table
Standard::Free((void*&)anItemPtr);
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
const TCollection_Array2& TCollection_Array2::Assign
(const TCollection_Array2& Right)
{
Standard_Integer MaxColumn = RowLength() ;
Standard_Integer MaxRow = ColLength() ;
Standard_Integer MaxSize = MaxColumn * MaxRow;
Standard_DimensionMismatch_Raise_if(MaxRow != Right.ColLength() ||
MaxColumn != Right.RowLength(),
"Array2::Operator=");
Array2Item* p = &ChangeValue(myLowerRow,myLowerColumn);
const Array2Item* q = &Right.Value(Right.LowerRow(),Right.LowerCol());
for (Standard_Integer i=0; i<MaxSize; i++) {
p[i] = q[i];
}
return *this;
}

View File

@@ -0,0 +1,105 @@
#include <Standard_OutOfRange.hxx>
#include Array2Item_hxx
//=======================================================================
//function : ColLength
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array2::ColLength () const
{
return myUpperRow - myLowerRow + 1 ;
}
//=======================================================================
//function : LowerCol
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array2::LowerCol () const
{
return myLowerColumn ;
}
//=======================================================================
//function : LowerRow
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array2::LowerRow () const
{
return myLowerRow;
}
//=======================================================================
//function : RowLength
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array2::RowLength () const
{
return myUpperColumn - myLowerColumn + 1 ;
}
//=======================================================================
//function : UpperRow
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array2::UpperRow () const
{
return myUpperRow ;
}
//=======================================================================
//function : UpperCol
//purpose :
//=======================================================================
inline Standard_Integer TCollection_Array2::UpperCol () const
{
return myUpperColumn ;
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
inline void TCollection_Array2::SetValue ( const Standard_Integer Row,
const Standard_Integer Col,
const Array2Item& Value )
{
Standard_OutOfRange_Raise_if((Row < myLowerRow || Row > myUpperRow ||
Col < myLowerColumn || Col > myUpperColumn),
NULL);
((Array2Item **)myData)[Row][Col] = Value ;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
inline const Array2Item& TCollection_Array2::Value(const Standard_Integer Row,
const Standard_Integer Col) const
{
Standard_OutOfRange_Raise_if((Row < myLowerRow || Row > myUpperRow ||
Col < myLowerColumn || Col > myUpperColumn),
NULL);
return ((Array2Item **)myData)[Row][Col];
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
inline Array2Item& TCollection_Array2::ChangeValue(const Standard_Integer Row,
const Standard_Integer Col)
{
Standard_OutOfRange_Raise_if((Row < myLowerRow || Row > myUpperRow ||
Col < myLowerColumn || Col > myUpperColumn),
NULL);
return ((Array2Item **)myData)[Row][Col];
}

View File

@@ -0,0 +1,41 @@
-- File: TCollection_Array1Descriptor.cdl
-- Created: Wed Nov 25 10:02:32 1992
-- Author: Jean Pierre TIRAULT
-- <jpt@sdsun3>
---Copyright: Matra Datavision 1992
deferred class Array2Descriptor from TCollection
uses
Integer from Standard,
Address from Standard
is
Initialize (aLowerRow: Integer; aUpperRow: Integer;
aLowerCol: Integer; aUpperCol: Integer;
anAddress: Address);
UpperRow (me) returns Integer;
---Level: Advanced
LowerRow (me) returns Integer;
---Level: Advanced
UpperCol (me) returns Integer;
---Level: Advanced
LowerCol (me) returns Integer;
---Level: Advanced
Address(me) returns Address;
---Level: Advanced
fields
myAddress : Address;
myLowerRow : Integer;
myLowerCol : Integer;
myUpperRow : Integer;
myUpperCol : Integer;
end;

View File

@@ -0,0 +1,55 @@
//
//
//
#include <TCollection_Array2Descriptor.ixx>
// ---------------------------------------------------------------------
TCollection_Array2Descriptor::TCollection_Array2Descriptor
(const Standard_Integer aLowerRow,
const Standard_Integer aUpperRow,
const Standard_Integer aLowerCol,
const Standard_Integer aUpperCol,
const Standard_Address anAddress
)
{
myLowerRow = aLowerRow;
myUpperRow = aUpperRow;
myLowerCol = aLowerCol;
myUpperCol = aUpperCol;
myAddress = anAddress;
}
// ---------------------------------------------------------------------
Standard_Integer TCollection_Array2Descriptor::UpperRow() const
{
return myUpperRow;
}
// ---------------------------------------------------------------------
Standard_Integer TCollection_Array2Descriptor::LowerRow() const
{
return myLowerRow;
}
// ---------------------------------------------------------------------
Standard_Integer TCollection_Array2Descriptor::UpperCol() const
{
return myUpperCol;
}
// ---------------------------------------------------------------------
Standard_Integer TCollection_Array2Descriptor::LowerCol() const
{
return myLowerCol;
}
// ---------------------------------------------------------------------
Standard_Address TCollection_Array2Descriptor::Address() const
{
return myAddress;
}

View File

@@ -0,0 +1,850 @@
-- File: TCollection_AsciiString.cdl
-- Created: Mon Feb 22 16:57:04 1993
-- Author: Mireille MERCIEN
-- <mip@sdsun4>
---Copyright: Matra Datavision 1993
class AsciiString from TCollection
---Purpose: A variable-length sequence of ASCII characters
-- (normal 8-bit character type). It provides editing
-- operations with built-in memory management to
-- make AsciiString objects easier to use than
-- ordinary character arrays.
-- AsciiString objects follow value semantics; in
-- other words, they are the actual strings, not
-- handles to strings, and are copied through
-- assignment. You may use HAsciiString objects
-- to get handles to strings.
uses ExtendedString from TCollection
raises
NullObject,
OutOfRange,
NumericError,
NegativeValue
is
Create returns AsciiString from TCollection;
---Purpose: Initializes a AsciiString to an empty AsciiString.
Create ( message : CString ) returns AsciiString from TCollection
---Purpose: Initializes a AsciiString with a CString.
raises NullObject;
Create ( message : CString ; aLen : Integer )
returns AsciiString from TCollection
---Purpose: Initializes a AsciiString with a CString.
raises NullObject;
Create ( aChar : Character) returns AsciiString from TCollection;
---Purpose: Initializes a AsciiString with a single character.
Create ( length : Integer; filler : Character)
returns AsciiString from TCollection;
---Purpose: Initializes an AsciiString with <length> space allocated.
-- and filled with <filler>. This is usefull for buffers.
Create ( value : Integer ) returns AsciiString from TCollection
---Purpose: Initializes an AsciiString with an integer value
raises NullObject;
Create ( value : Real ) returns AsciiString from TCollection
---Purpose: Initializes an AsciiString with a real value
raises NullObject;
Create ( astring : AsciiString from TCollection )
returns AsciiString from TCollection;
---Purpose: Initializes a AsciiString with another AsciiString.
Create ( astring : AsciiString from TCollection ; message : Character )
returns AsciiString from TCollection;
---Purpose: Initializes a AsciiString with copy of another AsciiString
-- concatenated with the message character.
Create ( astring : AsciiString from TCollection ; message : CString )
returns AsciiString from TCollection;
---Purpose: Initializes a AsciiString with copy of another AsciiString
-- concatenated with the message string.
Create ( astring : AsciiString from TCollection ; message : AsciiString )
returns AsciiString from TCollection;
---Purpose: Initializes a AsciiString with copy of another AsciiString
-- concatenated with the message string.
Create(astring : ExtendedString from TCollection;
replaceNonAscii: Character from Standard = 0)
---Purpose: Creation by converting an extended string to an ascii string.
-- If replaceNonAscii is non-null charecter, it will be used
-- in place of any non-ascii character found in the source string.
-- Otherwise, raises OutOfRange exception if at least one character
-- in the source string is not in the "Ascii range".
returns AsciiString from TCollection
raises OutOfRange from Standard;
AssignCat (me : out ; other : Character )
---Level: Public
---Purpose: Appends <other> to me. This is an unary operator.
---C++: alias operator +=
raises NullObject from Standard
is static;
AssignCat (me : out ; other : Integer from Standard )
---Level: Public
---Purpose: Appends <other> to me. This is an unary operator.
---C++: alias operator +=
raises NullObject from Standard
is static;
AssignCat (me : out ; other : Real from Standard )
---Level: Public
---Purpose: Appends <other> to me. This is an unary operator.
---C++: alias operator +=
raises NullObject from Standard
is static;
AssignCat (me : out ; other : CString)
---Level: Public
---Purpose: Appends <other> to me. This is an unary operator.
-- ex: aString += "Dummy"
-- To catenate more than one CString, you must put a
-- AsciiString before.
-- Example: aString += "Hello " + "Dolly" IS NOT VALID !
-- But astring += anotherString + "Hello " + "Dolly" is valid.
---C++: alias operator +=
raises NullObject from Standard
is static;
AssignCat (me : out ; other : AsciiString from TCollection)
---Level: Public
---Purpose: Appends <other> to me. This is an unary operator.
-- Example: aString += anotherString
---C++: alias operator +=
is static;
Capitalize(me : out)
---Level: Public
---Purpose: Converts the first character into its corresponding
-- upper-case character and the other characters into lowercase
-- Example: before
-- me = "hellO "
-- after
-- me = "Hello "
is static;
-- Cat(me; other : CString from Standard; result : out AsciiString from TCollection )
-- is private;
Cat (me ; other : Character from Standard) returns AsciiString from TCollection
---Level: Public
---Purpose: Appends <other> to me.
-- Syntax:
-- aString = aString + "Dummy"
-- Example: aString contains "I say "
-- aString = aString + "Hello " + "Dolly"
-- gives "I say Hello Dolly"
-- To catenate more than one CString, you must put a String before.
-- So the following example is WRONG !
-- aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
-- This rule is applicable to AssignCat (operator +=) too.
---C++: alias operator +
---C++: inline
raises NullObject from Standard
is static;
Cat (me ; other : Integer from Standard) returns AsciiString from TCollection
---Level: Public
---Purpose: Appends <other> to me.
-- Syntax:
-- aString = aString + 15;
-- Example: aString contains "I say "
-- gives "I say 15"
-- To catenate more than one CString, you must put a String before.
-- So the following example is WRONG !
-- aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
-- This rule is applicable to AssignCat (operator +=) too.
---C++: alias operator +
---C++: inline
raises NullObject from Standard
is static;
Cat (me ; other : Real from Standard) returns AsciiString from TCollection
---Level: Public
---Purpose: Appends <other> to me.
-- Syntax:
-- aString = aString + 15.15;
-- Example: aString contains "I say "
-- gives "I say 15.15"
-- To catenate more than one CString, you must put a String before.
-- So the following example is WRONG !
-- aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
-- This rule is applicable to AssignCat (operator +=) too.
---C++: alias operator +
---C++: inline
raises NullObject from Standard
is static;
Cat (me ; other : CString from Standard)
returns AsciiString from TCollection
---Level: Public
---Purpose: Appends <other> to me.
-- Syntax:
-- aString = aString + "Dummy"
-- Example: aString contains "I say "
-- aString = aString + "Hello " + "Dolly"
-- gives "I say Hello Dolly"
-- To catenate more than one CString, you must put a String before.
-- So the following example is WRONG !
-- aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
-- This rule is applicable to AssignCat (operator +=) too.
---C++: alias operator +
---C++: inline
is static;
-- Cat(me; other : AsciiString from TCollection;
-- result : out AsciiString from TCollection )
-- is private;
Cat (me ; other : AsciiString from TCollection)
returns AsciiString from TCollection
---Level: Public
---Purpose: Appends <other> to me.
-- Example: aString = aString + anotherString
---C++: alias operator +
---C++: inline
is static;
Center(me : out;
Width : Integer from Standard;
Filler : Character from Standard)
raises NegativeValue from Standard
---Purpose: Modifies this ASCII string so that its length
-- becomes equal to Width and the new characters
-- are equal to Filler. New characters are added
-- both at the beginning and at the end of this string.
-- If Width is less than the length of this ASCII string, nothing happens.
-- Example
-- TCollection_AsciiString
-- myAlphabet("abcdef");
-- myAlphabet.Center(9,' ');
-- assert ( myAlphabet == "
-- abcdef " );
is static;
ChangeAll(me : out; aChar, NewChar : Character;
CaseSensitive : Boolean=Standard_True)
---Level: Public
---Purpose: Substitutes all the characters equal to aChar by NewChar
-- in the AsciiString <me>.
-- The substitution can be case sensitive.
-- If you don't use default case sensitive, no matter wether aChar
-- is uppercase or not.
-- Example: me = "Histake" -> ChangeAll('H','M',Standard_True)
-- gives me = "Mistake"
is static;
Clear (me : out)
---Level: Public
---Purpose: Removes all characters contained in <me>.
-- This produces an empty AsciiString.
is static;
Copy (me : out ; fromwhere : CString from Standard)
---Level: Public
---Purpose: Copy <fromwhere> to <me>.
-- Used as operator =
-- Example: aString = anotherCString;
---C++: alias operator =
is static;
Copy (me : out ; fromwhere : AsciiString from TCollection)
---Level: Public
---Purpose: Copy <fromwhere> to <me>.
-- Used as operator =
-- Example: aString = anotherString;
---C++: alias operator =
is static;
Destroy (me : in out)
---Level: Public
---Purpose: Frees memory allocated by AsciiString.
---C++: alias ~
is static;
FirstLocationInSet(me; Set : AsciiString from TCollection;
FromIndex : Integer from Standard;
ToIndex : Integer from Standard)
returns Integer
raises OutOfRange from Standard
is static;
---Level: Public
---Purpose: Returns the index of the first character of <me> that is
-- present in <Set>.
-- The search begins to the index FromIndex and ends to the
-- the index ToIndex.
-- Returns zero if failure.
-- Raises an exception if FromIndex or ToIndex is out of range.
-- Example: before
-- me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
-- after
-- me = "aabAcAa"
-- returns
-- 1
FirstLocationNotInSet(me; Set : AsciiString from TCollection;
FromIndex : Integer;
ToIndex : Integer) returns Integer
raises OutOfRange from Standard
is static;
---Level: Public
---Purpose: Returns the index of the first character of <me>
-- that is not present in the set <Set>.
-- The search begins to the index FromIndex and ends to the
-- the index ToIndex in <me>.
-- Returns zero if failure.
-- Raises an exception if FromIndex or ToIndex is out of range.
-- Example: before
-- me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
-- after
-- me = "aabAcAa"
-- returns
-- 3
Insert (me : out; where : Integer; what : Character)
---Level: Public
---Purpose: Inserts a Character at position <where>.
-- Example:
-- aString contains "hy not ?"
-- aString.Insert(1,'W'); gives "Why not ?"
-- aString contains "Wh"
-- aString.Insert(3,'y'); gives "Why"
-- aString contains "Way"
-- aString.Insert(2,'h'); gives "Why"
raises OutOfRange from Standard
is static;
Insert (me : out; where : Integer; what : CString)
---Level: Public
---Purpose: Inserts a CString at position <where>.
-- Example:
-- aString contains "O more"
-- aString.Insert(2,"nce"); gives "Once more"
raises NullObject from Standard,
OutOfRange from Standard
is static;
Insert (me : out; where : Integer; what : AsciiString from TCollection)
---Level: Public
---Purpose: Inserts a AsciiString at position <where>.
raises OutOfRange;
InsertAfter(me : out; Index : Integer;
other : AsciiString from TCollection)
raises OutOfRange from Standard
is static;
---Level: Public
---Purpose: Pushing a string after a specific index in the string <me>.
-- Raises an exception if Index is out of bounds.
-- - less than 0 (InsertAfter), or less than 1 (InsertBefore), or
-- - greater than the number of characters in this ASCII string.
-- Example:
-- before
-- me = "cde" , Index = 0 , other = "ab"
-- after
-- me = "abcde" , other = "ab"
InsertBefore(me : out; Index : Integer;
other : AsciiString from TCollection)
raises OutOfRange from Standard
is static;
---Level: Public
---Purpose: Pushing a string before a specific index in the string <me>.
-- Raises an exception if Index is out of bounds.
-- - less than 0 (InsertAfter), or less than 1 (InsertBefore), or
-- - greater than the number of characters in this ASCII string.
-- Example:
-- before
-- me = "cde" , Index = 1 , other = "ab"
-- after
-- me = "abcde" , other = "ab"
IsEmpty(me) returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns True if the string <me> contains zero character.
IsEqual (me ; other : CString) returns Boolean
---Purpose: Returns true if the characters in this ASCII string
-- are identical to the characters in ASCII string other.
-- Note that this method is an alias of operator ==.
raises NullObject from Standard
is static;
---C++: alias operator ==
IsEqual (me ; other : AsciiString from TCollection)
returns Boolean from Standard
is static;
---Purpose: Returns true if the characters in this ASCII string
-- are identical to the characters in ASCII string other.
-- Note that this method is an alias of operator ==.
---C++: alias operator ==
IsDifferent (me ; other : CString)
returns Boolean from Standard
---Level: Public
---Purpose: Returns true if there are differences between the
-- characters in this ASCII string and ASCII string other.
-- Note that this method is an alias of operator !=
raises NullObject from Standard
is static;
---C++: alias operator !=
IsDifferent (me ; other : AsciiString from TCollection)
returns Boolean from Standard
is static;
---Purpose: Returns true if there are differences between the
-- characters in this ASCII string and ASCII string other.
-- Note that this method is an alias of operator !=
---C++: alias operator !=
IsLess (me ; other : CString) returns Boolean from Standard
---Level: Public
---Purpose: Returns TRUE if <me> is 'ASCII' less than <other>.
raises NullObject from Standard
---C++: alias operator <
is static;
IsLess (me ; other : AsciiString from TCollection)
returns Boolean from Standard
---Level: Public
---Purpose: Returns TRUE if <me> is 'ASCII' less than <other>.
---C++: alias operator <
is static;
IsGreater (me ; other : CString) returns Boolean from Standard
---Level: Public
---Purpose: Returns TRUE if <me> is 'ASCII' greater than <other>.
raises NullObject from Standard
is static;
---C++: alias operator >
IsGreater (me ; other : AsciiString from TCollection)
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE if <me> is 'ASCII' greater than <other>.
---C++: alias operator >
IntegerValue(me)
returns Integer from Standard
---Level: Public
---Purpose: Converts a AsciiString containing a numeric expression to
-- an Integer.
-- Example: "215" returns 215.
raises NumericError from Standard
is static;
IsIntegerValue(me) returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns True if the AsciiString contains an integer value.
-- Note: an integer value is considered to be a real value as well.
IsRealValue(me) returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns True if the AsciiString contains a real value.
-- Note: an integer value is considered to be a real value as well.
IsAscii(me) returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns True if the AsciiString contains only ASCII characters
-- between ' ' and '~'.
-- This means no control character and no extended ASCII code.
LeftAdjust(me : out)
is static;
---Level: Public
---Purpose: Removes all space characters in the begining of the string.
LeftJustify(me : out; Width : Integer;
Filler : Character from Standard)
raises NegativeValue from Standard
is static;
---Level: Public
---Purpose: left justify
-- Length becomes equal to Width and the new characters are
-- equal to Filler.
-- If Width < Length nothing happens.
-- Raises an exception if Width is less than zero.
-- Example:
-- before
-- me = "abcdef" , Width = 9 , Filler = ' '
-- after
-- me = "abcdef "
Length (me) returns Integer
is static;
---C++: inline
---Level: Public
---Purpose: Returns number of characters in <me>.
-- This is the same functionality as 'strlen' in C.
-- Example
-- TCollection_AsciiString myAlphabet("abcdef");
-- assert ( myAlphabet.Length() == 6 );
-- - 1 is the position of the first character in this string.
-- - The length of this string gives the position of its last character.
-- - Positions less than or equal to zero, or
-- greater than the length of this string are
-- invalid in functions which identify a character
-- of this string by its position.
Location(me; other : AsciiString from TCollection;
FromIndex : Integer;
ToIndex : Integer)
returns Integer from Standard
raises OutOfRange from Standard
is static;
---Level: Public
---Purpose: Returns an index in the string <me> of the first occurence
-- of the string S in the string <me> from the starting index
-- FromIndex to the ending index ToIndex
-- returns zero if failure
-- Raises an exception if FromIndex or ToIndex is out of range.
-- Example:
-- before
-- me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7
-- after
-- me = "aabAaAa"
-- returns
-- 4
Location(me; N : Integer; C : Character from Standard;
FromIndex : Integer;
ToIndex : Integer)
returns Integer from Standard
raises OutOfRange from Standard
is static;
---Level: Public
---Purpose: Returns the index of the nth occurence of the character C
-- in the string <me> from the starting index FromIndex to the
-- ending index ToIndex.
-- Returns zero if failure.
-- Raises an exception if FromIndex or ToIndex is out of range.
-- Example:
-- before
-- me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5
-- after
-- me = "aabAa"
-- returns
-- 5
LowerCase (me : out)
is static;
---Level: Public
---Purpose: Converts <me> to its lower-case equivalent.
-- Example
-- TCollection_AsciiString myString("Hello Dolly");
-- myString.UpperCase();
-- assert ( myString == "HELLO DOLLY" );
-- myString.LowerCase();
-- assert ( myString == "hello dolly" );
Prepend(me : out; other : AsciiString from TCollection)
is static;
---Level: Public
---Purpose: Inserts the string other at the beginning of this ASCII string.
-- Example
-- TCollection_AsciiString myAlphabet("cde");
-- TCollection_AsciiString myBegin("ab");
-- myAlphabet.Prepend(myBegin);
-- assert ( myAlphabet == "abcde" );
Print (me ; astream : out OStream)
is static;
---Level: Public
---Purpose: Displays <me> on a stream.
---C++: alias "friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_AsciiString& astring);"
Read (me : out; astream : out IStream)
is static;
---Level: Public
---Purpose: Read <me> from a stream.
---C++: alias "friend Standard_EXPORT Standard_IStream& operator >> (Standard_IStream& astream, TCollection_AsciiString& astring);"
RealValue(me) returns Real from Standard
---Level: Public
---Purpose: Converts an AsciiString containing a numeric expression.
-- to a Real.
-- Example: ex: "215" returns 215.0.
-- ex: "3.14159267" returns 3.14159267.
raises NumericError from Standard
is static;
RemoveAll(me :out; C : Character from Standard;
CaseSensitive : Boolean from Standard)
is static;
---Level: Public
---Purpose: Remove all the occurences of the character C in the string.
-- Example:
-- before
-- me = "HellLLo", C = 'L' , CaseSensitive = True
-- after
-- me = "Hello"
RemoveAll(me : out; what : Character)
is static;
---Level: Public
---Purpose: Removes every <what> characters from <me>.
Remove (me : out ; where : Integer ; ahowmany : Integer=1)
---Level: Public
---Purpose: Erases <ahowmany> characters from position <where>,
-- <where> included.
-- Example:
-- aString contains "Hello"
-- aString.Remove(2,2) erases 2 characters from position 2
-- This gives "Hlo".
raises OutOfRange from Standard
is static;
RightAdjust(me : out)
is static;
---Level: Public
---Purpose: Removes all space characters at the end of the string.
RightJustify(me : out;
Width : Integer;
Filler : Character from Standard)
raises NegativeValue from Standard
is static;
---Level: Public
---Purpose: Right justify.
-- Length becomes equal to Width and the new characters are
-- equal to Filler.
-- if Width < Length nothing happens.
-- Raises an exception if Width is less than zero.
-- Example:
-- before
-- me = "abcdef" , Width = 9 , Filler = ' '
-- after
-- me = " abcdef"
Search (me ; what : CString) returns Integer from Standard
---Level: Public
---Purpose: Searches a CString in <me> from the beginning
-- and returns position of first item <what> matching.
-- it returns -1 if not found.
-- Example:
-- aString contains "Sample single test"
-- aString.Search("le") returns 5
raises NullObject from Standard
is static;
Search (me ; what : AsciiString from TCollection)
returns Integer from Standard
is static;
---Level: Public
---Purpose: Searches an AsciiString in <me> from the beginning
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
SearchFromEnd (me ; what : CString)
returns Integer from Standard
---Level: Public
---Purpose: Searches a CString in a AsciiString from the end
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
-- Example:
-- aString contains "Sample single test"
-- aString.SearchFromEnd("le") returns 12
raises NullObject from Standard
is static;
SearchFromEnd (me ; what : AsciiString from TCollection)
returns Integer from Standard
is static;
---Level: Public
---Purpose: Searches a AsciiString in another AsciiString from the end
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
SetValue(me : out; where : Integer; what : Character)
---Level: Public
---Purpose: Replaces one character in the AsciiString at position <where>.
-- If <where> is less than zero or greater than the length of <me>
-- an exception is raised.
-- Example:
-- aString contains "Garbake"
-- astring.Replace(6,'g') gives <me> = "Garbage"
raises OutOfRange from Standard
is static;
SetValue(me : out; where : Integer; what : CString)
---Level: Public
---Purpose: Replaces a part of <me> by a CString.
-- If <where> is less than zero or greater than the length of <me>
-- an exception is raised.
-- Example:
-- aString contains "abcde"
-- aString.SetValue(4,"1234567") gives <me> = "abc1234567"
raises OutOfRange from Standard
is static;
SetValue(me : out; where : Integer; what : AsciiString from TCollection)
---Level: Public
---Purpose: Replaces a part of <me> by another AsciiString.
raises OutOfRange from Standard
is static;
Split(me : out; where : Integer; result : out AsciiString from TCollection)
is private;
Split(me : out; where : Integer)
returns AsciiString from TCollection
---Level: Public
---Purpose: Splits a AsciiString into two sub-strings.
-- Example:
-- aString contains "abcdefg"
-- aString.Split(3) gives <me> = "abc" and returns "defg"
raises OutOfRange from Standard
is static;
SubString(me; FromIndex, ToIndex : Integer;
result : out AsciiString from TCollection)
is private;
SubString(me; FromIndex, ToIndex : Integer)
---Level: Public
---Purpose: Creation of a sub-string of the string <me>.
-- The sub-string starts to the index Fromindex and ends
-- to the index ToIndex.
-- Raises an exception if ToIndex or FromIndex is out of bounds
-- Example:
-- before
-- me = "abcdefg", ToIndex=3, FromIndex=6
-- after
-- me = "abcdefg"
-- returns
-- "cdef"
---C++: inline
returns AsciiString from TCollection
raises OutOfRange from Standard
is static;
ToCString(me)
returns CString from Standard
is static;
---Level: Public
---Purpose: Returns pointer to AsciiString (char *).
-- This is useful for some casual manipulations.
-- Warning: Because this "char *" is 'const', you can't modify its contents.
---C++: inline
Token (me ; separators : CString ;
whichone : Integer;
result : out AsciiString from TCollection)
is private;
Token (me ; separators : CString=" \t" ; whichone : Integer=1)
returns AsciiString from TCollection
---Level: Public
---Purpose: Extracts <whichone> token from <me>.
-- By default, the <separators> is set to space and tabulation.
-- By default, the token extracted is the first one (whichone = 1).
-- <separators> contains all separators you need.
-- If no token indexed by <whichone> is found, it returns empty AsciiString.
-- Example:
-- aString contains "This is a message"
-- aString.Token() returns "This"
-- aString.Token(" ",4) returns "message"
-- aString.Token(" ",2) returns "is"
-- aString.Token(" ",9) returns ""
-- Other separators than space character and tabulation are allowed :
-- aString contains "1234; test:message , value"
-- aString.Token("; :,",4) returns "value"
-- aString.Token("; :,",2) returns "test"
raises NullObject from Standard
is static;
Trunc (me : out ; ahowmany : Integer)
---Level: Public
---Purpose: Truncates <me> to <ahowmany> characters.
-- Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
raises OutOfRange from Standard
is static;
UpperCase (me : out)
is static;
---Level: Public
---Purpose: Converts <me> to its upper-case equivalent.
UsefullLength(me)
returns Integer from Standard
is static;
---Level: Public
---Purpose: Length of the string ignoring all spaces (' ') and the
-- control character at the end.
Value(me ; where : Integer)
returns Character from Standard
---Level: Public
---Purpose: Returns character at position <where> in <me>.
-- If <where> is less than zero or greater than the lenght of <me>,
-- an exception is raised.
-- Example:
-- aString contains "Hello"
-- aString.Value(2) returns 'e'
raises OutOfRange from Standard
is static;
HashCode(myclass ; astring : AsciiString from TCollection; Upper : Integer)
returns Integer;
---Level: Internal
---Purpose: Hash function for AsciiString
-- (returns the same Integer value that the hash function for ExtendedString)
---C++: inline
IsEqual(myclass ; string1 : AsciiString from TCollection;
string2 : AsciiString from TCollection)
returns Boolean;
---Level: Internal
---Purpose: Returns True when the two strings are the same.
-- (Just for HashCode for AsciiString)
---C++: inline
IsEqual(myclass ; string1 : AsciiString from TCollection;
string2 : CString from Standard)
returns Boolean;
---Level: Internal
---Purpose: Returns True when the two strings are the same.
-- (Just for HashCode for AsciiString)
---C++: inline
HASHCODE(myclass ; astring : AsciiString from TCollection; Upper : Integer)
returns Integer;
---Level: Internal
---Purpose: Hash function for AsciiString no case sensitive
---C++: inline
ISSIMILAR(myclass ; string1 : AsciiString from TCollection;
string2 : AsciiString from TCollection)
returns Boolean;
---Level: Internal
---Purpose: Returns True when the two strings are the same
-- (no case sensitive).
-- (Just for HashCode for AsciiString)
fields
mystring : PCharacter;
mylength : Integer;
friends
class HAsciiString from TCollection
end AsciiString from TCollection;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
#include <Standard_OutOfRange.hxx>
#include <Standard_CString.hxx>
//definition global methods for using in NCollection
//------------------------------------------------------------------------
// HashCode
//------------------------------------------------------------------------
inline Standard_Integer HashCode(const TCollection_AsciiString& astring,
const Standard_Integer Upper)
{
return TCollection_AsciiString::HashCode(astring,Upper);
}
//------------------------------------------------------------------------
// IsEqual
//------------------------------------------------------------------------
inline Standard_Boolean IsEqual(const TCollection_AsciiString& string1,
const TCollection_AsciiString& string2)
{
return TCollection_AsciiString::IsEqual(string1,string2);
}
// ----------------------------------------------------------------------------
// ToCString
// ----------------------------------------------------------------------------
inline Standard_CString TCollection_AsciiString::ToCString()const
{
return mystring;
}
// ----------------------------------------------------------------------------
inline Standard_Integer TCollection_AsciiString::Length() const
{
return mylength;
}
inline TCollection_AsciiString TCollection_AsciiString::Cat(const TCollection_AsciiString& other) const
{
return TCollection_AsciiString( *this , other ) ;
}
inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_CString other) const
{
return TCollection_AsciiString( *this , other ) ;
}
inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Character other) const
{
return TCollection_AsciiString( *this , other ) ;
}
inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Integer other) const
{
return TCollection_AsciiString( *this , TCollection_AsciiString(other) ) ;
}
inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Real other) const
{
return TCollection_AsciiString( *this , TCollection_AsciiString(other) ) ;
}
//------------------------------------------------------------------------
// HashCode
//------------------------------------------------------------------------
inline Standard_Integer TCollection_AsciiString::HashCode(const TCollection_AsciiString& astring,
const Standard_Integer Upper)
{
return ::HashCode(astring.ToCString(),Upper);
}
//------------------------------------------------------------------------
// IsEqual
//------------------------------------------------------------------------
inline Standard_Boolean TCollection_AsciiString::IsEqual(const TCollection_AsciiString& string1,
const TCollection_AsciiString& string2)
{
return string1.IsEqual(string2);
}
//------------------------------------------------------------------------
// IsEqual
//------------------------------------------------------------------------
inline Standard_Boolean TCollection_AsciiString::IsEqual(const TCollection_AsciiString& string1,
const Standard_CString string2)
{
return string1.IsEqual( string2 );
}
//------------------------------------------------------------------------
// HASHCODE
//------------------------------------------------------------------------
inline Standard_Integer TCollection_AsciiString::HASHCODE(const TCollection_AsciiString& astring,
const Standard_Integer Upper)
{
return ::HASHCODE( astring.ToCString() , astring.Length() , Upper );
}
// ----------------------------------------------------------------------------
// SubString
// ----------------------------------------------------------------------------
inline TCollection_AsciiString TCollection_AsciiString::SubString(const Standard_Integer FromIndex,
const Standard_Integer ToIndex) const
{
if (ToIndex > mylength || FromIndex <= 0 || FromIndex > ToIndex ) Standard_OutOfRange::Raise();
return TCollection_AsciiString( &mystring [ FromIndex - 1 ] ,
ToIndex - FromIndex + 1 ) ;
}

View File

@@ -0,0 +1,161 @@
-- File: TCollection_Sequence.cdl
-- Created: Fri Sep 11 17:34:39 1992
-- Author: Mireille MERCIEN
-- <mip@sdsun3>
---Copyright: Matra Datavision 1992
class BaseSequence from TCollection
---Purpose: Definition of a base class for all instanciations
-- of sequence.
--
-- The methods : Clear, Remove accepts a pointer to a
-- function to use to delete the nodes. This allow
-- proper call of the destructor on the Items.
-- Without adding a virtual function pointer to each
-- node or each sequence.
raises
NoSuchObject from Standard,
OutOfRange from Standard
is
Create returns BaseSequence is protected;
---Purpose: Creation of an empty sequence.
Create(Other : BaseSequence) returns BaseSequence from TCollection
---Purpose: Creation by copy of existing Sequence.
-- Warning: This constructor prints a warning message.
-- We recommand to use the operator =.
is private;
IsEmpty(me) returns Boolean;
---Level: Public
---Purpose: returns True if the sequence <me> contains no elements.
---C++: inline
Length(me) returns Integer from Standard;
---Level: Public
---Purpose: Returns the number of element(s) in the
-- sequence. Returns zero if the sequence is empty.
---C++: inline
Clear(me : in out; DelNode : Address) is protected;
---Level: Private
PAppend(me : in out; Node : Address)
is protected;
PAppend(me : in out; S : in out BaseSequence)
---Level: Public
---Purpose: Concatenates <S> at the end of <me>.
-- <S> is cleared.
-- Example:
-- before
-- me = (A B C)
-- S = (D E F)
-- after
-- me = (A B C D E F)
-- S = ()
is protected;
PPrepend(me : in out; Node : Address)
is protected;
PPrepend(me : in out; S : in out BaseSequence)
---Level: Public
---Purpose: Concatenates <S> at the beginning of <me>.
-- <S> is cleared.
-- Example:
-- before
-- me = (A B C) S = (D E F)
-- after me = (D E F A B C)
-- S = ()
is protected;
Reverse(me : in out);
---Level: Public
---Purpose: Reverses the order of items on <me>.
-- Example:
-- before
-- me = (A B C)
-- after
-- me = (C B A)
PInsertAfter(me : in out; Index : Integer from Standard; Node : Address )
raises OutOfRange from Standard
is protected;
PInsertAfter(me : in out; Index : Integer from Standard; S : in out BaseSequence)
raises OutOfRange from Standard
---Level: Public
---Purpose: Inserts the sequence <S> in <me> after the
-- position <Index>. <S> is cleared.
-- Raises an exception if the index is out of bound.
-- Example:
-- before
-- me = (A B C), Index = 3, S = (D E F)
-- after
-- me = (A B C D E F)
-- S = ()
is protected;
Exchange(me : in out; I, J : Integer from Standard)
raises OutOfRange from Standard;
---Level: Public
---Purpose: Swaps elements which are located at
-- positions <I> and <J> in <me>.
-- Raises an exception if I or J is out of bound.
-- Example:
-- before
-- me = (A B C), I = 1, J = 3
-- after
-- me = (C B A)
PSplit(me : in out; Index : Integer from Standard; Sub : in out BaseSequence)
raises OutOfRange from Standard
---Level: Public
---Purpose: Keeps in <me> the items 1 to <Index>-1 and
-- puts in <Sub> the items <Index> to the end.
-- Example:
-- before
-- me = (A B C D) ,Index = 3
-- after
-- me = (A B)
-- Sub = (C D)
is protected;
Remove(me : in out; Index : Integer from Standard; DelNode : Address)
raises OutOfRange from Standard
is protected;
Remove(me : in out; FromIndex, ToIndex : Integer from Standard; DelNode : Address)
raises OutOfRange from Standard
is protected;
Find(me; Index : Integer from Standard) returns Address from Standard
---Level: Internal
---Purpose: Returns the node at position <index>.
is protected;
Nullify(me : in out ) is private;
---Level: Internal
---Purpose: Clear all fields.
--
fields
FirstItem : Address from Standard is protected;
LastItem : Address from Standard is protected;
CurrentItem : Address from Standard is protected;
CurrentIndex : Integer from Standard is protected;
Size : Integer from Standard is protected;
end;

View File

@@ -0,0 +1,352 @@
#include <TCollection_BaseSequence.ixx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
#include <TCollection_SeqNode.hxx>
typedef void (*DelNode) (TCollection_SeqNode*);
TCollection_BaseSequence::TCollection_BaseSequence() :
FirstItem(NULL),
LastItem(NULL),
CurrentItem(NULL),
CurrentIndex(0),
Size(0)
{
}
// ----------------------------------
// Clear : Clear the Current Sequence
// ----------------------------------
void TCollection_BaseSequence::Clear(const Standard_Address delnode)
{
Size = 0;
TCollection_SeqNode* p = (TCollection_SeqNode*) FirstItem;
TCollection_SeqNode* q;
while (p) {
q = p;
p = p->Next();
((DelNode)delnode) (q);
}
LastItem = FirstItem = CurrentItem = NULL;
CurrentIndex = 0;
}
void TCollection_BaseSequence::PAppend(const Standard_Address newnode)
{
if (Size == 0) {
FirstItem = LastItem = CurrentItem = newnode;
CurrentIndex = Size = 1;
}
else {
((TCollection_SeqNode*)LastItem)->Next() = (TCollection_SeqNode*)newnode;
LastItem = newnode;
Size++;
}
}
// ---------------------------------------------------
// Append : Push a sequence at the end of the sequence
// ---------------------------------------------------
void TCollection_BaseSequence::PAppend(TCollection_BaseSequence& Other)
{
if (Size == 0) {
Size = Other.Size;
FirstItem = Other.FirstItem;
LastItem = Other.LastItem;
CurrentItem = FirstItem;
CurrentIndex = 1;
}
else {
Size += Other.Size;
((TCollection_SeqNode*)LastItem)->Next() = (TCollection_SeqNode*)Other.FirstItem;
if (Other.FirstItem) {
((TCollection_SeqNode*)Other.FirstItem)->Previous() = (TCollection_SeqNode*)LastItem;
LastItem = Other.LastItem;
}
}
Other.Nullify();
}
void TCollection_BaseSequence::PPrepend(const Standard_Address newnode)
{
if (Size == 0) {
FirstItem = LastItem = CurrentItem = newnode;
CurrentIndex = Size = 1;
}
else {
((TCollection_SeqNode*)FirstItem)->Previous() = (TCollection_SeqNode*) newnode;
((TCollection_SeqNode*)newnode)->Next() = (TCollection_SeqNode*)FirstItem;
FirstItem = newnode;
Size++;
CurrentIndex++;
}
}
void TCollection_BaseSequence::PPrepend(TCollection_BaseSequence& Other)
{
if (Size == 0) {
Size = Other.Size;
FirstItem = Other.FirstItem;
LastItem = Other.LastItem;
CurrentIndex = 1;
CurrentItem = FirstItem;
}
else {
Size += Other.Size;
if (Other.LastItem) ((TCollection_SeqNode*)Other.LastItem)->Next() = (TCollection_SeqNode*)FirstItem;
((TCollection_SeqNode*)FirstItem)->Previous() = (TCollection_SeqNode*)Other.LastItem;
FirstItem = Other.FirstItem;
CurrentIndex += Other.Size;
}
Other.Nullify();
}
// ---------------------------------------------------------
// Reverse : Reverse the order of a given sequence
// ---------------------------------------------------------
void TCollection_BaseSequence::Reverse()
{
TCollection_SeqNode* p = (TCollection_SeqNode*) FirstItem;
TCollection_SeqNode* tmp;
while (p) {
tmp = p->Next();
p->Next() = p->Previous();
p->Previous() = tmp;
p = tmp;
}
tmp = (TCollection_SeqNode*)FirstItem;
FirstItem = LastItem;
LastItem = tmp;
if (Size != 0) CurrentIndex = Size + 1 - CurrentIndex;
}
void TCollection_BaseSequence::PInsertAfter(const Standard_Integer Index, const Standard_Address N)
{
if (Index == 0)
PPrepend(N);
else {
TCollection_SeqNode* p = (TCollection_SeqNode*) Find(Index);
TCollection_SeqNode* newnode = (TCollection_SeqNode*) N;
newnode->Next() = p->Next();
newnode->Previous() = p;
if (Index == Size) LastItem = newnode;
else p->Next()->Previous() = newnode;
p->Next() = newnode;
Size++;
if (Index < CurrentIndex) CurrentIndex++;
}
}
// -------------------------------------------------------------------
// InsertAfter : Insert a sequence after a given index in the sequence
// -------------------------------------------------------------------
void TCollection_BaseSequence::PInsertAfter(const Standard_Integer Index, TCollection_BaseSequence& Other)
{
if (Index < 0 || Index > Size) Standard_OutOfRange::Raise();
if (Other.Size == 0) return;
if (Index == 0)
PPrepend( Other );
else {
TCollection_SeqNode* p = (TCollection_SeqNode*) Find(Index);
((TCollection_SeqNode*)Other.FirstItem)->Previous() = p;
((TCollection_SeqNode*)Other.LastItem)->Next() = p->Next();
if (Index == Size) LastItem = Other.LastItem;
else p->Next()->Previous() = (TCollection_SeqNode*)Other.LastItem;
p->Next() = (TCollection_SeqNode*)Other.FirstItem;
Size += Other.Size;
if (Index < CurrentIndex) CurrentIndex += Other.Size;
Other.Nullify();
}
}
// ----------------------------------------
// Exchange : Exchange two elements in the sequence
// ----------------------------------------
void TCollection_BaseSequence::Exchange(const Standard_Integer I, const Standard_Integer J)
{
Standard_OutOfRange_Raise_if ( I <= 0 || J <= 0 || I > Size || J > Size,"" ) ;
// Assume I < J
if (I == J) return;
if (J < I) {
Exchange(J,I);
return;
}
TCollection_SeqNode* pi = (TCollection_SeqNode*) Find(I);
TCollection_SeqNode* pj = (TCollection_SeqNode*) Find(J);
// update the node before I
if (pi->Previous())
pi->Previous()->Next() = pj;
else
FirstItem = pj;
// update the node after J
if (pj->Next())
pj->Next()->Previous() = pi;
else
LastItem = pi;
if (pi->Next() == pj) { // I and J are consecutives, update them
pj->Previous() = pi->Previous();
pi->Previous() = pj;
pi->Next() = pj->Next();
pj->Next() = pi;
}
else { // I and J are not consecutive
pi->Next()->Previous() = pj; // update the node after I
pj->Previous()->Next() = pi; // update the node before J
TCollection_SeqNode* tmp = pi->Next(); // update nodes I and J
pi->Next() = pj->Next();
pj->Next() = tmp;
tmp = pi->Previous();
pi->Previous() = pj->Previous();
pj->Previous() = tmp;
}
if (CurrentIndex == I) CurrentItem = pj;
else if (CurrentIndex == J) CurrentItem = pi;
}
void TCollection_BaseSequence::PSplit(const Standard_Integer Index, TCollection_BaseSequence& Sub)
{
Standard_OutOfRange_Raise_if( Index <= 0 || Index > Size,"" );
Standard_DomainError_Raise_if(this == &Sub,"No Split on myself!!");
TCollection_SeqNode* p = (TCollection_SeqNode*) Find(Index);
Sub.LastItem = LastItem;
Sub.Size = Size - Index + 1;
LastItem = p->Previous();
if (LastItem) {
((TCollection_SeqNode*)LastItem)->Next() = NULL;
Size = Index - 1;
if (CurrentIndex >= Index) {
CurrentIndex = 1;
CurrentItem = (TCollection_SeqNode*) FirstItem;
}
}
else {
FirstItem = CurrentItem = NULL;
Size = CurrentIndex = 0;
}
Sub.FirstItem = Sub.CurrentItem = p;
p->Previous() = NULL;
Sub.CurrentIndex = 1;
}
void TCollection_BaseSequence::Remove(const Standard_Integer Index, const Standard_Address delnode)
{
Standard_OutOfRange_Raise_if(Index <= 0 || Index > Size,"" );
TCollection_SeqNode* p = (TCollection_SeqNode*) Find(Index);
if (p->Previous())
p->Previous()->Next() = p->Next();
else
FirstItem = p->Next();
if (p->Next())
p->Next()->Previous() = p->Previous();
else
LastItem = p->Previous();
Size--;
if (CurrentIndex > Index) CurrentIndex--;
else if (CurrentIndex == Index) {
if (p->Next())
CurrentItem = p->Next();
else {
CurrentItem = (TCollection_SeqNode*) LastItem;
CurrentIndex = Size;
}
}
((DelNode)delnode) (p);
}
// ---------------------
// Remove a set of items
// ---------------------
void TCollection_BaseSequence::Remove(const Standard_Integer From, const Standard_Integer To,
const Standard_Address delnode)
{
Standard_OutOfRange_Raise_if (From <= 0 || From > Size || To <= 0 || To > Size || From > To,"" );
TCollection_SeqNode* pfrom = (TCollection_SeqNode*) Find(From);
TCollection_SeqNode* pto = (TCollection_SeqNode*) Find(To);
if (pfrom->Previous())
pfrom->Previous()->Next() = pto->Next();
else
FirstItem = pto->Next();
if (pto->Next())
pto->Next()->Previous() = pfrom->Previous();
else
LastItem = pfrom->Previous();
Size -= To - From + 1;
if (CurrentIndex > To)
CurrentIndex -= To - From + 1;
else if (CurrentIndex >= From) {
if (pto->Next()) {
CurrentItem = pto->Next();
CurrentIndex = From; // AGV fix 24.05.01
} else {
CurrentItem = (TCollection_SeqNode*) LastItem;
CurrentIndex = Size;
}
}
Standard_Integer i;
for (i = From; i <= To; i++) {
pto = pfrom;
pfrom = pfrom->Next();
((DelNode)delnode) (pto);
}
}
Standard_Address TCollection_BaseSequence::Find(const Standard_Integer Index) const
{
Standard_Integer i;
TCollection_SeqNode* p;
if (Index <= CurrentIndex) {
if (Index < CurrentIndex / 2) {
p = (TCollection_SeqNode*) FirstItem;
for (i = 1; i < Index; i++) p = p->Next();
}
else {
p = (TCollection_SeqNode*) CurrentItem;
for (i = CurrentIndex; i > Index; i--) p = p->Previous();
}
}
else {
if (Index < (CurrentIndex + Size) / 2) {
p = (TCollection_SeqNode*) CurrentItem;
for (i = CurrentIndex; i < Index; i++) p = p->Next();
}
else {
p = (TCollection_SeqNode*) LastItem;
for (i = Size; i > Index; i--) p = p->Previous();
}
}
return p;
}
//=======================================================================
//function : Nullify
//purpose :
//=======================================================================
void TCollection_BaseSequence::Nullify()
{
FirstItem = LastItem = CurrentItem = NULL;
CurrentIndex = Size = 0;
}

View File

@@ -0,0 +1,12 @@
inline Standard_Boolean TCollection_BaseSequence::IsEmpty() const
{
return Size == 0;
}
inline Standard_Integer TCollection_BaseSequence::Length() const
{
return Size;
}

View File

@@ -0,0 +1,150 @@
-- File: TCollection_BasicMap.cdl
-- Created: Fri Feb 26 16:37:33 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
private deferred class BasicMap from TCollection
---Purpose: Root class of all the maps, provides utilitites
-- for managing the buckets.
-- Maps are dynamically extended data structures where
-- data is quickly accessed with a key.
-- General properties of maps
-- - Map items may be (complex) non-unitary data; they
-- may be difficult to manage with an array. Moreover, the
-- map allows a data structure to be indexed by complex data.
-- - The size of a map is dynamically extended. So a map
-- may be first dimensioned for a little number of items.
-- Maps avoid the use of large and quasi-empty arrays.
-- - The access to a map item is much faster than the one
-- to a sequence, a list, a queue or a stack item.
-- - The access time to a map item may be compared with
-- the one to an array item. First of all, it depends on the
-- size of the map. It also depends on the quality of a user
-- redefinable function (the hashing function) to find
-- quickly where the item is.
-- - The exploration of a map may be of better performance
-- than the exploration of an array because the size of the
-- map is adapted to the number of inserted items.
-- These properties explain why maps are commonly used as
-- internal data structures for algorithms.
-- Definitions
-- - A map is a data structure for which data is addressed by keys.
-- - Once inserted in the map, a map item is referenced as an entry of the map.
-- - Each entry of the map is addressed by a key. Two
-- different keys address two different entries of the map.
-- - The position of an entry in the map is called a bucket.
-- - A map is dimensioned by its number of buckets, i.e. the
-- maximum number of entries in the map. The
-- performance of a map is conditioned by the number of buckets.
-- - The hashing function transforms a key into a bucket
-- index. The number of values that can be computed by
-- the hashing function is equal to the number of buckets of the map.
-- - Both the hashing function and the equality test
-- between two keys are provided by a hasher object.
-- - A map may be explored by a map iterator. This
-- exploration provides only inserted entries in the map
-- (i.e. non empty buckets).
-- Collections' generic maps
-- The Collections component provides numerous generic derived maps.
-- - These maps include automatic management of the
-- number of buckets: they are automatically resized when
-- the number of keys exceeds the number of buckets. If
-- you have a fair idea of the number of items in your map,
-- you can save on automatic resizing by specifying a
-- number of buckets at the time of construction, or by using
-- a resizing function. This may be considered for crucial optimization issues.
-- - Keys, items and hashers are parameters of these generic derived maps.
-- - TCollection_MapHasher class describes the
-- functions required by any hasher which is to be used
-- with a map instantiated from the Collections component.
-- - An iterator class is automatically instantiated at the
-- time of instantiation of a map provided by the
-- Collections component if this map is to be explored
-- with an iterator. Note that some provided generic maps
-- are not to be explored with an iterator but with indexes (indexed maps).
uses MapNodePtr from TCollection
is
Initialize(NbBuckets : Integer; single : Boolean);
---Purpose: Initialize the map. Single is True when the map
-- uses only one table of buckets.
--
-- One table : Map, DataMap
-- Two tables : DoubleMap, IndexedMap, IndexedDataMap
NbBuckets(me) returns Integer
---Purpose: Returns the number of buckets in <me>.
---C++: inline
is static;
Extent(me) returns Integer
---Purpose: Returns the number of keys already stored in <me>.
--
---C++: inline
is static;
IsEmpty(me) returns Boolean
---Purpose: Returns True when the map contains no keys.
-- This is exactly Extent() == 0.
---C++: inline
is static;
BeginResize(me;
NbBuckets : Integer;
NewBuckets : out Integer;
data1, data2 : out Address)
returns Boolean
---Purpose: Tries to resize the Map with NbBuckets. Returns
-- True if possible, NewBuckts is the new nuber of
-- buckets. data1 and data2 are the new tables of
-- buckets where the data must be copied.
is static protected;
EndResize(me : in out;
NbBuckets : Integer;
NewBuckets : Integer;
data1, data2 : Address)
---Purpose: If BeginResize was succesfull after copying the
-- data to data1 and data2 this methods update the
-- tables and destroys the old ones.
is static protected;
Resizable(me) returns Boolean
---Purpose: Returns True if resizing the map should be
-- considered.
---C++: inline
is static protected;
Increment(me : in out)
---Purpose: Decrement the extent of the map.
---C++: inline
is static protected;
Decrement(me : in out)
---Purpose: Decrement the extent of the map.
---C++: inline
is static protected;
Destroy(me : in out)
---Purpose: Destroys the buckets.
is static protected;
Statistics(me; S : in out OStream)
---Purpose: Prints on <S> usefull statistics about the map
-- <me>. It can be used to test the quality of the hashcoding.
is static;
fields
isDouble : Boolean from Standard; -- True for double maps
mySaturated : Boolean from Standard;
myNbBuckets : Integer;
mySize : Integer;
myData1 : Address from Standard is protected;
myData2 : Address from Standard is protected;
friends
class BasicMapIterator from TCollection
end BasicMap;

View File

@@ -0,0 +1,145 @@
// File: TCollection_BasicMap.cxx
// Created: Fri Feb 26 17:20:43 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <TCollection_BasicMap.ixx>
#include <TCollection.hxx>
#include <TCollection_BasicMapIterator.hxx>
#include <TCollection_MapNode.hxx>
#include <Standard_Stream.hxx>
//=======================================================================
//function : TCollection_BasicMap
//purpose :
//=======================================================================
TCollection_BasicMap::TCollection_BasicMap(const Standard_Integer NbBuckets,
const Standard_Boolean single) :
myData1(NULL),
myData2(NULL),
isDouble(!single),
mySaturated(Standard_False),
myNbBuckets(NbBuckets),
mySize(0)
{
}
//=======================================================================
//function : BeginResize
//purpose :
//=======================================================================
Standard_Boolean TCollection_BasicMap::BeginResize
(const Standard_Integer NbBuckets,
Standard_Integer& N,
Standard_Address& data1,
Standard_Address& data2) const
{
if (mySaturated) return Standard_False;
N = TCollection::NextPrimeForMap(NbBuckets);
if (N <= myNbBuckets) {
if (IsEmpty())
N = myNbBuckets;
else
return Standard_False;
}
data1 = Standard::Allocate((N+1)*sizeof(TCollection_MapNodePtr));
memset(data1, 0, (N+1)*sizeof(TCollection_MapNodePtr));
if (isDouble) {
data2 = Standard::Allocate((N+1)*sizeof(TCollection_MapNodePtr));
memset(data2, 0, (N+1)*sizeof(TCollection_MapNodePtr));
}
else
data2 = NULL;
return Standard_True;
}
//=======================================================================
//function : EndResize
//purpose :
//=======================================================================
void TCollection_BasicMap::EndResize(const Standard_Integer NbBuckets,
const Standard_Integer N,
const Standard_Address data1,
const Standard_Address data2)
{
Standard::Free(myData1);
Standard::Free(myData2);
myNbBuckets = N;
mySaturated = myNbBuckets <= NbBuckets;
myData1 = data1;
myData2 = data2;
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void TCollection_BasicMap::Destroy()
{
mySize = 0;
mySaturated = Standard_False;
Standard::Free(myData1);
Standard::Free(myData2);
myData1 = myData2 = NULL;
}
//=======================================================================
//function : Statistics
//purpose :
//=======================================================================
void TCollection_BasicMap::Statistics(Standard_OStream& S) const
{
S <<"\nMap Statistics\n---------------\n\n";
S <<"This Map has "<<myNbBuckets<<" Buckets and "<<mySize<<" Keys\n\n";
if (mySaturated) S<<"The maximum number of Buckets is reached\n";
if (mySize == 0) return;
// compute statistics on 1
Standard_Integer * sizes = new Standard_Integer [mySize+1];
Standard_Integer i,l,nb;
TCollection_MapNode* p;
TCollection_MapNode** data;
S << "\nStatistics for the first Key\n";
for (i = 0; i <= mySize; i++) sizes[i] = 0;
data = (TCollection_MapNode**) myData1;
nb = 0;
for (i = 0; i <= myNbBuckets; i++) {
l = 0;
p = data[i];
if (p) nb++;
while (p) {
l++;
p = p->Next();
}
sizes[l]++;
}
// display results
l = 0;
for (i = 0; i<= mySize; i++) {
if (sizes[i] > 0) {
l += sizes[i] * i;
S << setw(5) << sizes[i] <<" buckets of size "<<i<<"\n";
}
}
Standard_Real mean = ((Standard_Real) l) / ((Standard_Real) nb);
S<<"\n\nMean of length : "<<mean<<"\n";
delete [] sizes;
}

View File

@@ -0,0 +1,68 @@
// File: TCollection_BasicMap.lxx
// Created: Fri Feb 26 17:02:30 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//function : NbBuckets
//purpose :
//=======================================================================
inline Standard_Integer TCollection_BasicMap::NbBuckets() const
{
return myNbBuckets;
}
//=======================================================================
//function : Extent
//purpose :
//=======================================================================
inline Standard_Integer TCollection_BasicMap::Extent() const
{
return mySize;
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_BasicMap::IsEmpty() const
{
return mySize == 0;
}
//=======================================================================
//function : Resizable
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_BasicMap::Resizable()const
{
return IsEmpty() || (!mySaturated && (mySize > myNbBuckets));
}
//=======================================================================
//function : Increment
//purpose :
//=======================================================================
inline void TCollection_BasicMap::Increment()
{
mySize++;
}
//=======================================================================
//function : Decrement
//purpose :
//=======================================================================
inline void TCollection_BasicMap::Decrement()
{
mySize--;
}

View File

@@ -0,0 +1,73 @@
-- File: TCollection_BasicMapIterator.cdl
-- Created: Fri Feb 26 15:10:06 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
private deferred class BasicMapIterator from TCollection
---Purpose: This class provides basic services for the
-- iterators on Maps. The iterators are inherited
-- from this one.
--
-- The iterator contains an array of pointers
-- (buckets). Each bucket is a pointer on a node. A
-- node contains a pointer on the next node.
--
-- This class provides also basic services for the
-- implementation of Maps.
-- A map iterator provides a step by step exploration of all
-- entries of a map. After initialization of a concrete derived
-- iterator, use in a loop:
-- - the function More to know if there is a current entry for
-- the iterator in the map,
-- - then the functions which read data on an entry of the
-- map (these functions are provided by each type of map),
-- - then the function Next to set the iterator to the next entry of the map.
-- Warning
-- - A map is a non-ordered data structure. The order in
-- which entries of a map are explored by the iterator
-- depends on its contents, and change when the map is edited.
-- - It is not recommended to modify the contents of a map
-- during iteration: the result is unpredictable.
uses
BasicMap from TCollection
is
Initialize;
---Purpose: Creates an empty iterator.
Initialize(M : BasicMap from TCollection);
---Purpose: Initialize on the first node in the buckets.
Initialize(me : in out; M : BasicMap from TCollection)
---Purpose: Initialize on the first node in the buckets.
is static protected;
Reset(me : in out)
---Purpose: Resets the iterator to the first node.
is static;
More(me) returns Boolean
---Purpose: Returns true if there is a current entry for this iterator in the map.
-- Use the function Next to set this iterator to the position of
-- the next entry, if it exists.
---C++: inline
is static;
Next(me : in out)
---Purpose: Sets this iterator to the position of the next entry of the map.
-- Nothing is changed if there is no more entry to explore in
-- the map: this iterator is always positioned on the last entry
-- of the map but the function More returns false.
is static;
fields
myNbBuckets : Integer;
myBuckets : Address from Standard;
myBucket : Integer;
myNode : Address from Standard is protected;
end BasicMapIterator;

View File

@@ -0,0 +1,89 @@
// File: TCollection_BasicMapIterator.cxx
// Created: Fri Feb 26 15:46:25 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <TCollection_BasicMapIterator.ixx>
#include <TCollection_BasicMap.hxx>
#include <TCollection_MapNode.hxx>
//=======================================================================
//function : TCollection_BasicMapIterator
//purpose :
//=======================================================================
TCollection_BasicMapIterator::TCollection_BasicMapIterator () :
myNode(NULL),
myNbBuckets(0),
myBuckets(NULL),
myBucket(0)
{}
//=======================================================================
//function : TCollection_BasicMapIterator
//purpose :
//=======================================================================
TCollection_BasicMapIterator::TCollection_BasicMapIterator
(const TCollection_BasicMap& M) :
myNode(NULL),
myNbBuckets(M.myNbBuckets),
myBuckets(M.myData1),
myBucket(-1)
{
if (!myBuckets) myNbBuckets = -1;
Next();
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void TCollection_BasicMapIterator::Initialize
(const TCollection_BasicMap& M)
{
myNbBuckets = M.myNbBuckets;
myBuckets = M.myData1;
myBucket = -1;
myNode = NULL;
if (!myBuckets) myNbBuckets = -1;
Next();
}
//=======================================================================
//function : Reset
//purpose :
//=======================================================================
void TCollection_BasicMapIterator::Reset()
{
myBucket = -1;
myNode = NULL;
Next();
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void TCollection_BasicMapIterator::Next()
{
if (!myBuckets) return;
if (myNode) {
myNode = ((TCollection_MapNode*) myNode)->Next();
if (myNode) return;
}
while (!myNode) {
myBucket++;
if (myBucket > myNbBuckets) return;
myNode = ((TCollection_MapNodePtr*)myBuckets)[myBucket];
}
}

View File

@@ -0,0 +1,18 @@
// File: TCollection_BasicMapIterator.lxx
// Created: Fri Feb 26 15:48:30 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//function : More
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_BasicMapIterator::More() const
{
return myNode != 0L;
}

View File

@@ -0,0 +1,24 @@
-- File: CMPLRS.edl
-- Author: euclid
-- History: Fri Feb 20 16:16:22 MET 1998
@if ( %DebugMode == "False" ) then
@if ( %Station == "sun" ) then
@set %CMPLRS_CXX_ModeOpt = " -O3 -DNo_Exception ";
@endif;
@if ( %Station == "ao1" ) then
@string %CMPLRS_CXX_ModeOpt += " -O3 -DNo_Exception ";
@endif;
@if ( %Station == "sil" ) then
@set %CMPLRS_CXX_ModeOpt = " -O2 -DNo_Exception ";
@endif;
@if ( %Station == "hp" ) then
@set %CMPLRS_CXX_ModeOpt = " +O3 -DNo_Exception ";
@endif;
@endif;

View File

@@ -0,0 +1,39 @@
-- File: TCollection_Compare.cdl
-- Created: Tue May 14 18:07:48 1991
-- Author: Annick PANCHER
-- <apc@topsn2>
-- Revised: Mireille MERCIEN
-- <mip@sdsun3>
-- Copyright: Matra Datavision 1992
deferred generic class Compare from TCollection ( Item as any )
---Purpose: Defines a comparison operator which can be used by
-- any ordered structure. The way to compare items
-- has to be described in subclasses, which inherit
-- from instantiations of Compare.
is
IsLower (me; Left, Right: Item)
---Level: Public
---Purpose: returns True if <Left> is lower than <Right>.
returns Boolean
is virtual;
IsGreater (me; Left, Right: Item)
---Level: Public
---Purpose: returns True if <Left> is greater than <Right>.
returns Boolean
is virtual;
IsEqual(me; Left, Right: Item)
---Level: Public
---Purpose: returns True when <Right> and <Left> are equal.
returns Boolean
is virtual;
end;

View File

@@ -0,0 +1,39 @@
// Copyright: Matra-Datavision 1991
// File: TCollection_Compare.gxx
// Created: Thu Aug 27 12:06:34 1992
// Author: Mireille MERCIEN
// <mip@sdsun3>
// Copyright: Matra Datavision 1992
#include <Standard_NotImplemented.hxx>
// -----------
// IsLower :
// -----------
Standard_Boolean TCollection_Compare::IsLower (const Item& ,
const Item& ) const
{
Standard_NotImplemented::Raise();
return Standard_False;
}
// -----------
// IsGreater :
// -----------
Standard_Boolean TCollection_Compare::IsGreater (const Item& ,
const Item& ) const
{
Standard_NotImplemented::Raise();
return Standard_False;
}
// -----------
// IsEqual :
// -----------
Standard_Boolean TCollection_Compare::IsEqual (const Item& Left,
const Item& Right) const
{
return (Left == Right) ;
}

View File

@@ -0,0 +1,28 @@
-- File: TCollection_CompareOfInteger.cdl
-- Created: Thu Aug 27 12:06:34 1992
-- Author: Mireille MERCIEN
-- <mip@sdsun3>
---Copyright: Matra Datavision 1992
class CompareOfInteger from TCollection
inherits
PrivCompareOfInteger
is
Create ;
IsLower (me; Left, Right: Integer)
---Level: Public
---Purpose: Returns True if <Left> is lower than <Right>.
returns Boolean
is redefined;
IsGreater (me; Left, Right: Integer)
---Level: Public
---Purpose: Returns True if <Left> is greater than <Right>.
returns Boolean
is redefined;
end;

View File

@@ -0,0 +1,33 @@
// Copyright: Matra-Datavision 1992
// <mip@sdsun3>
// File: TCollection_CompareOfInteger.cxx
// Created: Thu Aug 27 12:06:34 1992
// Author: Mireille MERCIEN
#include <TCollection_CompareOfInteger.ixx>
// -----------
// Create :
// -----------
TCollection_CompareOfInteger::TCollection_CompareOfInteger()
{
}
// -----------
// IsLower :
// -----------
Standard_Boolean TCollection_CompareOfInteger::IsLower (
const Standard_Integer &Left,const Standard_Integer &Right) const
{
return (Left < Right) ;
}
// -----------
// IsGreater :
// -----------
Standard_Boolean TCollection_CompareOfInteger::IsGreater (
const Standard_Integer &Left,const Standard_Integer &Right) const
{
return (Left > Right) ;
}

View File

@@ -0,0 +1,28 @@
-- File: TCollection_CompareOfReal.cdl
-- Created: Thu Aug 27 12:27:20 1992
-- Author: Mireille MERCIEN
-- <mip@sdsun3>
---Copyright: Matra Datavision 1992
class CompareOfReal from TCollection
inherits
PrivCompareOfReal
is
Create;
IsLower (me; Left, Right: Real)
---Level: Public
---Purpose: Returns True if <Left> is lower than <Right>.
returns Boolean
is redefined;
IsGreater (me; Left, Right: Real)
---Level: Public
---Purpose: Returns True if <Left> is greater than <Right>.
returns Boolean
is redefined;
end;

View File

@@ -0,0 +1,38 @@
// Copyright: Matra-Datavision 1992
// <mip@sdsun3>
// File: TCollection_CompareOfReal.cxx
// Created: Thu Aug 27 12:06:34 1992
// Author: Mireille MERCIEN
#include <TCollection_CompareOfReal.ixx>
// -----------
// Create :
// -----------
TCollection_CompareOfReal::TCollection_CompareOfReal()
{
}
// -----------
// IsLower :
// -----------
Standard_Boolean TCollection_CompareOfReal::IsLower (
const Standard_Real &Left,const Standard_Real &Right) const
{
return (Left < Right) ;
}
// -----------
// IsGreater :
// -----------
Standard_Boolean TCollection_CompareOfReal::IsGreater (
const Standard_Real &Left,const Standard_Real &Right) const
{
return (Left > Right) ;
}

View File

@@ -0,0 +1,195 @@
-- File: TCollection_DataMap.cdl
-- Created: Fri Jan 8 12:16:17 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class DataMap from TCollection
(TheKey as any;
TheItem as any;
Hasher as any) -- as MapHasher(TheKey)
inherits BasicMap from TCollection
---Purpose: The DataMap is a Map to store keys with associated
-- Items.An entry of a DataMap is composed of both the key and the item.
-- The DataMap can be seen as an extended array where
-- the Keys are the indices. For this reason the
-- operator () is defined on DataMap to fetch an Item
-- from a Key. So the following syntax can be used :
--
-- anItem = aMap(aKey);
-- aMap(aKey) = anItem;
--
-- This analogy has its limit. aMap(aKey) = anItem
-- can be done only if aKey was previously bound to
-- an item in the map.
-- DataMap is a generic class which depends on three parameters:
-- - Key is the type of key for an entry in the map,
-- - Item is the type of element associated with a key in the map,
-- - Hasher is the type of hasher on keys.
-- Use a DataMapIterator iterator to explore a DataMap map.
-- Notes:
-- - An iterator class is automatically instantiated from the
-- TCollection_DataMapIterator generic class at the
-- time of instantiation of a DataMap map.
-- - TCollection_MapHasher class describes the
-- functions required for a Hasher object.
raises
DomainError from Standard,
NoSuchObject from Standard
class DataMapNode from TCollection
inherits MapNode from TCollection
uses MapNodePtr from TCollection
is
Create(K : TheKey; I : TheItem; n : MapNodePtr from TCollection) returns DataMapNode from TCollection;
--- Purpose: Constructs a DataMap with NbBuckets (defaulted to 1) buckets.
-- Note that the map will be automatically redimensioned
-- during its use if the number of entries becomes too large.
-- Use:
-- - the function Bind to add an entry (key, item) in the map,
-- - operator() to read an item from a key, or to assign a
-- new value to this item,
-- - the function UnBind to remove an entry (key, item) from the map,
-- - and a map iterator to explore the map.
---C++: inline
Key(me) returns TheKey;
---C++: return &
---C++: inline
Value(me) returns TheItem;
---C++: return &
---C++: inline
fields
myKey : TheKey;
myValue : TheItem;
end;
class DataMapIterator inherits BasicMapIterator from TCollection
---Purpose: Functions used for iterating the contents of a DataMap
-- Note: an iterator class is automatically instantiated from
-- this generic class at the time of instantiation of a DataMap.
-- Warning
-- - A map is a non-ordered data structure. The order in
-- which entries of a map are explored by the iterator
-- depends on its contents, and change when the map is edited.
-- - It is not recommended to modify the contents of a map
-- during iteration: the result is unpredictable.
raises NoSuchObject from Standard
is
Create returns DataMapIterator from TCollection;
---Purpose: Creates an undefined Iterator (empty); use the function Initialize to define the map to explore.
Create (aMap : DataMap from TCollection)
returns DataMapIterator from TCollection;
---Purpose: Creates an Iterator on the map <aMap>.
Initialize(me : in out; aMap : DataMap from TCollection)
---Level: Public
---Purpose: Sets, or resets the Iterator in the map <aMap>.
is static;
Key(me) returns any TheKey
---Purpose: Returns the current Key. An error is raised if
-- the iterator is empty (More returns False).
-- Note: Key is the type of key for an entry in the explored DataMap map.
-- Exceptions
-- Standard_NoSuchObject if this iterator is empty (i.e.
-- when the function More returns false).
---C++: return const &
raises
NoSuchObject from Standard
is static;
Value(me) returns any TheItem
---Purpose: Returns the item of the current entry in the map for this iterator.
-- Note: Item is the type of element bound to a key in the explored DataMap map.
-- Exceptions
-- Standard_NoSuchObject if this iterator is empty (i.e.
-- when the function More returns false)
---C++: return const &
raises
NoSuchObject from Standard
is static;
end DataMapIterator from TCollection;
is
Create(NbBuckets : Integer = 1) returns DataMap from TCollection;
---Purpose: Creates a DataMap with <NbBuckets> buckets. Without
-- arguments the map is automatically dimensioned.
Create(Other : DataMap from TCollection) returns DataMap from TCollection
---Purpose: As copying Map is an expensive operation it is
-- incorrect to do it implicitly. This constructor is private and
-- will raise an error if the Map is not empty.
-- To copy the content of a DataMap use the Assign method (operator =).
raises DomainError from Standard
is private;
Assign(me : in out; Other : DataMap from TCollection)
returns DataMap from TCollection
---Purpose: Copies the contents of the map Other into this map.
-- Note that this method is an alias of operator =.
---C++: alias operator =
---C++: return &
is static;
ReSize(me : in out; NbBuckets : Integer)
---Level: Public
---Purpose: Changes the number of buckets of <me> to be
-- <NbBuckets>. The keys already stored in the map are kept.
is static;
Clear(me : in out)
---Purpose: Removes all keys in the map.
---C++: alias ~
is static;
Bind(me : in out; K : TheKey; I : TheItem) returns Boolean
---Purpose: Adds the Key <K> to the Map <me> with the Item
-- <I>. Returns True if the Key was not already in
-- the Map. If the Key was already in the Map the
-- Item in the Map is replaced.
is static;
IsBound(me; K : TheKey) returns Boolean
---Purpose: Returns True if the key <K> is stored in the map <me>.
is static;
UnBind(me : in out; K : TheKey) returns Boolean
---Purpose: Removes the Key <K> from the map. Returns True if
-- the Key was in the Map.
-- Returns false if the key K was not in this map.
is static;
Find(me; K : TheKey) returns any TheItem
---Level: Public
---Purpose: Returns the Item stored with the Key <K> in the Map.
-- Trigger: An exception is raised when <K> is not in the map.
raises NoSuchObject from Standard
---C++: alias operator()
---C++: return const &
is static;
ChangeFind(me : in out; K : TheKey) returns any TheItem
---Level: Public
---Purpose: Returns the Item stored with the Key <K> in the
-- Map. This Item can be modified with the syntax
-- aMap(K) = newItem;
-- Trigger: An exception is raised when <K> is not in the map.
---C++: alias operator()
---C++: return &
raises NoSuchObject from Standard
is static;
end DataMap;

View File

@@ -0,0 +1,268 @@
// Lastly modified by :
// +---------------------------------------------------------------------------+
// ! szy ! Modified Assign method ! 7-05-2003! 3.0-00-2!
// +---------------------------------------------------------------------------+
// File: TCollection_DataMap.gxx
// Created: Fri Jan 8 16:33:21 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <Standard_DomainError.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : TCollection_DataMap
//purpose :
//=======================================================================
TCollection_DataMap::TCollection_DataMap(const Standard_Integer NbBuckets) :
TCollection_BasicMap(NbBuckets,Standard_True)
{
}
//=======================================================================
//function : TCollection_DataMap
//purpose :
//=======================================================================
TCollection_DataMap::TCollection_DataMap(const TCollection_DataMap& Other) :
TCollection_BasicMap(Other.NbBuckets(),Standard_True)
{
if (!Other.IsEmpty())
Standard_DomainError::Raise("TCollection:Copy of DataMap");
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
TCollection_DataMap& TCollection_DataMap::Assign
(const TCollection_DataMap& Other)
{
// very simple implementation
// not optimal (recompute the hashcode values)
if (this == &Other) return *this;
Clear();
// ReSize(Other.NbBuckets());
if (!Other.IsEmpty()) {
ReSize(Other.Extent());
for (TCollection_DataMapIterator It(Other); It.More(); It.Next()) {
Bind(It.Key(),It.Value());
}
}
return *this;
}
//=======================================================================
//function : ReSize
//purpose :
//=======================================================================
void TCollection_DataMap::ReSize(const Standard_Integer N)
{
Standard_Integer newBuck;
Standard_Address newData1=NULL, dummy=NULL;
if (BeginResize(N,newBuck,newData1,dummy)) {
if (myData1) {
TCollection_DataMapNode** newdata = (TCollection_DataMapNode**) newData1;
TCollection_DataMapNode** olddata = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode *p, *q;
Standard_Integer i,k;
for (i = 0; i <= NbBuckets(); i++) {
if (olddata[i]) {
p = olddata[i];
while (p) {
k = Hasher::HashCode(p->Key(),newBuck);
q = (TCollection_DataMapNode*) p->Next();
p->Next() = newdata[k];
newdata[k] = p;
p = q;
}
}
}
}
EndResize(N,newBuck,newData1,dummy);
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TCollection_DataMap::Clear()
{
if (!IsEmpty()) {
Standard_Integer i;
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode *p,*q;
for (i = 0; i <= NbBuckets(); i++) {
if (data[i]) {
p = data[i];
while (p) {
q = (TCollection_DataMapNode*) p->Next();
delete p;
p = q;
}
}
}
}
TCollection_BasicMap::Destroy();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Boolean TCollection_DataMap::Bind(const TheKey& K, const TheItem& I)
{
if (Resizable()) ReSize(Extent());
TCollection_DataMapNode** data = (TCollection_DataMapNode**)myData1;
Standard_Integer k = Hasher::HashCode(K,NbBuckets());
TCollection_DataMapNode* p = data[k];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
p->Value() = I;
return Standard_False;
}
p = (TCollection_DataMapNode*) p->Next();
}
Increment();
data[k] = new TCollection_DataMapNode(K,I,data[k]);
return Standard_True;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_DataMap::IsBound(const TheKey& K) const
{
if (IsEmpty()) return Standard_False;
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return Standard_True;
}
p = (TCollection_DataMapNode*) p->Next();
}
return Standard_False;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean TCollection_DataMap::UnBind(const TheKey& K)
{
if (IsEmpty()) return Standard_False;
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
Standard_Integer k = Hasher::HashCode(K,NbBuckets());
TCollection_DataMapNode* p = data[k];
TCollection_DataMapNode* q = NULL;
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
Decrement();
if (q) q->Next() = p->Next();
else data[k] = (TCollection_DataMapNode*) p->Next();
delete p;
return Standard_True;
}
q = p;
p = (TCollection_DataMapNode*) p->Next();
}
return Standard_False;
}
//=======================================================================
//function : Find
//purpose :
//=======================================================================
const TheItem& TCollection_DataMap::Find(const TheKey& K) const
{
Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::Find");
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return p->Value();
}
p = (TCollection_DataMapNode*) p->Next();
}
Standard_NoSuchObject::Raise("TCollection_DataMap::Find");
return p->Value();
}
//=======================================================================
//function : ChangeFind
//purpose :
//=======================================================================
TheItem& TCollection_DataMap::ChangeFind(const TheKey& K)
{
Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::ChangeFind");
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return p->Value();
}
p = (TCollection_DataMapNode*) p->Next();
}
Standard_NoSuchObject::Raise("TCollection_DataMap::ChangeFind");
return p->Value();
}
// method of the iterator
//=======================================================================
//function : Key
//purpose :
//=======================================================================
const TheKey& TCollection_DataMapIterator::Key() const
{
Standard_NoSuchObject_Raise_if(!More(),"TCollection_DataMapIterator::Key");
return ((TCollection_DataMapNode*) myNode)->Key();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const TheItem& TCollection_DataMapIterator::Value() const
{
Standard_NoSuchObject_Raise_if(!More(),"TCollection_DataMapIterator::Value");
return ((TCollection_DataMapNode*) myNode)->Value();
}
// @@SDM: begin
// Copyright Open CasCade......................................Version 5.0-00
// Lastly modified by : szy Date : 7-05-2003
// File history synopsis (creation,modification,correction)
// +---------------------------------------------------------------------------+
// ! Developer ! Comments ! Date ! Version !
// +-----------!-----------------------------------------!----------!----------+
// ! rle ! Creation ! 8-01-1993! 5.0-00-2!
// ! szy ! Modified Assign method ! 7-05-2003! 5.0-00-2!
// +---------------------------------------------------------------------------+
// @@SDM: end

View File

@@ -0,0 +1,34 @@
// File: TCollection_DataMapIterator.gxx
// Created: Fri Feb 26 19:21:18 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//function : TCollection_DataMapIterator
//purpose :
//=======================================================================
TCollection_DataMapIterator::TCollection_DataMapIterator() :
TCollection_BasicMapIterator()
{}
//=======================================================================
//function : TCollection_DataMapIterator
//purpose :
//=======================================================================
TCollection_DataMapIterator::TCollection_DataMapIterator(const TCollection_DataMap& aMap) :
TCollection_BasicMapIterator(aMap)
{}
//=======================================================================
//function : TCollection_DataMapIterator
//purpose :
//=======================================================================
void TCollection_DataMapIterator::Initialize(const TCollection_DataMap& aMap)
{
TCollection_BasicMapIterator::Initialize(aMap);
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,16 @@
inline TCollection_DataMapNode::TCollection_DataMapNode(const TheKey& K, const TheItem& I,const TCollection_MapNodePtr& n)
: TCollection_MapNode(n),myKey(K)
{
myValue = I;
}
inline TheKey& TCollection_DataMapNode::Key() const
{
return (TheKey&)myKey;
}
inline TheItem& TCollection_DataMapNode::Value() const
{
return (TheItem&)myValue;
}

View File

@@ -0,0 +1,201 @@
-- File: TCollection_DoubleMap.cdl
-- Created: Fri Jan 8 17:15:50 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class DoubleMap from TCollection (TheKey1 as any;
TheKey2 as any;
Hasher1 as any; -- as MapHasher(TheKey1)
Hasher2 as any) -- as MapHasher(TheKey2)
inherits BasicMap from TCollection
---Purpose:
-- A map used to bind pairs of keys (Key1,Key2) and
-- retrieve them in linear time. Key1 is referenced as the
-- first key of the DoubleMap and Key2 as the second key.
-- An entry of a DoubleMap is composed of a pair of two
-- keys: the first key and the second key.
-- DoubleMap is a generic class which depends on four parameters:
-- - Key1 is the type of the first key for an entry in the map,
-- - Key2 is the type of the second key for an entry in the map,
-- - Hasher1 is the type of hasher on first keys,
-- - Hasher2 is the type of hasher on second keys.
-- Use a DoubleMapIterator to explore a DoubleMap map.
-- Notes:
-- - An iterator class is automatically instantiated from the
-- TCollection_DoubleMapIterator class at the time of
-- instantiation of a DoubleMap map.
-- - TCollection_MapHasher class describes the
-- functions required for a Hasher1 or a Hasher2 object.
raises
DomainError from Standard,
MultiplyDefined from Standard,
NoSuchObject from Standard
class DoubleMapNode from TCollection
inherits MapNode from TCollection
uses MapNodePtr from TCollection
is
Create(K1 : TheKey1; K2 : TheKey2; n1,n2 : MapNodePtr from TCollection) returns DoubleMapNode from TCollection;
---C++: inline
Key1(me) returns TheKey1;
---C++: return &
---C++: inline
Key2(me) returns TheKey2;
---C++: return &
---C++: inline
Next2(me) returns MapNodePtr from TCollection;
---C++: return &
---C++: inline
fields
myKey1 : TheKey1;
myKey2 : TheKey2;
myNext2 : MapNodePtr from TCollection;
end;
class DoubleMapIterator inherits BasicMapIterator from TCollection
---Purpose: Functions used for iterating the contents of a DoubleMap map.
-- Note: an iterator class is automatically instantiated from
-- this generic class at the time of instantiation of a DoubleMap map.
-- Warning
-- - A map is a non-ordered data structure. The order in
-- which entries of a map are explored by the iterator
-- depends on its contents, and changes when the map is edited.
-- - It is not recommended to modify the contents of a map
-- during iteration: the result is unpredictable.
raises NoSuchObject from Standard
is
Create returns DoubleMapIterator from TCollection;
---Purpose: Creates an undefined Iterator (empty) use the
--- function Initialize to define the map to explore.
Create (aMap : DoubleMap from TCollection)
returns DoubleMapIterator from TCollection;
---Purpose: Creates an Iterator on the map <aMap>.
Initialize(me : in out; aMap : DoubleMap from TCollection)
---Level: Public
---Purpose: Sets or resets the Iterator in the map <aMap>.
is static;
Key1(me) returns any TheKey1
---Purpose: Returns the first key, of the current
-- entry in the map for this iterator.
-- Note: Key1 and Key2 are the types of the first and second
-- keys for an entry in the explored DoubleMap map.
-- Exceptions
-- Standard_NoSuchObject if this iterator is empty (i.e.
-- when the function More returns false).
---C++: return const &
raises
NoSuchObject from Standard
is static;
Key2(me) returns any TheKey2
---Purpose: Returns the second key, of the current
-- entry in the map for this iterator.
-- Note: Key1 and Key2 are the types of the first and second
-- keys for an entry in the explored DoubleMap map.
-- Exceptions
-- Standard_NoSuchObject if this iterator is empty (i.e.
-- when the function More returns false).
---C++: return const &
raises
NoSuchObject from Standard
is static;
end DoubleMapIterator from TCollection;
is
Create(NbBuckets : Integer = 1) returns DoubleMap from TCollection;
---Purpose: Creates a DoubleMap with <NbBuckets> buckets. Without
-- arguments the map is automatically dimensioned.
Create(Other : DoubleMap from TCollection)
returns DoubleMap from TCollection
---Purpose: As copying Map is an expensive operation it is
-- incorrect to do it implicitly. This constructor is private and
-- will raise an error if the Map is not empty. To copy the
-- content of a Map use the Assign method (operator =).
raises DomainError from Standard
is private;
Assign(me : in out; Other : DoubleMap from TCollection)
returns DoubleMap from TCollection
---Purpose: Copies the contents of the map Other into this map.
-- Note that this method is an alias of operator =.
---C++: alias operator =
---C++: return &
is static;
ReSize(me : in out; NbBuckets : Integer)
---Purpose: Changes the number of buckets of this map to N.
-- The entries (Key1 + Key2) already stored in this map are maintained.
is static;
Clear(me : in out)
---Level: Public
---Purpose: Removes all keys from the map.
---C++: alias ~
is static;
Bind(me : in out; K1 : TheKey1; K2 : TheKey2)
---Level: Public
---Purpose: Adds the pair <K1>,<K2> to the map.
-- Trigger: An exception is raised if K1 or K2 are already bound.
raises MultiplyDefined from Standard
is static;
AreBound(me; K1 : TheKey1; K2 : TheKey2) returns Boolean
---Level: Public
---Purpose: Returns True if <K1> and <K2> are bound to each other in the map <me>.
is static;
IsBound1(me; K : TheKey1) returns Boolean
---Level: Public
---Purpose: Returns True if the TheKey <K> is bound in the map <me>.
is static;
IsBound2(me; K : TheKey2) returns Boolean
---Level: Public
---Purpose: Returns True if the key <K> is bound in the map <me>.
is static;
Find1(me; K : TheKey1) returns any TheKey2
---Level: Public
---Purpose: Returns the Key2 bound to <K> in the map.
---C++: return const &
raises NoSuchObject
is static;
Find2(me; K : TheKey2) returns any TheKey1
---Level: Public
---Purpose: Returns the Key1 bound to <K> in the map.
---C++: return const &
raises NoSuchObject
is static;
UnBind1(me : in out; K : TheKey1) returns Boolean
---Level: Public
---Purpose: Unbind the Key <K> from the map. Returns True if
-- the Key was bound in the Map.
is static;
UnBind2(me : in out; K : TheKey2) returns Boolean
---Level: Public
---Purpose: Unbind the Key <K> from the map. Returns True if
-- the Key was bound in the Map.
is static;
end DoubleMap;

View File

@@ -0,0 +1,389 @@
// Lastly modified by :
// +---------------------------------------------------------------------------+
// ! szy ! Modified Assign method ! 7-05-2003! 3.0-00-3!
// +---------------------------------------------------------------------------+
// File: TCollection_DoubleMap.gxx
// Created: Fri Jan 8 18:15:52 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <Standard_DomainError.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : TCollection_DoubleMap
//purpose :
//=======================================================================
TCollection_DoubleMap::TCollection_DoubleMap(const Standard_Integer NbBuckets):
TCollection_BasicMap(NbBuckets,Standard_False)
{
}
//=======================================================================
//function : TCollection_DoubleMap
//purpose :
//=======================================================================
TCollection_DoubleMap::TCollection_DoubleMap
(const TCollection_DoubleMap& Other) :
TCollection_BasicMap(Other.NbBuckets(),Standard_False)
{
if (Other.Extent() != 0)
Standard_DomainError::Raise("TCollection:Copy of DoubleMap");
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
TCollection_DoubleMap& TCollection_DoubleMap::Assign
(const TCollection_DoubleMap& Other)
{
if (this == &Other) return *this;
Clear();
// ReSize(Other.NbBuckets());
if (!Other.IsEmpty()) {
ReSize(Other.Extent());
for (TCollection_DoubleMapIterator It(Other); It.More(); It.Next()) {
Bind(It.Key1(),It.Key2());
}
}
return *this;
}
//=======================================================================
//function : ReSize
//purpose :
//=======================================================================
void TCollection_DoubleMap::ReSize(const Standard_Integer N)
{
Standard_Integer newBuck;
Standard_Address newData1=NULL, newData2=NULL;
if (BeginResize(N,newBuck,newData1,newData2)) {
if (myData1) {
TCollection_DoubleMapNode** newdata1 = (TCollection_DoubleMapNode**) newData1;
TCollection_DoubleMapNode** newdata2 = (TCollection_DoubleMapNode**) newData2;
TCollection_DoubleMapNode** olddata1 = (TCollection_DoubleMapNode**) myData1;
TCollection_DoubleMapNode *p, *q;
Standard_Integer i,k1,k2;
for (i = 0; i <= NbBuckets(); i++) {
if (olddata1[i]) {
p = olddata1[i];
while (p) {
k1 = Hasher1::HashCode(p->Key1(),newBuck);
k2 = Hasher2::HashCode(p->Key2(),newBuck);
q = (TCollection_DoubleMapNode*) p->Next();
p->Next() = newdata1[k1];
p->Next2() = newdata2[k2];
newdata1[k1] = p;
newdata2[k2] = p;
p = q;
}
}
}
}
EndResize(N,newBuck,newData1,newData2);
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TCollection_DoubleMap::Clear()
{
if (!IsEmpty()) {
Standard_Integer i;
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**) myData1;
// TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**) myData2;
TCollection_DoubleMapNode *p,*q;
for (i = 0; i <= NbBuckets(); i++) {
p = data1[i];
while (p) {
q = (TCollection_DoubleMapNode*) p->Next();
delete p;
p = q;
}
}
}
TCollection_BasicMap::Destroy();
}
//=======================================================================
//function : Bind
//purpose :
//=======================================================================
void TCollection_DoubleMap::Bind(const TheKey1& K1, const TheKey2& K2)
{
if (Resizable()) ReSize(Extent());
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**)myData1;
TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**)myData2;
Standard_Integer k1 = Hasher1::HashCode(K1,NbBuckets());
Standard_Integer k2 = Hasher2::HashCode(K2,NbBuckets());
TCollection_DoubleMapNode* p;
p = data1[k1];
while (p) {
if (Hasher1::IsEqual(p->Key1(),K1))
Standard_MultiplyDefined::Raise("DoubleMap:Bind");
p = (TCollection_DoubleMapNode*) p->Next();
}
p = data2[k2];
while (p) {
if (Hasher2::IsEqual(p->Key2(),K2))
Standard_MultiplyDefined::Raise("DoubleMap:Bind");
p = (TCollection_DoubleMapNode*)p->Next2();
}
p = new TCollection_DoubleMapNode(K1,K2,data1[k1],data2[k2]);
data1[k1] = p;
data2[k2] = p;
Increment();
}
//=======================================================================
//function : AreBound
//purpose :
//=======================================================================
Standard_Boolean TCollection_DoubleMap::AreBound(const TheKey1& K1,
const TheKey2& K2) const
{
if (IsEmpty()) return Standard_False;
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**)myData1;
TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**)myData2;
Standard_Integer k1 = Hasher1::HashCode(K1,NbBuckets());
Standard_Integer k2 = Hasher2::HashCode(K2,NbBuckets());
TCollection_DoubleMapNode *p1, *p2;
p1 = data1[k1];
while (p1) {
if (Hasher1::IsEqual(p1->Key1(),K1)) break;
p1 = (TCollection_DoubleMapNode*) p1->Next();
}
if (p1 == NULL) return Standard_False;
p2 = data2[k2];
while (p2) {
if (Hasher2::IsEqual(p2->Key2(),K2))
break;
p2 = (TCollection_DoubleMapNode*)p2->Next2();
}
if (p2 == NULL) return Standard_False;
return p1 == p2;
}
//=======================================================================
//function : IsBound1
//purpose :
//=======================================================================
Standard_Boolean TCollection_DoubleMap::IsBound1(const TheKey1& K1) const
{
if (IsEmpty()) return Standard_False;
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**)myData1;
Standard_Integer k1 = Hasher1::HashCode(K1,NbBuckets());
TCollection_DoubleMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher1::IsEqual(p1->Key1(),K1)) return Standard_True;
p1 = (TCollection_DoubleMapNode*) p1->Next();
}
return Standard_False;
}
//=======================================================================
//function : IsBound2
//purpose :
//=======================================================================
Standard_Boolean TCollection_DoubleMap::IsBound2(const TheKey2& K2) const
{
if (IsEmpty()) return Standard_False;
TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**)myData2;
Standard_Integer k2 = Hasher2::HashCode(K2,NbBuckets());
TCollection_DoubleMapNode *p2;
p2 = data2[k2];
while (p2) {
if (Hasher2::IsEqual(p2->Key2(),K2)) return Standard_True;
p2 = (TCollection_DoubleMapNode*)p2->Next2();
}
return Standard_False;
}
//=======================================================================
//function : Find1
//purpose :
//=======================================================================
const TheKey2& TCollection_DoubleMap::Find1(const TheKey1& K1) const
{
Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DoubleMap::Find1");
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**)myData1;
Standard_Integer k1 = Hasher1::HashCode(K1,NbBuckets());
TCollection_DoubleMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher1::IsEqual(p1->Key1(),K1)) return p1->Key2();
p1 = (TCollection_DoubleMapNode*) p1->Next();
}
Standard_NoSuchObject::Raise("TCollection_DoubleMap::Find1");
return p1->Key2();
}
//=======================================================================
//function : Find2
//purpose :
//=======================================================================
const TheKey1& TCollection_DoubleMap::Find2(const TheKey2& K2) const
{
Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DoubleMap::Find2");
TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**)myData2;
Standard_Integer k2 = Hasher2::HashCode(K2,NbBuckets());
TCollection_DoubleMapNode *p2;
p2 = data2[k2];
while (p2) {
if (Hasher2::IsEqual(p2->Key2(),K2)) return p2->Key1();
p2 = (TCollection_DoubleMapNode*)p2->Next2();
}
Standard_NoSuchObject::Raise("TCollection_DoubleMap::Find2");
return p2->Key1();
}
//=======================================================================
//function : UnBind1
//purpose :
//=======================================================================
Standard_Boolean TCollection_DoubleMap::UnBind1(const TheKey1& K1)
{
if (IsEmpty()) return Standard_False;
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**)myData1;
TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**)myData2;
Standard_Integer k1 = Hasher1::HashCode(K1,NbBuckets());
Standard_Integer k2;
TCollection_DoubleMapNode *p1, *p2, *q1, *q2;
q1 = q2 = NULL;
p1 = data1[k1];
while (p1) {
if (Hasher1::IsEqual(p1->Key1(),K1)) {
// remove from the first
if (q1)
q1->Next() = p1->Next();
else
data1[k1] = (TCollection_DoubleMapNode*) p1->Next();
// remove from the second
k2 = Hasher2::HashCode(p1->Key2(),NbBuckets());
p2 = data2[k2];
while (p2) {
if (p2 == p1) {
if (q2)
q2->Next2() = p2->Next2();
else
data2[k2] = (TCollection_DoubleMapNode*)p2->Next2();
break;
}
q2 = p2;
p2 = (TCollection_DoubleMapNode*)p2->Next2();
}
delete p1;
Decrement();
return Standard_True;
}
q1 = p1;
p1 = (TCollection_DoubleMapNode*) p1->Next();
}
return Standard_False;
}
//=======================================================================
//function : UnBind2
//purpose :
//=======================================================================
Standard_Boolean TCollection_DoubleMap::UnBind2(const TheKey2& K2)
{
if (IsEmpty()) return Standard_False;
TCollection_DoubleMapNode** data1 = (TCollection_DoubleMapNode**)myData1;
TCollection_DoubleMapNode** data2 = (TCollection_DoubleMapNode**)myData2;
Standard_Integer k2 = Hasher2::HashCode(K2,NbBuckets());
Standard_Integer k1;
TCollection_DoubleMapNode *p1, *p2, *q1, *q2;
q1 = q2 = NULL;
p2 = data2[k2];
while (p2) {
if (Hasher2::IsEqual(p2->Key2(),K2)) {
// remove from the second
if (q2)
q2->Next2() = p2->Next2();
else
data2[k2] = (TCollection_DoubleMapNode*)p2->Next2();
// remove from the first
k1 = Hasher1::HashCode(p2->Key1(),NbBuckets());
p1 = data1[k1];
while (p1) {
if (p2 == p1) {
if (q1)
q1->Next() = p1->Next();
else
data1[k1] = (TCollection_DoubleMapNode*) p1->Next();
break;
}
q1 = p1;
p1 = (TCollection_DoubleMapNode*) p1->Next();
}
delete p2;
Decrement();
return Standard_True;
}
q2 = p2;
p2 = (TCollection_DoubleMapNode*)p2->Next2();
}
return Standard_False;
}
// method of the iterator
//=======================================================================
//function : Key1
//purpose :
//=======================================================================
const TheKey1& TCollection_DoubleMapIterator::Key1() const
{
Standard_NoSuchObject_Raise_if(!More(),"TCollection_DoubleMapIterator::Key1");
return ((TCollection_DoubleMapNode*) myNode)->Key1();
}
//=======================================================================
//function : Key2
//purpose :
//=======================================================================
const TheKey2& TCollection_DoubleMapIterator::Key2() const
{
Standard_NoSuchObject_Raise_if(!More(),"TCollection_DoubleMapIterator::Key2");
return ((TCollection_DoubleMapNode*) myNode)->Key2();
}
// @@SDM: begin
// Copyright Open CasCade......................................Version 5.0-00
// Lastly modified by : szy Date : 7-05-2003
// File history synopsis (creation,modification,correction)
// +---------------------------------------------------------------------------+
// ! Developer ! Comments ! Date ! Version !
// +-----------!-----------------------------------------!----------!----------+
// ! rle ! Creation ! 8-01-1993! 5.0-00-3!
// ! szy ! Modified Assign method ! 7-05-2003! 5.0-00-3!
// +---------------------------------------------------------------------------+
// @@SDM: end

View File

@@ -0,0 +1,34 @@
// File: TCollection_DoubleMapIterator.gxx
// Created: Fri Feb 26 19:25:39 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//function : TCollection_DoubleMapIterator
//purpose :
//=======================================================================
TCollection_DoubleMapIterator::TCollection_DoubleMapIterator() :
TCollection_BasicMapIterator()
{}
//=======================================================================
//function : TCollection_DoubleMapIterator
//purpose :
//=======================================================================
TCollection_DoubleMapIterator::TCollection_DoubleMapIterator(const TCollection_DoubleMap& aMap) :
TCollection_BasicMapIterator(aMap)
{}
//=======================================================================
//function : TCollection_DoubleMapIterator
//purpose :
//=======================================================================
void TCollection_DoubleMapIterator::Initialize(const TCollection_DoubleMap& aMap)
{
TCollection_BasicMapIterator::Initialize(aMap);
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,21 @@
inline TCollection_DoubleMapNode::TCollection_DoubleMapNode(const TheKey1& K1,const TheKey2& K2,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2)
: TCollection_MapNode(n1),myKey1(K1),myKey2(K2),myNext2(n2)
{
}
inline TheKey1& TCollection_DoubleMapNode::Key1() const
{
return (TheKey1&)myKey1;
}
inline TheKey2& TCollection_DoubleMapNode::Key2() const
{
return (TheKey2&)myKey2;
}
inline TCollection_MapNodePtr& TCollection_DoubleMapNode::Next2() const
{
return (TCollection_MapNodePtr&)myNext2;
}

View File

@@ -0,0 +1,363 @@
-- File: TCollection_ExtendedString.cdl
-- Created: Mon Feb 22 16:58:21 1993
-- Author: Mireille MERCIEN
-- <mip@sdsun4>
---Copyright: Matra Datavision 1993
class ExtendedString from TCollection
---Purpose: A variable-length sequence of "extended"
-- (UNICODE) characters (16-bit character type). It
-- provides editing operations with built-in memory
-- management to make ExtendedString objects
-- easier to use than ordinary extended character arrays.
-- ExtendedString objects follow "value
-- semantics", that is, they are the actual strings,
-- not handles to strings, and are copied through
-- assignment. You may use HExtendedString
-- objects to get handles to strings.
uses AsciiString from TCollection
raises
NullObject,
OutOfRange,
NumericError,
NegativeValue
is
Create returns ExtendedString from TCollection;
---Purpose: Initializes a ExtendedString to an empty ExtendedString.
Create( astring : CString; isMultiByte : Boolean = Standard_False)
returns ExtendedString from TCollection
raises NullObject;
---Purpose: Creation by converting a CString to an extended string.
Create( astring : ExtString)
returns ExtendedString from TCollection
raises NullObject;
---Purpose: Creation by converting an ExtString to an extended string.
Create ( aChar : Character) returns ExtendedString from TCollection;
---Purpose: Initializes a AsciiString with a single character.
Create ( aChar : ExtCharacter) returns ExtendedString from TCollection;
---Purpose: Initializes a ExtendedString with a single character.
Create ( length : Integer; filler : ExtCharacter)
returns ExtendedString from TCollection;
---Purpose: Initializes a ExtendedString with <length> space allocated.
-- and filled with <filler>.This is useful for buffers.
Create ( value : Integer ) returns ExtendedString from TCollection
---Purpose: Initializes an ExtendedString with an integer value
raises NullObject;
Create ( value : Real ) returns ExtendedString from TCollection
---Purpose: Initializes an ExtendedString with a real value
raises NullObject;
Create ( astring : ExtendedString from TCollection )
returns ExtendedString from TCollection;
---Purpose: Initializes a ExtendedString with another ExtendedString.
Create( astring : AsciiString from TCollection)
returns ExtendedString from TCollection;
---Purpose: Creation by converting a normal Ascii string to an extended string.
AssignCat (me : out ; other : ExtendedString from TCollection)
is static;
---Purpose: Appends the other extended string to this extended string.
-- Note that this method is an alias of operator +=.
-- Example: aString += anotherString
---C++: alias operator +=
Cat (me ; other : ExtendedString from TCollection)
returns ExtendedString from TCollection
is static;
---Level: Public
---Purpose: Appends <other> to me.
---Example: aString = aString + anotherString
---C++: alias operator +
ChangeAll(me : out; aChar, NewChar : ExtCharacter)
is static;
---Level: Public
---Purpose: Substitutes all the characters equal to aChar by NewChar
-- in the ExtendedString <me>.
-- The substitution can be case sensitive.
-- If you don't use default case sensitive, no matter wether aChar
-- is uppercase or not.
---Example:
-- me = "Histake" -> ChangeAll('H','M',Standard_True)
-- gives me = "Mistake"
Clear (me : out)
is static;
---Level: Public
---Purpose: Removes all characters contained in <me>.
-- This produces an empty ExtendedString.
Copy (me : out ; fromwhere : ExtendedString from TCollection)
is static;
---Level: Public
---Purpose: Copy <fromwhere> to <me>.
-- Used as operator =
---Example: aString = anotherString;
---C++: alias operator =
Destroy (me : in out)
is static;
---Level: Public
---Purpose: Frees memory allocated by ExtendedString.
---C++: alias ~
Insert (me : out; where : Integer; what : ExtCharacter)
---Level: Public
---Purpose: Insert a Character at position <where>.
---Example:
-- aString contains "hy not ?"
-- aString.Insert(1,'W'); gives "Why not ?"
-- aString contains "Wh"
-- aString.Insert(3,'y'); gives "Why"
-- aString contains "Way"
-- aString.Insert(2,'h'); gives "Why"
raises OutOfRange from Standard
is static;
Insert (me : out; where : Integer; what : ExtendedString from TCollection)
---Level: Public
---Purpose: Insert a ExtendedString at position <where>.
raises OutOfRange from Standard
is static;
IsEqual (me ; other : ExtString )
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns true if the characters in this extended
-- string are identical to the characters in the other extended string.
-- Note that this method is an alias of operator ==
---C++: alias operator ==
IsEqual (me ; other : ExtendedString from TCollection)
returns Boolean from Standard
is static;
---Purpose: Returns true if the characters in this extended
-- string are identical to the characters in the other extended string.
-- Note that this method is an alias of operator ==
---C++: alias operator ==
IsDifferent (me ; other : ExtString )
returns Boolean from Standard
is static;
---Purpose: Returns true if there are differences between the
-- characters in this extended string and the other extended string.
-- Note that this method is an alias of operator !=.
---C++: alias operator !=
IsDifferent (me ; other : ExtendedString from TCollection)
returns Boolean from Standard
is static;
---Purpose: Returns true if there are differences between the
-- characters in this extended string and the other extended string.
-- Note that this method is an alias of operator !=.
---C++: alias operator !=
IsLess (me ; other : ExtString )
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE if <me> is less than <other>.
---C++: alias operator <
IsLess (me ; other : ExtendedString from TCollection)
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE if <me> is less than <other>.
---C++: alias operator <
IsGreater (me ; other : ExtString )
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE if <me> is greater than <other>.
---C++: alias operator >
IsGreater (me ; other : ExtendedString from TCollection)
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE if <me> is greater than <other>.
---C++: alias operator >
IsAscii(me)
returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns True if the ExtendedString contains only
-- "Ascii Range" characters .
Length (me) returns Integer from Standard
is static;
---Level: Public
---Purpose: Returns number of characters in <me>.
-- This is the same functionality as 'strlen' in C.
Print (me ; astream : out OStream)
is static;
---Level: Public
---Purpose: Displays <me> .
---C++: alias "friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_ExtendedString& astring);"
RemoveAll(me : out; what : ExtCharacter)
is static;
---Level: Public
---Purpose: Removes every <what> characters from <me>.
Remove (me : out ; where : Integer ; ahowmany : Integer=1)
---Level: Public
---Purpose: Erases <ahowmany> characters from position <where>,<where> included.
---Example:
-- aString contains "Hello"
-- aString.Erase(2,2) erases 2 characters from position 1
-- This gives "Hlo".
raises OutOfRange from Standard
is static;
Search (me ; what : ExtendedString from TCollection)
returns Integer from Standard
is static;
---Level: Public
---Purpose: Searches a ExtendedString in <me> from the beginning
-- and returns position of first item <what> matching.
-- it returns -1 if not found.
SearchFromEnd (me ; what : ExtendedString from TCollection)
returns Integer from Standard
is static;
---Level: Public
---Purpose: Searches a ExtendedString in another ExtendedString from the
-- end and returns position of first item <what> matching.
-- it returns -1 if not found.
SetValue(me : out; where : Integer; what : ExtCharacter)
---Level: Public
---Purpose: Replaces one character in the ExtendedString at position <where>.
-- If <where> is less than zero or greater than the length of <me>
-- an exception is raised.
---Example:
-- aString contains "Garbake"
-- astring.Replace(6,'g') gives <me> = "Garbage"
raises OutOfRange from Standard
is static;
SetValue(me : out; where : Integer; what : ExtendedString from TCollection)
---Level: Public
---Purpose: Replaces a part of <me> by another ExtendedString see above.
raises OutOfRange from Standard
is static;
Split(me : out; where : Integer) returns ExtendedString from TCollection
---Purpose: Splits this extended string into two sub-strings at position where.
-- - The second sub-string (from position
-- where + 1 of this string to the end) is
-- returned in a new extended string.
-- - this extended string is modified: its last
-- characters are removed, it becomes equal to
-- the first sub-string (from the first character to position where).
-- Example:
-- aString contains "abcdefg"
-- aString.Split(3) gives <me> = "abc" and returns "defg"
raises OutOfRange from Standard
is static;
Token (me ; separators : ExtString; whichone : Integer=1)
returns ExtendedString from TCollection
---Purpose: Extracts <whichone> token from <me>.
-- By default, the <separators> is set to space and tabulation.
-- By default, the token extracted is the first one (whichone = 1).
-- <separators> contains all separators you need.
-- If no token indexed by <whichone> is found, it returns an empty AsciiString.
-- Example:
-- aString contains "This is a message"
-- aString.Token() returns "This"
-- aString.Token(" ",4) returns "message"
-- aString.Token(" ",2) returns "is"
-- aString.Token(" ",9) returns ""
-- Other separators than space character and tabulation are allowed :
-- aString contains "1234; test:message , value"
-- aString.Token("; :,",4) returns "value"
-- aString.Token("; :,",2) returns "test"
raises NullObject from Standard
is static;
ToExtString(me) returns ExtString
---Level: Public
---Purpose: Returns pointer to ExtString
---C++: return const
is static;
Trunc (me : out ; ahowmany : Integer)
---Purpose: Truncates <me> to <ahowmany> characters.
-- Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
-- Exceptions
-- Standard_OutOfRange if ahowmany is greater
-- than the length of this string.
raises OutOfRange from Standard
is static;
Value(me ; where : Integer) returns ExtCharacter
---Purpose: Returns character at position <where> in <me>.
-- If <where> is less than zero or greater than the lenght of
-- <me>, an exception is raised.
-- Example:
-- aString contains "Hello"
-- aString.Value(2) returns 'e'
-- Exceptions
-- Standard_OutOfRange if where lies outside
-- the bounds of this extended string.
raises OutOfRange from Standard
is static;
HashCode(myclass ; astring : ExtendedString from TCollection; Upper : Integer)
returns Integer;
---Purpose: Returns a hashed value for the extended string
-- astring within the range 1..Upper.
-- Note: if astring is ASCII, the computed value is
-- the same as the value computed with the HashCode function on a
-- TCollection_AsciiString string composed with equivalent ASCII characters
IsEqual(myclass ; string1 : ExtendedString from TCollection;
string2 : ExtendedString from TCollection)
returns Boolean;
---Purpose: Returns true if the characters in this extended
-- string are identical to the characters in the other extended string.
-- Note that this method is an alias of operator ==.
ToUTF8CString(me; theCString : out PCharacter from Standard)
returns Integer from Standard;
---Purpose: Converts the internal <mystring> to UTF8 coding and
-- returns length of the out CString. A memory for the
-- <theCString> should be allocated before call!
LengthOfCString(me)
returns Integer from Standard;
---Purpose: Returns expected CString length in UTF8 coding.
-- It can be used for memory calculation before converting
-- to CString containing symbols in UTF8 coding.
ConvertToUnicode(me : out; astring : CString)
returns Boolean is private;
---Purpose: Returns true if the input CString was successfuly converted
-- to UTF8 coding
fields
mystring : PExtCharacter from Standard;
mylength : Integer from Standard;
end ExtendedString from TCollection;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
generic class HArray1 from TCollection
(ItemHArray1 as any;
TheArray1 as Array1 from TCollection(ItemHArray1))
inherits TShared
raises RangeError from Standard,
DimensionMismatch from Standard,
OutOfRange from Standard,
OutOfMemory from Standard
---Purpose: The class HArray1 represents unidimensionnal arrays
-- of fixed size dynamically dimensioned at construction time.
-- As with a C array, the access time to an HArray1 indexed
-- item is constant and is independent of the array size.
-- Arrays are commonly used as elementary data structures
-- for more complex objects.
-- HArray1 objects are handles to arrays.
-- - HArray1 arrays may be shared by several objects.
-- - You may use a TCollection_Array1 structure to have the actual array.
-- HArray1 is a generic class which depends on two parameters:
-- - Item, the type of element in the array,
-- - Array, the actual type of array handled by HArray1.
-- This is an instantiation with Item of the
-- TCollection_Array1 generic class.
-- Warning
-- HArray1 indexes start and end at a user-defined position.
-- Thus, when accessing an item, you must base the index on
-- the lower and upper bounds of the array.
is
Create (Low, Up: Integer from Standard)
returns mutable HArray1 from TCollection
---Purpose: Creates an array of lower bound <Low> and upper
-- bound <Up>. Range error is raised when <Up> is less than <Low>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Create (Low, Up: Integer from Standard; V : ItemHArray1)
returns mutable HArray1 from TCollection
---Purpose: Creates an array of lower bound <Low> and upper
-- bound <Up>. Range error is raised when <Up> is less than <Low>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Init(me : mutable; V : ItemHArray1);
---Purpose: Initialize the array with the value <V>
Length (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the number of elements of <me>.
---C++: inline
is static ;
Lower (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the lower bound.
---C++: inline
is static ;
Upper (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the upper bound.
---C++: inline
is static ;
SetValue (me : mutable; Index: Integer from Standard; Value: ItemHArray1)
---Level: Public
---Purpose: Assigns the value <Value> to the <Index>th item of this array.
raises
OutOfRange from Standard
---C++: inline
is static ;
Value (me; Index:Integer from Standard) returns any ItemHArray1
---Level: Public
---Purpose: Returns the value of the <Index>th element of the array.
---C++: inline
---C++: return const &
raises
OutOfRange from Standard
is static ;
ChangeValue (me : mutable; Index:Integer from Standard) returns any
ItemHArray1
---Level: Public
---Purpose: Returns the value of the <Index>th element of the array.
---C++: inline
---C++: return &
raises
OutOfRange from Standard
is static ;
Array1(me) returns TheArray1
---Purpose: Returns the Array array used as a field by this array;
-- the returned array is not modifiable;
---C++: return const &
---C++: inline
is static;
ChangeArray1(me : mutable) returns TheArray1
---Purpose: Returns a modifiable reference on the Array array
-- used as a field by this array, in order to modify it.
---C++: return &
---C++: inline
is static;
fields
myArray : TheArray1;
end HArray1 ;

View File

@@ -0,0 +1,43 @@
#include <Standard_OutOfRange.hxx>
#include <Standard_DimensionMismatch.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_OutOfMemory.hxx>
//=======================================================================
//function : TCollection_HArray1
//purpose :
//=======================================================================
TCollection_HArray1::TCollection_HArray1(const Standard_Integer First,
const Standard_Integer Last) :
myArray(First,Last)
{
}
//=======================================================================
//function : TCollection_HArray1
//purpose :
//=======================================================================
TCollection_HArray1::TCollection_HArray1(const Standard_Integer First,
const Standard_Integer Last,
const ItemHArray1& V) :
myArray(First,Last)
{
myArray.Init(V);
}
//=======================================================================
//function : TCollection_HArray1
//purpose :
//=======================================================================
void TCollection_HArray1::Init(const ItemHArray1& V)
{
myArray.Init(V);
}

View File

@@ -0,0 +1,88 @@
// File: TCollection_HArray1.lxx
// Created: Thu Mar 11 18:34:58 1993
// Author: Remi LEQUETTE
// <rle@phobox>
//=======================================================================
//function : Length
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray1::Length () const
{
return myArray.Length();
}
//=======================================================================
//function : Lower
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray1::Lower () const
{
return myArray.Lower();
}
//=======================================================================
//function : Upper
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray1::Upper () const
{
return myArray.Upper();
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
inline void TCollection_HArray1::SetValue (const Standard_Integer Index,
const ItemHArray1& Value)
{
myArray.SetValue(Index,Value);
}
//=======================================================================
//function : Array1
//purpose :
//=======================================================================
inline const TheArray1& TCollection_HArray1::Array1() const
{
return myArray;
}
//=======================================================================
//function : ChangeArray1
//purpose :
//=======================================================================
inline TheArray1& TCollection_HArray1::ChangeArray1()
{
return myArray;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
inline const ItemHArray1& TCollection_HArray1::Value(const Standard_Integer Index) const
{
return myArray(Index);
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
inline ItemHArray1& TCollection_HArray1::ChangeValue(const Standard_Integer Index)
{
return myArray(Index);
}

View File

@@ -0,0 +1,129 @@
-- File: TCollection_HArray2.cdl
-- Created: Thu Dec 17 18:00:36 1992
-- Author: Mireille MERCIEN
-- <mip@sdsun4>
---Copyright: Matra Datavision 1992
generic class HArray2 from TCollection
(ItemHArray2 as any;
TheArray2 as Array2 from TCollection(ItemHArray2))
inherits TShared
---Purpose: The class HArray2 represents bi-dimensionnal arrays
-- of fixed size dynamically dimensioned at construction time.
-- As with a C array, the access time to an HArray2 indexed
-- item is constant and is independent of the array size.
-- Arrays are commonly used as elementary data structures for more complex objects.
-- HArray2 objects are handles to arrays.
-- - HArray2 arrays may be shared by several objects.
-- - You may use a TCollection_Array2 structure to get the actual array.
-- HArray2 is a generic class which depends on two parameters:
-- - Item, the type of element in the array,
-- - Array, the actual type of array handled by HArray2.
-- This is an instantiation with Item of the TCollection_Array2 generic class.
-- Warning
-- HArray2 indexes start and end at a user-defined position.
-- Thus, when accessing an item you must base the indexes
-- on the lower and upper bounds of the array.
raises
RangeError from Standard,
OutOfRange from Standard,
OutOfMemory from Standard,
DimensionMismatch from Standard
is
Create (R1, R2, C1, C2: Integer from Standard)
returns mutable HArray2 from TCollection
---Purpose: Creates an array of lower bound <R1><C1> and upper
-- bound <R2><C2>. Range from Standard error is
-- raised when <R2> is less than <R1> or <C2> is less than <C1>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Create (R1, R2, C1, C2: Integer from Standard; V : ItemHArray2)
returns mutable HArray2 from TCollection
---Purpose: Creates an array of lower bound <R1><C1> and upper
-- bound <R2><C2>. Range from Standard error is
-- raised when <R2> is less than <R1> or <C2> is less than <C1>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Init(me : mutable; V : ItemHArray2) ;
---Purpose: Initializes the array with the value <V>
ColLength (me) returns Integer from Standard
---Purpose: Returns the number of rows of <me>.
---C++: inline
is static ;
RowLength (me) returns Integer from Standard
---Purpose: Returns the number of columns of <me>.
---C++: inline
is static;
LowerCol (me) returns Integer from Standard
---Purpose: Returns the lower column number of the array.
---C++: inline
is static ;
LowerRow (me) returns Integer from Standard
---Purpose: Returns the lower row number of the array.
---C++: inline
is static ;
UpperCol (me) returns Integer from Standard
---Purpose: Returns the upper column number of the array.
---C++: inline
is static ;
UpperRow (me) returns Integer from Standard
---Purpose: Returns the upper row number of the array.
---C++: inline
is static ;
SetValue (me : mutable; Row, Col: Integer from Standard;
Value: ItemHArray2)
---Purpose: Assigns the value Value to the (Row,Col) item of this array.
---C++: inline
raises OutOfRange from Standard
is static ;
Value (me; Row,Col: Integer from Standard) returns any ItemHArray2
---Level: Public
---Purpose: Returns the value of the element of index <Row><Col>
---C++: return const &
raises OutOfRange from Standard
is static;
ChangeValue (me : mutable; Row,Col: Integer from Standard)
returns any ItemHArray2
---Level: Public
---Purpose: Returns the value of the element of index <Row><Col>
---C++: return &
raises OutOfRange from Standard
is static;
Array2(me) returns TheArray2
---Purpose: Returns the Array array used as a field by this array;
-- the returned array is not modifiable.
---C++: return const &
---C++: inline
is static;
ChangeArray2(me : mutable) returns TheArray2
---Purpose: - Returns a modifiable reference on the Array array
-- used as a field by this array, in order to modify it.
---C++: return &
---C++: inline
is static;
fields
myArray : TheArray2;
end HArray2 ;

View File

@@ -0,0 +1,84 @@
#include <Standard_OutOfRange.hxx>
#include <Standard_DimensionMismatch.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_OutOfMemory.hxx>
//=======================================================================
//function : TCollection_HArray2
//purpose :
//=======================================================================
TCollection_HArray2::TCollection_HArray2 (const Standard_Integer R1,
const Standard_Integer R2,
const Standard_Integer C1,
const Standard_Integer C2) :
myArray(R1,R2,C1,C2)
{}
//=======================================================================
//function : TCollection_HArray2
//purpose :
//=======================================================================
TCollection_HArray2::TCollection_HArray2 (const Standard_Integer R1,
const Standard_Integer R2,
const Standard_Integer C1,
const Standard_Integer C2,
const ItemHArray2& V) :
myArray(R1,R2,C1,C2)
{myArray.Init(V);}
//=======================================================================
//function : TCollection_HArray2
//purpose :
//=======================================================================
void TCollection_HArray2::Init(const ItemHArray2& V)
{ myArray.Init(V);}
//=======================================================================
//function : IsSameState
//purpose :
//=======================================================================
//Standard_Boolean TCollection_HArray2::IsSameState
// (const Handle (TCollection_HArray2)& other) const
//{
// const TheArray2 & otherArray =
// Handle(TCollection_HArray2)::DownCast(other)->Array2();
// for (Standard_Integer i = myArray.LowerRow();
// i <= myArray.UpperRow();
// i++) {
// for (Standard_Integer j = myArray.LowerCol();
// j <= myArray.UpperCol();
// j++) {
// if (!(myArray(i,j) == otherArray(i,j))) return Standard_False;
// }
// }
// return Standard_True;
//}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const ItemHArray2& TCollection_HArray2::Value(const Standard_Integer Row,
const Standard_Integer Col) const
{
return myArray(Row,Col);
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
ItemHArray2& TCollection_HArray2::ChangeValue(const Standard_Integer Row,
const Standard_Integer Col)
{
return myArray(Row,Col);
}

View File

@@ -0,0 +1,98 @@
// File: TCollection_HArray2.lxx
// Created: Thu Mar 11 20:02:10 1993
// Author: Remi LEQUETTE
// <rle@phobox>
//=======================================================================
//function : ColLength
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray2::ColLength () const
{
return myArray.ColLength();
}
//=======================================================================
//function : LowerCol
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray2::LowerCol () const
{
return myArray.LowerCol();
}
//=======================================================================
//function : LowerRow
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray2::LowerRow () const
{
return myArray.LowerRow();
}
//=======================================================================
//function : RowLength
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray2::RowLength () const
{
return myArray.RowLength();
}
//=======================================================================
//function : UpperRow
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray2::UpperRow () const
{
return myArray.UpperRow();
}
//=======================================================================
//function : UpperCol
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HArray2::UpperCol () const
{
return myArray.UpperCol();
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
inline void TCollection_HArray2::SetValue ( const Standard_Integer Row,
const Standard_Integer Col,
const ItemHArray2& Value )
{
myArray.SetValue(Row,Col,Value);
}
//=======================================================================
//function : Array2
//purpose :
//=======================================================================
inline const TheArray2& TCollection_HArray2::Array2() const
{
return myArray;
}
//=======================================================================
//function : ChangeArray2
//purpose :
//=======================================================================
inline TheArray2& TCollection_HArray2::ChangeArray2()
{
return myArray;
}

View File

@@ -0,0 +1,582 @@
-- File: TCollection_HAsciiString.cdl
-- Created: Tue Dec 15 10:53:08 1992
-- Author: Mireille MERCIEN
-- <mip@sdsun4>
---Copyright: Matra Datavision 1992
class HAsciiString from TCollection
inherits TShared from MMgt
---Purpose: A variable-length sequence of ASCII characters
-- (normal 8-bit character type). It provides editing
-- operations with built-in memory management to
-- make HAsciiString objects easier to use than ordinary character arrays.
-- HAsciiString objects are handles to strings.
-- - HAsciiString strings may be shared by several objects.
-- - You may use an AsciiString object to get the actual string.
-- Note: HAsciiString objects use an AsciiString string as a field.
uses AsciiString from TCollection
,HExtendedString from TCollection
raises
NullObject,
OutOfRange,
NumericError,
NegativeValue
is
Create returns mutable HAsciiString from TCollection;
---Purpose: Initializes a HAsciiString to an empty AsciiString.
Create ( message : CString )
returns mutable HAsciiString from TCollection
---Purpose: Initializes a HAsciiString with a CString.
raises NullObject;
Create ( aChar : Character)
returns mutable HAsciiString from TCollection;
---Purpose: Initializes a HAsciiString with a single character.
Create ( length : Integer; filler : Character)
returns mutable HAsciiString from TCollection;
---Purpose: Initializes a HAsciiString with <length> space allocated.
-- and filled with <filler>.This is useful for buffers.
Create ( value : Integer )
returns mutable HAsciiString from TCollection
---Purpose: Initializes a HAsciiString with an integer value
raises NullObject;
Create ( value : Real )
returns mutable HAsciiString from TCollection
---Purpose: Initializes a HAsciiString with a real value
raises NullObject;
Create ( aString : AsciiString from TCollection)
returns mutable HAsciiString from TCollection;
---Purpose: Initializes a HAsciiString with a HAsciiString.
Create ( aString : HAsciiString from TCollection)
returns mutable HAsciiString from TCollection;
---Purpose: Initializes a HAsciiString with a HAsciiString.
Create ( aString : HExtendedString from TCollection;
replaceNonAscii: Character from Standard)
returns mutable HAsciiString from TCollection
raises OutOfRange from Standard;
---Purpose: Initializes a HAsciiString with a HAsciiString.
-- If replaceNonAscii is non-null charecter, it will be used
-- in place of any non-ascii character found in the source string.
-- Otherwise, raises OutOfRange exception if at least one character
-- in the source string is not in the "Ascii range".
AssignCat (me : mutable ; other : CString)
---C++: inline
---Level: Public
---Purpose: Appends <other> to me.
raises NullObject;
AssignCat (me : mutable ; other : HAsciiString from TCollection);
---C++: inline
---Level: Public
---Purpose: Appends <other> to me.
-- Example: aString = aString + anotherString
Capitalize(me : mutable);
---Level: Public
---Purpose: Converts the first character into its corresponding
-- upper-case character and the other characters into lowercase.
-- Example:
-- before
-- me = "hellO "
-- after
-- me = "Hello "
Cat (me ; other : CString)
returns mutable HAsciiString from TCollection;
---Level: Public
---Purpose: Creates a new string by concatenation of this
-- ASCII string and the other ASCII string.
-- Example:
-- aString = aString + anotherString
-- aString = aString + "Dummy"
-- aString contains "I say "
-- aString = aString + "Hello " + "Dolly"
-- gives "I say Hello Dolly"
-- Warning: To catenate more than one CString, you must put a String before.
-- So the following example is WRONG !
-- aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
-- This rule is applicable to AssignCat (operator +=) too.
Cat (me ; other : HAsciiString from TCollection)
returns mutable HAsciiString from TCollection;
---Level: Public
---Purpose: Creates a new string by concatenation of this
-- ASCII string and the other ASCII string.
-- Example: aString = aString + anotherString
Center(me : mutable;
Width : Integer from Standard;
Filler : Character from Standard)
raises NegativeValue from Standard;
---Purpose: Modifies this ASCII string so that its length
-- becomes equal to Width and the new characters
-- are equal to Filler. New characters are added
-- both at the beginning and at the end of this string.
-- If Width is less than the length of this ASCII string, nothing happens.
-- Example
-- Handle(TCollection_HAsciiString)
-- myAlphabet
-- = new
-- TCollection_HAsciiString
-- ("abcdef");
-- myAlphabet->Center(9,' ');
-- assert ( !strcmp(
-- myAlphabet->ToCString(),
-- " abcdef ") );
ChangeAll(me : mutable; aChar, NewChar : Character;
CaseSensitive : Boolean=Standard_True);
---Purpose: Replaces all characters equal to aChar by
-- NewChar in this ASCII string. The substitution is
-- case sensitive if CaseSensitive is true (default value).
-- If you do not use the default case sensitive
-- option, it does not matter whether aChar is upper-case or not.
-- Example
-- Handle(TCollection_HAsciiString)
-- myMistake = new
-- TCollection_HAsciiString
-- ("Hather");
-- myMistake->ChangeAll('H','F');
-- assert ( !strcmp(
-- myMistake->ToCString(),
-- "Father") );
Clear (me : mutable);
---Level: Public
---Purpose: Removes all characters contained in <me>.
-- This produces an empty HAsciiString.
FirstLocationInSet(me; Set : HAsciiString from TCollection;
FromIndex : Integer from Standard;
ToIndex : Integer from Standard)
returns Integer
raises OutOfRange from Standard;
---Level: Public
---Purpose: Returns the index of the first character of <me> that is
-- present in <Set>.
-- The search begins to the index FromIndex and ends to the
-- the index ToIndex.
-- Returns zero if failure.
-- Raises an exception if FromIndex or ToIndex is out of range
-- Example:
-- before
-- me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
-- after
-- me = "aabAcAa"
-- returns
-- 1
FirstLocationNotInSet(me; Set : HAsciiString from TCollection;
FromIndex : Integer;
ToIndex : Integer) returns Integer
raises OutOfRange from Standard;
---Level: Public
---Purpose: Returns the index of the first character of <me>
-- that is not present in the set <Set>.
-- The search begins to the index FromIndex and ends to the
-- the index ToIndex in <me>.
-- Returns zero if failure.
-- Raises an exception if FromIndex or ToIndex is out of range.
-- Example:
-- before
-- me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
-- after
-- me = "aabAcAa"
-- returns
-- 3
Insert (me : mutable; where : Integer; what : Character)
---Level: Public
---Purpose: Insert a Character at position <where>.
-- Example:
-- aString contains "hy not ?"
-- aString.Insert(1,'W'); gives "Why not ?"
-- aString contains "Wh"
-- aString.Insert(3,'y'); gives "Why"
-- aString contains "Way"
-- aString.Insert(2,'h'); gives "Why"
raises OutOfRange;
Insert (me : mutable; where : Integer; what : CString )
---Level: Public
---Purpose: Insert a HAsciiString at position <where>.
raises OutOfRange;
Insert (me : mutable; where : Integer; what : HAsciiString from TCollection)
---Level: Public
---Purpose: Insert a HAsciiString at position <where>.
raises OutOfRange;
InsertAfter(me : mutable; Index : Integer;
other : HAsciiString from TCollection)
raises OutOfRange from Standard;
---Purpose: Inserts the other ASCII string a after a specific index in the string <me>
-- Example:
-- before
-- me = "cde" , Index = 0 , other = "ab"
-- after
-- me = "abcde" , other = "ab"
InsertBefore(me : mutable; Index : Integer;
other : HAsciiString from TCollection)
raises OutOfRange from Standard;
---Purpose: Inserts the other ASCII string a before a specific index in the string <me>
-- Raises an exception if Index is out of bounds
-- Example:
-- before
-- me = "cde" , Index = 1 , other = "ab"
-- after
-- me = "abcde" , other = "ab"
IsEmpty(me) returns Boolean from Standard;
---Purpose: Returns True if the string <me> contains zero character
IsLess (me ; other : HAsciiString from TCollection) returns Boolean;
---Level: Public
---Purpose: Returns TRUE if <me> is 'ASCII' less than <other>.
IsGreater (me ; other : HAsciiString from TCollection) returns Boolean;
---Level: Public
---Purpose: Returns TRUE if <me> is 'ASCII' greater than <other>.
IntegerValue(me) returns Integer
---Level: Public
---Purpose: Converts a HAsciiString containing a numeric expression to
-- an Integer.
-- Example: "215" returns 215.
raises NumericError;
IsIntegerValue(me) returns Boolean from Standard;
---Purpose: Returns True if the string contains an integer value.
IsRealValue(me) returns Boolean from Standard;
---Purpose: Returns True if the string contains a real value.
IsAscii(me) returns Boolean from Standard;
---Level: Public
---Purpose: Returns True if the string contains only ASCII characters
-- between ' ' and '~'.
-- This means no control character and no extended ASCII code.
IsDifferent(me ; S : HAsciiString from TCollection)
---Level: Public
---Purpose: Returns True if the string S not contains same characters than
-- the string <me>.
returns Boolean from Standard;
IsSameString(me ; S : HAsciiString from TCollection)
---Level: Public
---Purpose: Returns True if the string S contains same characters than the
-- string <me>.
returns Boolean from Standard;
IsSameString(me ; S : HAsciiString from TCollection ;
CaseSensitive : Boolean from Standard)
---Level: Public
---Purpose: Returns True if the string S contains same characters than the
-- string <me>.
returns Boolean from Standard;
LeftAdjust(me : mutable);
---Level: Public
---Purpose: Removes all space characters in the begining of the string
LeftJustify(me : mutable; Width : Integer;
Filler : Character from Standard)
raises NegativeValue from Standard;
---Level: Public
---Purpose: Left justify.
-- Length becomes equal to Width and the new characters are
-- equal to Filler
-- if Width < Length nothing happens
-- Raises an exception if Width is less than zero
-- Example:
-- before
-- me = "abcdef" , Width = 9 , Filler = ' '
-- after
-- me = "abcdef "
Length (me) returns Integer;
---C++: inline
---Level: Public
---Purpose: Returns number of characters in <me>.
-- This is the same functionality as 'strlen' in C.
Location(me; other : HAsciiString from TCollection;
FromIndex : Integer;
ToIndex : Integer)
returns Integer
raises OutOfRange from Standard;
---Level: Public
---Purpose: returns an index in the string <me> of the first occurence
-- of the string S in the string <me> from the starting index
-- FromIndex to the ending index ToIndex
-- returns zero if failure
-- Raises an exception if FromIndex or ToIndex is out of range.
-- Example:
-- before
-- me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7
-- after
-- me = "aabAaAa"
-- returns
-- 4
Location(me; N : Integer; C : Character from Standard;
FromIndex : Integer;
ToIndex : Integer)
returns Integer
raises OutOfRange from Standard;
---Level: Public
---Purpose: Returns the index of the nth occurence of the character C
-- in the string <me> from the starting index FromIndex to the
-- ending index ToIndex.
-- Returns zero if failure.
-- Raises an exception if FromIndex or ToIndex is out of range
-- Example:
-- before
-- me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5
-- after
-- me = "aabAa"
-- returns 5
LowerCase (me : mutable);
---Level: Public
---Purpose: Converts <me> to its lower-case equivalent.
Prepend(me : mutable; other : HAsciiString from TCollection);
---Level: Public
---Purpose: Inserts the other string at the begining of the string <me>
-- Example:
-- before
-- me = "cde" , S = "ab"
-- after
-- me = "abcde" , S = "ab"
Print (me ; astream : out OStream);
---Purpose: Prints this string on the stream <astream>.
RealValue(me) returns Real
---Level: Public
---Purpose: Converts a string containing a numeric expression to a Real.
-- Example:
-- "215" returns 215.0.
-- "3.14159267" returns 3.14159267.
raises NumericError;
RemoveAll(me :mutable; C : Character from Standard;
CaseSensitive : Boolean from Standard);
---Level: Public
---Purpose: Remove all the occurences of the character C in the string
-- Example:
-- before
-- me = "HellLLo", C = 'L' , CaseSensitive = True
-- after
-- me = "Hello"
RemoveAll(me : mutable; what : Character);
---Level: Public
---Purpose: Removes every <what> characters from <me>
Remove (me : mutable ; where : Integer ; ahowmany : Integer=1)
---Level: Public
---Purpose: Erases <ahowmany> characters from position <where>,
-- <where> included.
-- Example:
-- aString contains "Hello"
-- aString.Erase(2,2) erases 2 characters from position 1
-- This gives "Hlo".
raises OutOfRange from Standard;
RightAdjust(me : mutable);
---Level: Public
---Purpose: Removes all space characters at the end of the string.
RightJustify(me : mutable;
Width : Integer;
Filler : Character from Standard)
raises NegativeValue from Standard;
---Level: Public
---Purpose: Right justify.
-- Length becomes equal to Width and the new characters are
-- equal to Filler
-- if Width < Length nothing happens
-- Raises an exception if Width is less than zero
-- Example:
-- before
-- me = "abcdef" , Width = 9 , Filler = ' '
-- after
-- me = " abcdef"
Search (me ; what : CString) returns Integer
---Level: Public
---Purpose: Searches a CString in <me> from the beginning
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
-- Example:
-- aString contains "Sample single test"
-- aString.Search("le") returns 5
--
raises NullObject from Standard;
Search (me ; what : HAsciiString from TCollection) returns Integer;
---Level: Public
---Purpose: Searches a String in <me> from the beginning
-- and returns position of first item <what> matching.
-- it returns -1 if not found.
SearchFromEnd (me ; what : CString) returns Integer
---Level: Public
---Purpose: Searches a CString in a String from the end
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
-- Example:
-- aString contains "Sample single test"
-- aString.SearchFromEnd("le") returns 12
raises NullObject from Standard;
SearchFromEnd (me ; what : HAsciiString from TCollection) returns Integer;
---Level: Public
---Purpose: Searches a HAsciiString in another HAsciiString from the end
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
SetValue(me : mutable; where : Integer; what : Character)
---Level: Public
---Purpose: Replaces one character in the string at position <where>.
-- If <where> is less than zero or greater than the length of <me>
-- an exception is raised.
-- Example:
-- aString contains "Garbake"
-- astring.Replace(6,'g') gives <me> = "Garbage"
raises OutOfRange from Standard;
SetValue(me : mutable; where : Integer; what : CString)
---Level: Public
---Purpose: Replaces a part of <me> in the string at position <where>.
-- If <where> is less than zero or greater than the length of <me>
-- an exception is raised.
-- Example:
-- aString contains "Garbake"
-- astring.Replace(6,'g') gives <me> = "Garbage"
raises OutOfRange from Standard;
SetValue(me : mutable; where : Integer; what : HAsciiString from TCollection)
---Level: Public
---Purpose: Replaces a part of <me> by another string.
raises OutOfRange from Standard;
Split(me : mutable; where : Integer)
returns mutable HAsciiString from TCollection
---Level: Public
---Purpose: Splits a HAsciiString into two sub-strings.
-- Example:
-- aString contains "abcdefg"
-- aString.Split(3) gives <me> = "abc" and returns "defg"
raises OutOfRange from Standard;
SubString(me; FromIndex, ToIndex : Integer)
---Level: Public
---Purpose: Creation of a sub-string of the string <me>.
-- The sub-string starts to the index Fromindex and ends
-- to the index ToIndex.
-- Raises an exception if ToIndex or FromIndex is out of
-- bounds
-- Example:
-- before
-- me = "abcdefg", ToIndex=3, FromIndex=6
-- after
-- me = "abcdefg"
-- returns
-- "cdef"
returns mutable HAsciiString from TCollection
raises OutOfRange from Standard;
ToCString(me) returns CString;
---Level: Public
---Purpose: Returns pointer to string (char *)
-- This is useful for some casual manipulations
-- Because this "char *" is 'const', you can't modify its contents.
---C++: inline
Token (me ; separators : CString=" \t" ; whichone : Integer=1)
returns mutable HAsciiString from TCollection
---Level: Public
---Purpose: Extracts <whichone> token from <me>.
-- By default, the <separators> is set to space and tabulation.
-- By default, the token extracted is the first one (whichone = 1).
-- <separators> contains all separators you need.
-- If no token indexed by <whichone> is found, it returns an empty String.
-- Example:
-- aString contains "This is a message"
-- aString.Token() returns "This"
-- aString.Token(" ",4) returns "message"
-- aString.Token(" ",2) returns "is"
-- aString.Token(" ",9) returns ""
-- Other separators than space character and tabulation are allowed
-- aString contains "1234; test:message , value"
-- aString.Token("; :,",4) returns "value"
-- aString.Token("; :,",2) returns "test"
raises NullObject from Standard;
Trunc (me : mutable ; ahowmany : Integer)
---Level: Public
---Purpose: Truncates <me> to <ahowmany> characters.
-- Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
raises OutOfRange from Standard;
UpperCase (me : mutable);
---Level: Public
---Purpose: Converts <me> to its upper-case equivalent.
UsefullLength(me) returns Integer;
---Level: Public
---Purpose: Length of the string ignoring all spaces (' ') and the
-- control character at the end.
Value(me ; where : Integer) returns Character
---Level: Public
---Purpose: Returns character at position <where> in <me>.
-- If <where> is less than zero or greater than the lenght of
-- <me>, an exception is raised.
-- Example:
-- aString contains "Hello"
-- aString.Value(2) returns 'e'
raises OutOfRange from Standard;
String(me) returns AsciiString from TCollection;
---C++: return const &
---C++: inline
---Level: Advanced
---Purpose: Returns the field myString.
ShallowCopy(me) returns mutable like me;
---Level: Advanced
---C++: function call
ShallowDump(me ; s: in out OStream);
---Level: Avanced
---C++: function call
IsSameState (me ; other : like me)
---Level: Advanced
returns Boolean;
fields
myString : AsciiString from TCollection;
end;

View File

@@ -0,0 +1,651 @@
//Copyright: Matra Datavision 1992,1993
//Created By M. MERCIEN Dec,15 1992
//
#define OptJr 1
#include <TCollection_HAsciiString.ixx>
#include <TCollection_HExtendedString.hxx>
#include <Standard_String.hxx>
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString():myString(){}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Standard_CString message):myString(message)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const TCollection_AsciiString& astring):myString(astring)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Standard_Character aChar):myString(aChar)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Standard_Integer length,const Standard_Character filler ):myString(length,filler)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Standard_Integer aValue):myString(aValue)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Standard_Real aValue):myString(aValue)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Handle(TCollection_HAsciiString)& astring):myString(astring->String())
{
}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HAsciiString::TCollection_HAsciiString
(const Handle(TCollection_HExtendedString)& astring,
const Standard_Character replaceNonAscii)
: myString(astring->String(), replaceNonAscii)
{
}
// ---------------------------------------------------------------------------
// Capitalize
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Capitalize()
{
myString.Capitalize();
}
// ---------------------------------------------------------------------------
// Cat
// ----------------------------------------------------------------------------
Handle(TCollection_HAsciiString)
TCollection_HAsciiString::Cat(const Standard_CString other) const
{
return new TCollection_HAsciiString(myString.Cat(other));
}
// ---------------------------------------------------------------------------
// Cat
// ----------------------------------------------------------------------------
Handle(TCollection_HAsciiString)
TCollection_HAsciiString::Cat(const Handle(TCollection_HAsciiString)& other)
const
{
return new TCollection_HAsciiString(myString.Cat(other->String() ) );
}
// ---------------------------------------------------------------------------
// Center
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Center
(const Standard_Integer Width ,
const Standard_Character Filler)
{
if (Width < 0) Standard_NegativeValue::Raise();
myString.Center(Width,Filler);
}
// ----------------------------------------------------------------------------
// ChangeAll
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::ChangeAll
(const Standard_Character aChar,
const Standard_Character NewChar,
const Standard_Boolean CaseSensitive)
{
myString.ChangeAll(aChar,NewChar,CaseSensitive);
}
// ----------------------------------------------------------------------------
// Clear
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Clear()
{
myString.Clear();
}
// ----------------------------------------------------------------------------
// FirstLocationInSet
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::FirstLocationInSet
(const Handle(TCollection_HAsciiString)& Set,
const Standard_Integer FromIndex,
const Standard_Integer ToIndex) const
{
if (Length() == 0 || Set->Length() == 0) return 0;
if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
Standard_OutOfRange::Raise();
return (myString.FirstLocationInSet(Set->String(),FromIndex,ToIndex));
}
// ----------------------------------------------------------------------------
// FirstLocationNotInSet
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::FirstLocationNotInSet
(const Handle(TCollection_HAsciiString)& Set,
const Standard_Integer FromIndex,
const Standard_Integer ToIndex) const
{
if (Length() == 0 || Set->Length() == 0) return 0;
if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
Standard_OutOfRange::Raise();
return (myString.FirstLocationNotInSet(Set->String(),FromIndex,ToIndex));
}
// ----------------------------------------------------------------------------
// Insert a Standard_Character before 'where'th Standard_Character
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Insert(const Standard_Integer where,
const Standard_Character what)
{
myString.Insert(where,what);
}
// ----------------------------------------------------------------------------
// Insert
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Insert(const Standard_Integer where,
const Standard_CString what)
{
myString.Insert(where,what);
}
// ----------------------------------------------------------------------------
// Insert
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Insert(const Standard_Integer where,
const Handle(TCollection_HAsciiString)& what)
{
myString.Insert(where,what->String());
}
//------------------------------------------------------------------------
// InsertAfter
//------------------------------------------------------------------------
void TCollection_HAsciiString::InsertAfter
(const Standard_Integer Index, const Handle(TCollection_HAsciiString)& S)
{
Standard_Integer size1 = Length();
#ifndef NOBOUNDCHECK
if (Index < 0 || Index > size1) Standard_OutOfRange::Raise();
#endif
myString.InsertAfter(Index,S->String());
}
//------------------------------------------------------------------------
// InsertBefore
//------------------------------------------------------------------------
void TCollection_HAsciiString::InsertBefore
(const Standard_Integer Index, const Handle(TCollection_HAsciiString)& S)
{
Standard_Integer size1 = Length();
#ifndef NOBOUNDCHECK
if (Index < 1 || Index > size1) Standard_OutOfRange::Raise();
#endif
myString.InsertBefore(Index,S->String());
}
// ----------------------------------------------------------------------------
// IsEmpty
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsEmpty() const
{
return (myString.Length() == 0);
}
// ----------------------------------------------------------------------------
// IsLess
// ----------------------------------------------------------------------------
Standard_Boolean
TCollection_HAsciiString::IsLess(const Handle(TCollection_HAsciiString)& other) const
{
return myString.IsLess(other->String());
}
// ----------------------------------------------------------------------------
// IsGreater
// ----------------------------------------------------------------------------
Standard_Boolean
TCollection_HAsciiString::IsGreater(const Handle(TCollection_HAsciiString)& other) const
{
return myString.IsGreater(other->String());
}
// ----------------------------------------------------------------------------
// IntegerValue
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::IntegerValue() const
{
return myString.IntegerValue();
}
// ----------------------------------------------------------------------------
// IsIntegerValue
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsIntegerValue() const
{
return myString.IsIntegerValue();
}
// ----------------------------------------------------------------------------
// IsRealvalue
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsRealValue() const
{
return myString.IsRealValue();
}
// ----------------------------------------------------------------------------
// IsAscii
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsAscii() const
{
return myString.IsAscii();
}
// ----------------------------------------------------------------------------
// IsDifferent
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsDifferent
(const Handle(TCollection_HAsciiString)& S) const
{
if(S.IsNull()) Standard_NullObject::Raise("TCollection_HAsciiString::IsDifferent");
#if OptJr
if ( myString.Length() == S->Length() ) {
Standard_Boolean KEqual ;
ASCIISTRINGEQUAL( myString.ToCString() , S->ToCString() ,
myString.mylength , KEqual ) ;
return !KEqual ;
}
else
return Standard_True ;
#else
return ( strcmp(myString.ToCString(), S->ToCString()) );
#endif
}
// ----------------------------------------------------------------------------
// IsSameString
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsSameString
(const Handle(TCollection_HAsciiString)& S) const
{
if(S.IsNull()) Standard_NullObject::Raise("TCollection_HAsciiString::IsSameString");
#if OptJr
if ( myString.Length() == S->Length() ) {
Standard_Boolean KEqual ;
ASCIISTRINGEQUAL( myString.ToCString() , S->ToCString() ,
myString.mylength , KEqual ) ;
return KEqual ;
}
else
return Standard_False ;
#else
return ( !strcmp(myString.ToCString(), S->ToCString()) );
#endif
}
// ----------------------------------------------------------------------------
// IsSameString
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsSameString
(const Handle(TCollection_HAsciiString)& S ,
const Standard_Boolean CaseSensitive) const
{
// Handle(TCollection_HAsciiString) H1,H2;
// H1 = UpperCase(This);
// H2 = UpperCase(S);
// return ( H1 == H2));
if(S.IsNull()) Standard_NullObject::Raise("TCollection_HAsciiString::IsSameString");
Standard_Integer size1 = Length();
if ( size1 != S->Length() ) return Standard_False;
#if OptJr
if ( CaseSensitive ) {
Standard_Boolean KEqual ;
ASCIISTRINGEQUAL( myString.ToCString() , S->String().ToCString() ,
size1 , KEqual ) ;
return KEqual ;
}
else {
for ( Standard_Integer i = 1 ; i <= size1; i++) {
if ( toupper( Value(i) ) != toupper( S->Value(i) ) )
return Standard_False;
}
return Standard_True ;
}
#else
// Example of bad sequence of test : CaseSensitive does not change in the loop
Standard_Character C1,C2;
for( Standard_Integer i = 1 ; i <= size1; i++) {
if(CaseSensitive){
if (Value(i) != S->Value(i)) return Standard_False;
}
else {
C1 = Value(i);
C2 = S->Value(i);
if(toupper(C1) != toupper(C2)) return Standard_False;
}
}
return Standard_True;
#endif
}
//------------------------------------------------------------------------
// LeftAdjust
//------------------------------------------------------------------------
void TCollection_HAsciiString::LeftAdjust ()
{
myString.LeftAdjust();
}
//------------------------------------------------------------------------
// LeftJustify
//------------------------------------------------------------------------
void TCollection_HAsciiString::LeftJustify
(const Standard_Integer Width, const Standard_Character Filler)
{
if (Width < 0) Standard_NegativeValue::Raise();
myString.LeftJustify(Width,Filler);
}
//------------------------------------------------------------------------
// Location
//------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::Location
(const Standard_Integer N, const Standard_Character C,
const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
{
if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
Standard_OutOfRange::Raise();
return myString.Location(N,C,FromIndex,ToIndex);
}
//------------------------------------------------------------------------
// Location
//------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::Location
(const Handle(TCollection_HAsciiString)& S, const Standard_Integer FromIndex,
const Standard_Integer ToIndex) const
{
if (Length() == 0 || S->Length() == 0) return 0;
if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
Standard_OutOfRange::Raise();
return myString.Location(S->String(),FromIndex,ToIndex);
}
// ----------------------------------------------------------------------------
// LowerCase
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::LowerCase()
{
myString.LowerCase();
}
//------------------------------------------------------------------------
// Prepend
//------------------------------------------------------------------------
void TCollection_HAsciiString::Prepend
(const Handle(TCollection_HAsciiString)& S)
{
myString.Prepend(S->String());
}
//---------------------------------------------------------------------
// Print
//---------------------------------------------------------------------
void TCollection_HAsciiString::Print(Standard_OStream& S) const
{
myString.Print(S);
}
// ----------------------------------------------------------------------------
// RealValue
// ----------------------------------------------------------------------------
Standard_Real TCollection_HAsciiString::RealValue() const
{
return myString.RealValue();
}
// ----------------------------------------------------------------------------
// RemoveAll
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::RemoveAll
(const Standard_Character what,
const Standard_Boolean CaseSensitive)
{
myString.RemoveAll(what,CaseSensitive);
}
// ----------------------------------------------------------------------------
// RemoveAll
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::RemoveAll(const Standard_Character what)
{
myString.RemoveAll(what);
}
// ----------------------------------------------------------------------------
// Remove
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Remove (const Standard_Integer where,
const Standard_Integer ahowmany)
{
myString.Remove(where,ahowmany);
}
//------------------------------------------------------------------------
// RightAdjust
//------------------------------------------------------------------------
void TCollection_HAsciiString::RightAdjust ()
{
myString.RightAdjust();
}
//------------------------------------------------------------------------
// RightJustify
//------------------------------------------------------------------------
void TCollection_HAsciiString::RightJustify
(const Standard_Integer Width, const Standard_Character Filler)
{
if (Width < 0) Standard_NegativeValue::Raise();
myString.RightJustify(Width,Filler);
}
// ----------------------------------------------------------------------------
// Search
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::Search(const Standard_CString what)const
{
return myString.Search(what);
}
// ----------------------------------------------------------------------------
// Search
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::Search
(const Handle(TCollection_HAsciiString)& what) const
{
return myString.Search(what->String());
}
// ----------------------------------------------------------------------------
// SearchFromEnd
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::SearchFromEnd(const Standard_CString what)const
{
return myString.SearchFromEnd(what);
}
// ----------------------------------------------------------------------------
// SearchFromEnd
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::SearchFromEnd
(const Handle(TCollection_HAsciiString)& what) const
{
return myString.SearchFromEnd(what->String());
}
// ----------------------------------------------------------------------------
// SetValue
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::SetValue(const Standard_Integer where,
const Standard_Character what)
{
myString.SetValue(where,what);
}
// ----------------------------------------------------------------------------
// SetValue
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::SetValue(const Standard_Integer where,const Standard_CString what)
{
myString.SetValue(where,what);
}
// ----------------------------------------------------------------------------
// SetValue
// ---------------------------------------------------------------------------
void TCollection_HAsciiString::SetValue(const Standard_Integer where,
const Handle(TCollection_HAsciiString)& what)
{
myString.SetValue(where, what->String());
}
// ----------------------------------------------------------------------------
// Split
// ----------------------------------------------------------------------------
Handle(TCollection_HAsciiString)
TCollection_HAsciiString::Split(const Standard_Integer where)
{
return new TCollection_HAsciiString(myString.Split(where));
}
// ----------------------------------------------------------------------------
// SubString
// ----------------------------------------------------------------------------
Handle(TCollection_HAsciiString)
TCollection_HAsciiString::SubString(const Standard_Integer FromIndex,
const Standard_Integer ToIndex) const
{
return new TCollection_HAsciiString(myString.SubString(FromIndex,ToIndex));
}
// ----------------------------------------------------------------------------
// Token
// ----------------------------------------------------------------------------
Handle(TCollection_HAsciiString) TCollection_HAsciiString::Token
(const Standard_CString separators,const Standard_Integer whichone) const
{
return new TCollection_HAsciiString(myString.Token(separators,whichone));
}
// ----------------------------------------------------------------------------
// Trunc
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::Trunc(const Standard_Integer ahowmany)
{
myString.Trunc(ahowmany);
}
// ----------------------------------------------------------------------------
// UpperCase
// ----------------------------------------------------------------------------
void TCollection_HAsciiString::UpperCase()
{
myString.UpperCase();
}
// ----------------------------------------------------------------------------
// UsefullLength
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HAsciiString::UsefullLength() const
{
return myString.UsefullLength();
}
// ----------------------------------------------------------------------------
// Value
// ----------------------------------------------------------------------------
Standard_Character TCollection_HAsciiString::Value(const Standard_Integer where) const
{
return myString.Value(where);
}
// ----------------------------------------------------------------------------
// ShallowCopy
// ----------------------------------------------------------------------------
Handle(TCollection_HAsciiString) TCollection_HAsciiString::ShallowCopy() const
{
// Handle(TCollection_HAsciiString) thecopy = new TCollection_HAsciiString;
// for (Standard_Integer i = 1 ; i <= Length() ; i++)
// thecopy->Insert(i,Value(i));
// return thecopy;
return new TCollection_HAsciiString(*this);
}
//---------------------------------------------------------------------
// ShallowDump
//---------------------------------------------------------------------
void TCollection_HAsciiString::ShallowDump(Standard_OStream& S) const
{
S << "begin class HAsciiString "<<endl;
myString.Print(S);
}
// ----------------------------------------------------------------------------
// IsSameState
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HAsciiString::IsSameState
(const Handle(TCollection_HAsciiString)& other) const
{
#if OptJr
if ( myString.Length() == other->Length() ) {
Standard_Boolean KEqual ;
ASCIISTRINGEQUAL( myString.ToCString() , other->ToCString() ,
myString.mylength , KEqual ) ;
return KEqual ;
}
else
return Standard_False ;
#else
return ( !strcmp(myString.mystring , other->ToCString() ));
#endif
}

View File

@@ -0,0 +1,29 @@
// ---------------------------------------------------------------------------
// AssignCat
// ----------------------------------------------------------------------------
inline void TCollection_HAsciiString::AssignCat(const Standard_CString other)
{myString.AssignCat(other);}
// ---------------------------------------------------------------------------
// AssignCat
// ----------------------------------------------------------------------------
inline void TCollection_HAsciiString::AssignCat
(const Handle(TCollection_HAsciiString)& other)
{myString.AssignCat(other->String());}
// ----------------------------------------------------------------------------
// Length
// ----------------------------------------------------------------------------
inline Standard_Integer TCollection_HAsciiString::Length() const
{return myString.mylength;}
// ----------------------------------------------------------------------------
// String
// ----------------------------------------------------------------------------
inline const TCollection_AsciiString& TCollection_HAsciiString::String() const
{return myString;}
// ----------------------------------------------------------------------------
inline Standard_CString TCollection_HAsciiString::ToCString() const
{ return myString.ToCString(); }

View File

@@ -0,0 +1,229 @@
-- File: TCollection_HExtendedString.cdl
-- Created: Wed Mar 17 17:32:41 1993
-- Author: Mireille MERCIEN
-- <mip@sdsun4>
---Copyright: Matra Datavision 1993
class HExtendedString from TCollection
inherits TShared from MMgt
---Purpose: A variable-length sequence of "extended"
-- (UNICODE) characters (16-bit character
-- type). It provides editing operations with
-- built-in memory management to make
-- ExtendedString objects easier to use than
-- ordinary extended character arrays.
-- HExtendedString objects are handles to strings.
-- - HExtendedString strings may be shared by several objects.
-- - You may use an ExtendedString object to get the actual string.
-- Note: HExtendedString objects use an
-- ExtendedString string as a field.
uses ExtendedString from TCollection
,HAsciiString from TCollection
raises
NullObject from Standard,
OutOfRange from Standard,
NumericError from Standard,
NegativeValue from Standard
is
Create returns mutable HExtendedString from TCollection;
---Purpose: Initializes a HExtendedString to an empty ExtendedString.
Create ( message : CString )
returns mutable HExtendedString from TCollection
---Purpose: Initializes a HExtendedString with a CString.
raises NullObject from Standard;
Create ( message : ExtString )
returns mutable HExtendedString from TCollection
---Purpose: Initializes a HExtendedString with an ExtString.
raises NullObject from Standard;
Create ( aChar : ExtCharacter)
returns mutable HExtendedString from TCollection;
---Purpose: Initializes a HExtendedString with a single character.
Create ( length : Integer; filler : ExtCharacter)
returns mutable HExtendedString from TCollection;
---Purpose: Initializes a HExtendedString with <length> space allocated.
-- and filled with <filler>.This is usefull for buffers.
Create ( aString : ExtendedString from TCollection)
returns mutable HExtendedString from TCollection;
---Purpose: Initializes a HExtendedString with a HExtendedString.
Create ( aString : HAsciiString from TCollection)
returns mutable HExtendedString from TCollection;
---Purpose: Initializes a HExtendedString with an HAsciiString.
Create ( aString : HExtendedString from TCollection)
returns mutable HExtendedString from TCollection;
---Purpose: Initializes a HExtendedString with a HExtendedString.
AssignCat (me : mutable ; other : HExtendedString from TCollection);
---Purpose: Appends <other> to me.
Cat (me ; other : HExtendedString from TCollection)
returns mutable HExtendedString from TCollection;
---Level: Public
---Purpose: Returns a string appending <other> to me.
ChangeAll(me : mutable; aChar, NewChar : ExtCharacter);
---Level: Public
---Purpose: Substitutes all the characters equal to aChar by NewChar
-- in the string <me>.
Clear (me : mutable);
---Level: Public
---Purpose: Removes all characters contained in <me>.
-- This produces an empty ExtendedString.
IsEmpty(me) returns Boolean from Standard;
---Purpose: Returns True if the string <me> contains zero character
Insert (me : mutable; where : Integer; what : ExtCharacter)
---Purpose: Insert a ExtCharacter at position <where>.
-- Example:
-- aString contains "hy not ?"
-- aString.Insert(1,'W'); gives "Why not ?"
-- aString contains "Wh"
-- aString.Insert(3,'y'); gives "Why"
-- aString contains "Way"
-- aString.Insert(2,'h'); gives "Why"
raises OutOfRange from Standard;
Insert (me : mutable; where : Integer;
what : HExtendedString from TCollection)
---Purpose: Insert a HExtendedString at position <where>.
raises OutOfRange from Standard;
IsLess (me ; other : HExtendedString from TCollection) returns Boolean;
---Purpose: Returns TRUE if <me> is less than <other>.
IsGreater (me ; other : HExtendedString from TCollection) returns Boolean;
---Purpose: Returns TRUE if <me> is greater than <other>.
IsAscii(me) returns Boolean from Standard;
---Purpose: Returns True if the string contains only "Ascii Range" characters
Length (me) returns Integer;
---Purpose: Returns number of characters in <me>.
-- This is the same functionality as 'strlen' in C.
Remove (me : mutable ; where : Integer ; ahowmany : Integer=1)
---Purpose: Erases <ahowmany> characters from position <where>,
-- <where> included.
-- Example:
-- aString contains "Hello"
-- aString.Erase(2,2) erases 2 characters from position 1
-- This gives "Hlo".
raises OutOfRange from Standard;
RemoveAll(me : mutable; what : ExtCharacter);
---Purpose: Removes every <what> characters from <me>.
SetValue(me : mutable; where : Integer; what : ExtCharacter)
---Purpose: Replaces one character in the string at position <where>.
-- If <where> is less than zero or greater than the length of <me>
-- an exception is raised.
-- Example:
-- aString contains "Garbake"
-- astring.Replace(6,'g') gives <me> = "Garbage"
raises OutOfRange from Standard;
SetValue(me : mutable; where : Integer;
what : HExtendedString from TCollection)
---Level: Public
---Purpose: Replaces a part of <me> by another string.
raises OutOfRange from Standard;
Split(me : mutable; where : Integer)
returns mutable HExtendedString from TCollection
---Purpose: Splits a ExtendedString into two sub-strings.
-- Example:
-- aString contains "abcdefg"
-- aString.Split(3) gives <me> = "abc" and returns "defg"
raises OutOfRange from Standard;
Search (me ; what : HExtendedString from TCollection) returns Integer;
---Level: Public
---Purpose: Searches a String in <me> from the beginning
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
SearchFromEnd (me ; what : HExtendedString from TCollection) returns Integer;
---Level: Public
---Purpose: Searches a ExtendedString in another ExtendedString from the end
-- and returns position of first item <what> matching.
-- It returns -1 if not found.
ToExtString(me) returns ExtString;
---Level: Public
---Purpose: Returns pointer to ExtString
---C++: return const
Token (me ; separators : ExtString; whichone : Integer=1)
returns mutable HExtendedString from TCollection
---Level: Public
---Purpose: Extracts <whichone> token from <me>.
-- By default, the <separators> is set to space and tabulation.
-- By default, the token extracted is the first one (whichone = 1).
-- <separators> contains all separators you need.
-- If no token indexed by <whichone> is found, it returns an empty String.
-- Example:
-- aString contains "This is a message"
-- aString.Token() returns "This"
-- aString.Token(" ",4) returns "message"
-- aString.Token(" ",2) returns "is"
-- aString.Token(" ",9) returns ""
-- Other separators than space character and tabulation are allowed
-- aString contains "1234; test:message , value"
-- aString.Token("; :,",4) returns "value"
-- aString.Token("; :,",2) returns "test"
raises NullObject from Standard;
Trunc (me : mutable ; ahowmany : Integer)
---Purpose: Truncates <me> to <ahowmany> characters.
-- Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
raises OutOfRange from Standard;
Value(me ; where : Integer) returns ExtCharacter
---Purpose: Returns ExtCharacter at position <where> in <me>.
-- If <where> is less than zero or greater than the length of
-- <me>, an exception is raised.
-- Example:
-- aString contains "Hello"
-- aString.Value(2) returns 'e'
raises OutOfRange from Standard;
String(me) returns ExtendedString from TCollection;
---Purpose: Returns the field myString
Print (me ; astream : out OStream);
---Purpose: Displays <me> .
ShallowCopy(me) returns mutable like me;
---C++: function call
ShallowDump(me ; s: in out OStream);
---Level: Advanced
IsSameState (me ; other : like me) returns Boolean;
---Level: Advanced
ChangeString(me) returns ExtendedString from TCollection is private;
---Purpose: Returns the field myString
---C++: return &
fields
myString : ExtendedString from TCollection;
end;

View File

@@ -0,0 +1,317 @@
//Copyright: Matra Datavision 1992,1993
//Created By M. MERCIEN Dec,15 1992
//Modified: C. LEYNADIER Nov,21 1997 (Token et ChangeString)
#include <TCollection_AsciiString.hxx>
#include <TCollection_HExtendedString.ixx>
#include <TCollection_HAsciiString.hxx>
#include <Standard_ExtCharacter.hxx>
#include <Standard_ExtString.hxx>
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString(){}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const Standard_CString message):myString(message)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const Standard_ExtString message):myString(message)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const Standard_ExtCharacter aChar):myString(aChar)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const Standard_Integer length,const Standard_ExtCharacter filler )
:myString(length,filler)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const TCollection_ExtendedString& astring):myString(astring)
{}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const Handle(TCollection_HAsciiString)& astring)
:myString(astring->String())
{
}
// ----------------------------------------------------------------------------
// Create
// ----------------------------------------------------------------------------
TCollection_HExtendedString::TCollection_HExtendedString
(const Handle(TCollection_HExtendedString)& astring)
:myString(astring->ChangeString())
{
}
// ---------------------------------------------------------------------------
// AssignCat
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::AssignCat
(const Handle(TCollection_HExtendedString)& other)
{
myString.AssignCat(other->ChangeString());
}
// ---------------------------------------------------------------------------
// Cat
// ----------------------------------------------------------------------------
Handle(TCollection_HExtendedString) TCollection_HExtendedString::Cat
(const Handle(TCollection_HExtendedString)& other) const
{
return new TCollection_HExtendedString(myString.Cat(other->ChangeString() ) );
}
// ----------------------------------------------------------------------------
// ChangeAll
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::ChangeAll
(const Standard_ExtCharacter aChar,
const Standard_ExtCharacter NewChar)
{
myString.ChangeAll(aChar,NewChar);
}
// ----------------------------------------------------------------------------
// IsEmpty
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HExtendedString::IsEmpty() const
{
return (myString.Length() == 0);
}
// ----------------------------------------------------------------------------
// Clear
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::Clear()
{
myString.Clear();
}
// ----------------------------------------------------------------------------
// Insert a Standard_ExtCharacter before 'where'th Standard_ExtCharacter
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::Insert(const Standard_Integer where,
const Standard_ExtCharacter what)
{
myString.Insert(where,what);
}
// ----------------------------------------------------------------------------
// Insert
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::Insert(const Standard_Integer where,
const Handle(TCollection_HExtendedString)& what)
{
myString.Insert(where,what->ChangeString());
}
// ----------------------------------------------------------------------------
// IsLess
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HExtendedString::IsLess(
const Handle(TCollection_HExtendedString)& other) const
{
return myString.IsLess(other->ChangeString());
}
// ----------------------------------------------------------------------------
// IsGreater
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HExtendedString::IsGreater
(const Handle(TCollection_HExtendedString)& other) const
{
return myString.IsGreater(other->ChangeString());
}
// ----------------------------------------------------------------------------
// IsAscii
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HExtendedString::IsAscii() const
{
return myString.IsAscii();
}
// ----------------------------------------------------------------------------
// Length
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HExtendedString::Length() const
{
return myString.Length();
}
// ----------------------------------------------------------------------------
// Remove
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::Remove (const Standard_Integer where,
const Standard_Integer ahowmany)
{
myString.Remove(where,ahowmany);
}
// ----------------------------------------------------------------------------
// RemoveAll
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::RemoveAll(const Standard_ExtCharacter what)
{
myString.RemoveAll(what);
}
// ----------------------------------------------------------------------------
// SetValue
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::SetValue(
const Standard_Integer where,const Standard_ExtCharacter what)
{
myString.SetValue(where,what);
}
// ----------------------------------------------------------------------------
// SetValue
// ---------------------------------------------------------------------------
void TCollection_HExtendedString::SetValue(const Standard_Integer where,
const Handle(TCollection_HExtendedString)& what)
{
myString.SetValue(where, what->ChangeString());
}
// ----------------------------------------------------------------------------
// Split
// ----------------------------------------------------------------------------
Handle(TCollection_HExtendedString) TCollection_HExtendedString::Split
(const Standard_Integer where)
{
return new TCollection_HExtendedString(myString.Split(where));
}
// ----------------------------------------------------------------------------
// Search
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HExtendedString::Search
(const Handle(TCollection_HExtendedString)& what) const
{
return myString.Search(what->ChangeString());
}
// ----------------------------------------------------------------------------
// SearchFromEnd
// ----------------------------------------------------------------------------
Standard_Integer TCollection_HExtendedString::SearchFromEnd
(const Handle(TCollection_HExtendedString)& what) const
{
return myString.SearchFromEnd(what->ChangeString());
}
// ----------------------------------------------------------------------------
// Token
// ----------------------------------------------------------------------------
Handle(TCollection_HExtendedString) TCollection_HExtendedString::Token
(const Standard_ExtString separators,const Standard_Integer whichone) const
{
return new TCollection_HExtendedString(myString.Token(separators,whichone));
}
// ----------------------------------------------------------------------------
// ToExtString
// ----------------------------------------------------------------------------
const Standard_ExtString TCollection_HExtendedString::ToExtString() const
{
return (myString.ToExtString());
}
// ----------------------------------------------------------------------------
// Trunc
// ----------------------------------------------------------------------------
void TCollection_HExtendedString::Trunc(const Standard_Integer ahowmany)
{
myString.Trunc(ahowmany);
}
// ----------------------------------------------------------------------------
// Value
// ----------------------------------------------------------------------------
Standard_ExtCharacter TCollection_HExtendedString::Value
(const Standard_Integer where) const
{
return myString.Value(where);
}
// ----------------------------------------------------------------------------
// String
// ----------------------------------------------------------------------------
TCollection_ExtendedString TCollection_HExtendedString::String() const
{
return myString;
}
//---------------------------------------------------------------------
// Print
//---------------------------------------------------------------------
void TCollection_HExtendedString::Print(Standard_OStream& S) const
{
S << "begin class HExtendedString "<<endl;
myString.Print(S);
}
// ----------------------------------------------------------------------------
// ShallowCopy
// ----------------------------------------------------------------------------
Handle(TCollection_HExtendedString) TCollection_HExtendedString::ShallowCopy() const
{
Handle(TCollection_HExtendedString) thecopy =
new TCollection_HExtendedString;
for (Standard_Integer i = 1 ; i <= Length() ; i++)
thecopy->Insert(i,Value(i));
return thecopy;
}
//---------------------------------------------------------------------
// ShallowDump
//---------------------------------------------------------------------
void TCollection_HExtendedString::ShallowDump(Standard_OStream& S) const
{
S << "begin class HExtendedString "<<endl;
myString.Print(S);
}
// ----------------------------------------------------------------------------
// Issamestate
// ----------------------------------------------------------------------------
Standard_Boolean TCollection_HExtendedString::IsSameState
(const Handle(TCollection_HExtendedString)& other) const
{
Handle(TCollection_HExtendedString) H;
H = Handle(TCollection_HExtendedString)::DownCast(other);
return ( myString == H->ChangeString() );
}
TCollection_ExtendedString& TCollection_HExtendedString::ChangeString() const
{
return (TCollection_ExtendedString&)myString;
}

View File

@@ -0,0 +1,276 @@
-- File: TCollection_HSequence.cdl
-- Created: Thu Nov 26 19:33:29 1992
-- Author: Mireille MERCIEN
-- <mip@sdsun3>
---Copyright: Matra Datavision 1992
generic class HSequence from TCollection
(Item as any;
TheSequence as any) -- Sequence from TCollection(Item))
inherits TShared from MMgt
---Purpose: A sequence of items indexed by an integer.
-- Sequences have about the same goal as unidimensional
-- arrays (TCollection_HArray1): they are commonly used
-- as elementary data structures for more complex objects.
-- But a sequence is a structure of variable size: sequences
-- avoid the use of large and quasi-empty arrays. Exploring
-- a sequence data structure is efficient when the exploration
-- is done in sequence; elsewhere a sequence item takes
-- longer to be read than an array item. Note also that
-- sequences are not efficient when they have to support
-- numerous algorithmic explorations: a map is better for that purpose.
-- HSequence objects are handles to sequences.
-- - HSequence sequences may be shared by several objects.
-- - You may use a TCollection_Sequence structure to
-- have the actual sequence.
-- HSequence is a generic class which depends on two parameters:
-- - Item, the type of element in the sequence,
-- - Seq, the actual type of sequence handled by
-- HSequence. This is an instantiation with Item of the
-- TCollection_Sequence generic class.A
raises
NoSuchObject from Standard,
OutOfRange from Standard
is
Create returns mutable HSequence from TCollection;
---Purpose: Constructs an empty sequence.
-- Use:
-- - the function Append or Prepend to add an item or
-- a collection of items at the end, or at the beginning of the sequence,
-- - the function InsertAfter or InsertBefore to add an
-- item or a collection of items at any position in the sequence,
-- - the function SetValue or ChangeValue to assign a
-- new value to an item of the sequence,
-- - the function Value to read an item of the sequence,
-- - the function Remove to remove an item at any position in the sequence.
---C++: inline
IsEmpty(me) returns Boolean;
---Level: Public
---Purpose: returns True if the sequence <me> contains no elements.
---C++: inline
Length(me) returns Integer;
---Level: Public
---Purpose: Returns the number of element(s) in the
-- sequence. Returns zero if the sequence is empty.
--
---C++: inline
Clear(me : mutable);
---Level: Public
---Purpose: Removes all element(s) of the sequence <me>
-- Example:
-- before
-- me = (A B C)
-- after
-- me = ()
Append(me : mutable; anItem : Item);
---Level: Public
---Purpose: Appends <anItem> at the end of <me>.
-- Example:
-- before
-- me = (A B C)
-- after
-- me = (A B C anItem)
Append(me : mutable; aSequence : HSequence);
---Level: Public
---Purpose: Concatenates <aSequence> at the end of <me>.
-- Example:
-- before
-- me = (A B C)
-- aSequence = (D E F)
-- after
-- me = (A B C D E F)
-- aSequence = (D E F)
Prepend(me : mutable; anItem : Item);
---Level: Public
---Purpose: Add <anItem> at the beginning of <me>.
-- Example:
-- before
-- me = (A B C)
-- after
-- me = (anItem A B C )
Prepend(me : mutable; aSequence : HSequence);
---Purpose: Concatenates <aSequence> at the beginning of <me>.
-- Example:
-- before
-- me = (A B C)
-- aSequence = (D E F)
-- after me = (D E F A B C)
-- aSequence = (D E F)
Reverse(me : mutable);
---Purpose: Reverses the order of items on <me>.The first one becomes the last one and inversely.
-- Example:
-- before
-- me = (A B C)
-- after
-- me = (C B A)
InsertBefore(me : mutable; anIndex : Integer; anItem : Item)
raises OutOfRange from Standard;
---Purpose: Inserts <anItem> in <me> before the position <anIndex>.
-- Raises an exception if the anIndex is out of bounds.
-- Example:
-- before
-- me = (A B D), anIndex = 3, anItem = C
-- after
-- me = (A B C D )
InsertBefore(me : mutable ; anIndex : Integer; aSequence : HSequence)
raises OutOfRange from Standard;
---Purpose: Inserts the sequence <aSequence> in <me> before
-- the position <anIndex>.
-- Raises an exception if the anIndex is out of bounds.
-- Example:
-- before
-- me = (A B F), anIndex = 3, aSequence = (C D E)
-- after
-- me = (A B C D E F)
-- aSequence = (C D E)
InsertAfter(me : mutable; anIndex : Integer; anItem : Item)
raises OutOfRange from Standard;
---Purpose: Inserts <anItem> in <me> after the position
-- <anIndex>.
-- Raises an exception if anIndex is out of bound.
-- Example:
-- before
-- me = (A B C), anIndex = 3, anItem = D
-- after
-- me = (A B C D)
InsertAfter(me : mutable ; anIndex : Integer; aSequence : HSequence)
raises OutOfRange from Standard;
---Purpose: Inserts the sequence <aSequence> in <me>
-- after the position <anIndex>.
-- Raises an exception if anIndex is out of bound.
-- Example:
-- before
-- me = (A B C), anIndex = 3, aSequence = (D E F)
-- after
-- me = (A B C D E F)
-- aSequence = (D E F)
Exchange(me : mutable; anIndex, anOtherIndex : Integer)
raises OutOfRange from Standard;
---Purpose: Swaps elements which are located at
-- positions <anIndex> and <anOtherIndex> in <me>.
-- Raises an exception if anIndex or anOtherIndex is out of bound.
-- Example:
-- before
-- me = (A B C), anIndex = 1, anOtherIndex = 3
-- after
-- me = (C B A)
Split(me : mutable; anIndex : Integer)
returns mutable HSequence
raises OutOfRange from Standard
---Purpose: Keeps in <me> the items 1 to <anIndex>-1 and
-- returns the items <anIndex> to the end.
-- Example:
-- before
-- me = (A B C D) ,anIndex = 3
-- after
-- me = (A B)
-- returns (C D)
is static;
SetValue(me : mutable; anIndex : Integer; anItem : Item)
raises OutOfRange from Standard
---Purpose: Sets <anItem> to be the item at position
-- <anIndex> in <me>.
-- Raises an exception if anIndex is out of bounds
-- Example:
-- before
-- me = (A B D), anIndex = 3, anItem = C
-- after
-- me = (A B C)
is static;
Value(me; anIndex : Integer) returns any Item
raises OutOfRange from Standard
---Purpose: Returns the Item at position <anIndex> in <me>.
-- Raises an exception if the anIndex is out of bound
-- Example:
-- before
-- me = (A B C), anIndex = 1
-- after
-- me = (A B C)
-- returns
-- A
---C++: return const &
is static;
ChangeValue(me : mutable; anIndex : Integer) returns any Item
raises OutOfRange from Standard
---Purpose: Returns the Item at position <anIndex> in <me>.
-- Raises an exception if the anIndex is out of bound.
-- Example:
-- before
-- me = (A B C), anIndex = 1
-- after
-- me = (A B C)
-- returns
-- A
---C++: return &
is static;
Remove(me : mutable; anIndex : Integer)
raises OutOfRange from Standard;
---Purpose: Removes from <me> the item at position
-- <anIndex>.
-- Raises an exception if anIndex is out of bounds.
-- Example:
-- before
-- me = (A B C), anIndex = 3
-- after
-- me = (A B)
Remove(me : mutable; fromIndex, toIndex : Integer)
raises OutOfRange from Standard;
---Purpose: Removes from <me> all the items of
-- positions between <fromIndex> and <toIndex>.
-- Raises an exception if the indices are out of bounds.
-- Example:
-- before
-- me = (A B C D E F), fromIndex = 1 toIndex = 3
-- after
-- me = (D E F)
Sequence(me) returns TheSequence;
---Purpose: Returns the Seq sequence used as a field by this
-- sequence; the returned sequence is not modifiable;
---C++: return const &
---C++: inline
ChangeSequence(me : mutable) returns TheSequence;
---Purpose: - Returns a modifiable reference on the Seq
-- sequence used as a field by this sequence, in order to modify it.
---C++: return &
---C++: inline
ShallowCopy(me) returns mutable like me;
---Purpose: function call
---C++: function call
-- IsSameState (me; other : like me) returns Boolean;
fields
mySequence : TheSequence;
end;

View File

@@ -0,0 +1,197 @@
// ----------------------------------------------------------------------
// Copyright: Matra-Datavision 1992
// File: TCollection_HSequence.gxx
// Created: Nov, 24 1992
// Author: Mireille MERCIEN
// ----------------------------------------------------------------------
// ----------------------------------
// Clear : Clear the Current HSequence
// ----------------------------------
void TCollection_HSequence::Clear()
{
mySequence.Clear();
}
// -------------------------------------------------
// Append : Push an item at the end of the sequence
// -------------------------------------------------
void TCollection_HSequence::Append(const Item& T)
{
mySequence.Append(T);
}
// ---------------------------------------------------
// Append : Push a Sequence at the end of the sequence
// ---------------------------------------------------
void TCollection_HSequence::Append(const Handle(TCollection_HSequence)& S)
{
Standard_Integer i,l = S->Length();
for (i = 1; i <= l; i++) mySequence.Append(S->Value(i));
}
// ---------------------------------------------------------
// Prepend : Push an element at the begining of the sequence
// ---------------------------------------------------------
void TCollection_HSequence::Prepend(const Item& T)
{
mySequence.Prepend(T);
}
// ---------------------------------------------------------
// Prepend : Push an element at the begining of the sequence
// ---------------------------------------------------------
void TCollection_HSequence::Prepend(const Handle(TCollection_HSequence)& S)
{
Standard_Integer i,l = S->Length();
for (i = 0; i < l; i++) mySequence.Prepend(S->Value(S->Length()-i));
}
// ---------------------------------------------------------
// Reverse : Reverse the order of a given sequence
// ---------------------------------------------------------
void TCollection_HSequence::Reverse()
{
mySequence.Reverse();
}
// -------------------------------------------------------------------
// InsertBefore : Insert an item before a given index in the sequence
// --------------------------------------------------------------------
void TCollection_HSequence::InsertBefore(const Standard_Integer Index,
const Item& T)
{
mySequence.InsertBefore(Index,T);
}
// ----------------------------------------------------------------------
// InsertBefore : Insert a sequence before a specific index in a HSequence
// ----------------------------------------------------------------------
void TCollection_HSequence::InsertBefore(const Standard_Integer Index ,
const Handle(TCollection_HSequence)& S)
{
Standard_Integer i,l = S->Length();
for (i = 1; i <= l; i++) mySequence.InsertBefore(Index+i-1,S->Value(i));
}
// -----------------------------------------------------------------
// InsertAfter : Insert an element after a given index in a sequence
// -----------------------------------------------------------------
void TCollection_HSequence::InsertAfter(const Standard_Integer Index,
const Item& T)
{
mySequence.InsertAfter(Index,T);
}
// -------------------------------------------------------------------
// InsertAfter : Insert a sequence after a given index in the sequence
// -------------------------------------------------------------------
void TCollection_HSequence::InsertAfter(const Standard_Integer Index,
const Handle(TCollection_HSequence)& S)
{
Standard_Integer i,l = S->Length();
for (i = 1; i <= l; i++) mySequence.InsertAfter(Index+i-1,S->Value(i));
}
// ----------------------------------------
// Exchange : Exchange two elements in the sequence
// ----------------------------------------
void TCollection_HSequence::Exchange(const Standard_Integer I,
const Standard_Integer J)
{
mySequence.Exchange(I,J);
}
// ---------------------------------------------
// Split : Split a sequence in two sub-sequences
// ---------------------------------------------
Handle (TCollection_HSequence)
TCollection_HSequence::Split(const Standard_Integer Index)
{
TheSequence SS;
mySequence.Split(Index,SS);
Handle(TCollection_HSequence) NS = new TCollection_HSequence();
Standard_Integer i,l = SS.Length();
for (i=1; i<= l; i++) NS->Append(SS(i));
return NS;
}
// ----------------------------------------------------------
// SetValue : Change the element of a given index in a sequence
// ----------------------------------------------------------
void TCollection_HSequence::SetValue(const Standard_Integer Index,
const Item& T)
{
mySequence(Index) = T;
}
// -----------------------------------------
// Value : Return the value of a given index
// -----------------------------------------
const Item& TCollection_HSequence::Value(const Standard_Integer Index) const
{
return (mySequence(Index));
}
// -----------------------------------------
// ChangeValue : Return the value of a given index
// -----------------------------------------
Item& TCollection_HSequence::ChangeValue(const Standard_Integer Index)
{
return (mySequence(Index));
}
// -------------------------------------
// Remove : Remove an item in a sequence
// -------------------------------------
void TCollection_HSequence::Remove(const Standard_Integer Index)
{
mySequence.Remove(Index);
}
// ---------------------
// Remove a set of items
// ---------------------
void TCollection_HSequence::Remove(const Standard_Integer From,
const Standard_Integer To)
{
mySequence.Remove(From,To);
}
// ---------------------------------------------------------------------
// ShallowCopy
// ---------------------------------------------------------------------
Handle(TCollection_HSequence) TCollection_HSequence::ShallowCopy() const
{
Handle (TCollection_HSequence) TheCopy = new TCollection_HSequence();
Standard_Integer i;
for (i=1; i <= mySequence.Length(); i++) TheCopy->Append(mySequence(i));
return TheCopy;
}
// ----------------------------------------------------------------------------
// IsSamestate
// ----------------------------------------------------------------------------
// Standard_Boolean TCollection_HSequence::IsSameState
// (const Handle(TCollection_HSequence)& other) const
// {
// Handle(TCollection_HSequence) Seq =
// Handle(TCollection_HSequence)::DownCast(other);
// if (Seq->Length() != Length()) return Standard_False;
// for (Standard_Integer I = 1; I<= Length(); I++) {
// if ( !(Value(I) == Seq->Value(I)) ) return Standard_False;
// }
// return Standard_True;
// }

View File

@@ -0,0 +1,47 @@
// File: TCollection_HSequence.lxx
// Created: Fri Mar 12 09:55:26 1993
// Author: Remi LEQUETTE
// <rle@phobox>
// -----------
// constructor :
// -----------
inline TCollection_HSequence::TCollection_HSequence(){}
//--------------------------------------------------
// IsEmpty: Returns True if the Sequence is empty
//--------------------------------------------------
inline Standard_Boolean TCollection_HSequence::IsEmpty() const
{
return mySequence.IsEmpty();
}
//--------------------------------------------------
// Length : Returns the length of the sequence
//--------------------------------------------------
inline Standard_Integer TCollection_HSequence::Length() const
{
return mySequence.Length();
}
//=======================================================================
//function : Sequence
//purpose :
//=======================================================================
inline const TheSequence& TCollection_HSequence::Sequence() const
{
return mySequence;
}
//=======================================================================
//function : ChangeSequence
//purpose :
//=======================================================================
inline TheSequence& TCollection_HSequence::ChangeSequence()
{
return mySequence;
}

View File

@@ -0,0 +1,154 @@
-- File: TCollection_HSet.cdl
-- Created: Tue Mar 2 12:10:59 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class HSet from TCollection
(Item as any;
TheSet as any) -- as Set from TCollection(Item))
inherits TShared from MMgt
---Purpose: An HSet is a collection of non-ordered items without any
-- duplicates. At each transaction, the system checks there are no duplicates.
-- HSet objects are handles to sets.
-- HSet is a generic class which depends on two parameters:
-- - Item, the type of element in the set,
-- - Set, the actual type of set handled by HSet. This is an
-- instantiation with TCollection_Set generic class.
is
Create returns mutable HSet from TCollection;
---Purpose: Construction of an empty set.
Extent(me) returns Integer from Standard
---Level: Public
---Purpose: Returns the number of items in the set me.
---C++: inline
is static;
IsEmpty(me) returns Boolean from Standard
---Level: Public
---Purpose: Returns True if the set <me> is empty, Extent == 0.
---C++: inline
is static;
Clear(me : mutable)
---Level: Public
---Purpose: Removes all the items from the set.
---C++: inline
is static;
Add(me : mutable; T : Item) returns Boolean from Standard
---Level: Public
---Purpose: Adds <T> to the set if this item does not
-- already exist. Returns False if <T> was
-- already in the set.
---Example:
-- before
-- me = {a,b,c,d}, T = y
-- after
-- me = {a,b,c,d,y} returns True
---C++: inline
is static;
Remove(me : mutable; T : Item) returns Boolean from Standard
---Level: Public
---Purpose: Removes <T> from the set and returns True.
-- Returns False if <T> was not in the set.
---Example:
-- before
-- me = {a,b,c,d}, T = a
-- after
-- me = {b,c,d} returns True
---C++: inline
is static;
Union(me; B : HSet from TCollection)
returns mutable HSet from TCollection
---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}
is static;
Intersection(me; B : HSet from TCollection)
returns mutable HSet from TCollection
---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}
is static;
Difference(me; B: HSet from TCollection)
returns mutable HSet from TCollection
---Purpose: Compares set B with this set and deletes duplicates.
--Example:
-- before
-- me = {a,b,c}, B = {d,a,f}
-- after
-- me = {a,b,c}, B = {d,a,f}
-- returns
-- {b,c}
is static;
Contains(me; T : Item) returns Boolean from Standard
---Purpose: Returns True if an item is in the set me.
---C++: inline
is static;
IsASubset(me; S : HSet from TCollection) returns Boolean from Standard
---Purpose: Returns True if a set is contained in the set me.
-- The two sets can be identical.
---C++: inline
is static;
IsAProperSubset(me; S : HSet from TCollection)
returns Boolean from Standard
---Purpose: Returns True S is a subset and if all its elements are strictly included in this set.
-- The two sets cannot be identical.
---C++: inline
is static;
ShallowCopy(me) returns mutable like me;
---Level: Advanced
---C++: function call
-- IsSameState (me; other: like me) returns Boolean;
-- Level: Advanced
Set(me) returns TheSet
---Level: Advanced
---Purpose: Returns the internal set. For implementation.
---C++: inline
---C++: return const &
is static;
ChangeSet(me : mutable) returns TheSet
---Level: Advanced
---Purpose: Returns the internal set. For implementation.
---C++: inline
---C++: return &
is static;
fields
mySet : TheSet;
end HSet from TCollection;

View File

@@ -0,0 +1,85 @@
// File: TCollection_HSet.gxx
// Created: Wed Mar 3 13:35:32 1993
// Author: Remi LEQUETTE
// <rle@phobox>
//=======================================================================
//function : TCollection_HSet
//purpose :
//=======================================================================
TCollection_HSet::TCollection_HSet()
{
}
//=======================================================================
//function : Union
//purpose :
//=======================================================================
Handle(TCollection_HSet) TCollection_HSet::Union
(const Handle(TCollection_HSet)& B) const
{
Handle(TCollection_HSet) R = new TCollection_HSet();
R->ChangeSet() = mySet;
R->ChangeSet().Union(B->Set());
return R;
}
//=======================================================================
//function : Intersection
//purpose :
//=======================================================================
Handle(TCollection_HSet) TCollection_HSet::Intersection
(const Handle(TCollection_HSet)& B) const
{
Handle(TCollection_HSet) R = new TCollection_HSet();
R->ChangeSet() = mySet;
R->ChangeSet().Intersection(B->Set());
return R;
}
//=======================================================================
//function : Difference
//purpose :
//=======================================================================
Handle(TCollection_HSet) TCollection_HSet::Difference
(const Handle(TCollection_HSet)& B) const
{
Handle(TCollection_HSet) R = new TCollection_HSet();
R->ChangeSet() = mySet;
R->ChangeSet().Difference(B->Set());
return R;
}
//=======================================================================
//function : ShallowCopy
//purpose :
//=======================================================================
Handle(TCollection_HSet) TCollection_HSet::ShallowCopy() const
{
Handle(TCollection_HSet) S = new TCollection_HSet();
S->ChangeSet() = mySet;
return S;
}
//=======================================================================
//function : IsSameState
//purpose :
//=======================================================================
//Standard_Boolean TCollection_HSet::IsSameState
// (const Handle(TCollection_HSet)& Other) const
//{
// Handle(TCollection_HSet) S = Handle(TCollection_HSet)::DownCast(Other);
// Standard_Boolean result = Standard_False;
// if (!S.IsNull()) {
// if (S->Extent() == Extent()) {
// result = IsASubset(S);
// }
// }
// return result;
//}

View File

@@ -0,0 +1,106 @@
// File: TCollection_HSet.lxx
// Created: Tue Mar 2 16:41:00 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//function : Extent
//purpose :
//=======================================================================
inline Standard_Integer TCollection_HSet::Extent() const
{
return mySet.Extent();
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_HSet::IsEmpty() const
{
return mySet.IsEmpty();
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
inline void TCollection_HSet::Clear()
{
mySet.Clear();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_HSet::Add(const Item& T)
{
return mySet.Add(T);
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_HSet::Remove(const Item& T)
{
return mySet.Remove(T);
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_HSet::Contains(const Item& T) const
{
return mySet.Contains(T);
}
//=======================================================================
//function : IsASubset
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_HSet::IsASubset
(const Handle(TCollection_HSet)& S) const
{
return mySet.IsASubset(S->Set());
}
//=======================================================================
//function : IsAProperSubset
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_HSet::IsAProperSubset
(const Handle(TCollection_HSet)& S) const
{
return mySet.IsAProperSubset(S->Set());
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
inline const TheSet& TCollection_HSet::Set() const
{
return mySet;
}
//=======================================================================
//function : ChangeSet
//purpose :
//=======================================================================
inline TheSet& TCollection_HSet::ChangeSet()
{
return mySet;
}

View File

@@ -0,0 +1,208 @@
-- File: TCollection_IndexedDataMap.cdl
-- Created: Fri Jan 8 17:49:04 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class IndexedDataMap from TCollection
(TheKey as any;
TheItem as any;
Hasher as any) -- as MapHasher(TheKey)
inherits BasicMap from TCollection
---Purpose: An indexed map is used to store keys and to bind
-- an index to them. Each new key stored in the map
-- gets an index. Index are incremented as keys are
-- stored in the map. A key can be found by the index
-- and an index by the key. No key but the last can
-- be removed so the indices are in the range 1..
-- Extent. An Item is stored with each key.
--
-- This class is similar to IndexedMap from
-- TCollection with the Item as a new feature. Note
-- the important difference on the operator (). In
-- the IndexedMap this operator returns the Key. In
-- the IndexedDataMap this operator returns the Item.
-- An IndexedDataMap is an ordered
-- map, which allows a linear iteration on its contents. It
-- combines the behavior of:
-- - an array because data may be accessed with an index,
-- - and a map because data may also be accessed with a key.
-- IndexedDataMap is a generic class which depends on three parameters:
-- - Key is the type of key for an entry in the map,
-- - Item is the type of element associated with a key in the map,
-- - Hasher is the type of hasher on keys.
-- Notes:
-- - IndexedDataMap is similar to
-- TCollection_IndexedMap with the item as a new
-- feature. Note, however, the important difference with operator ():
-- - for an IndexedMap this operator returns the key, but
-- - for an IndexedDataMap it returns the item.
-- - It is recommended not to explore an IndexedDataMap
-- map with an iterator: you just use indexes.
-- - TCollection_MapHasher class describes the
-- functions required for a Hasher object.
raises
DomainError from Standard,
OutOfRange from Standard,
NoSuchObject from Standard
class IndexedDataMapNode from TCollection
inherits MapNode from TCollection
uses MapNodePtr from TCollection
is
Create(K1 : TheKey; K2 : Integer; I : TheItem; n1,n2 : MapNodePtr from TCollection) returns IndexedDataMapNode from TCollection;
---C++: inline
Key1(me) returns TheKey;
---C++: return &
---C++: inline
Key2(me) returns Integer;
---C++: return &
---C++: inline
Next2(me) returns MapNodePtr from TCollection;
---C++: return &
---C++: inline
Value(me) returns TheItem;
---C++: return &
---C++: inline
fields
myKey1 : TheKey;
myKey2 : Integer from Standard;
myValue : TheItem;
myNext2 : MapNodePtr from TCollection;
end;
is
Create(NbBuckets : Integer = 1) returns IndexedDataMap from TCollection;
---Purpose: Constructs an IndexedDataMap with NbBuckets
-- (defaulted to 1) buckets.
-- Note that the map will be automatically redimensioned
-- during its use if the number of entries becomes too large.
-- Use:
-- - the function Add to add an entry (key, item, index) in the map,
-- - operator() to read an item from an index, or to
-- assign a new value to this item,
-- - the function FindFromKey or ChangeFromKey to
-- read an item from a key, or to assign a new value to this item,
-- - the function RemoveLast to remove the last entry from the map,
-- - and other available edition and querying functions.
Create(Other : IndexedDataMap from TCollection)
returns IndexedDataMap from TCollection
---Purpose: As copying Map is an expensive operation it is
-- incorrect to do it implicitly. This constructor
-- will raise an error if the Map is not empty. To copy the
-- content of a Map use the Assign method (operator =).
raises DomainError from Standard
is private;
Assign(me : in out; Other : IndexedDataMap from TCollection)
returns IndexedDataMap from TCollection
---Purpose: Replace the content of this map by the content of
-- the map <Other>.
---C++: alias operator =
---C++: return &
is static;
ReSize(me : in out; NbBuckets : Integer)
---Purpose: Changes the number of buckets of <me> to be
-- <NbBuckets>. The entries (key + item + index) already
-- stored in this map are maintained.
is static;
Clear(me : in out)
---Purpose: Removes all keys in the map.
---C++: alias ~
is static;
Add(me : in out; K : TheKey; I : TheItem) returns Integer
---Purpose: Adds the Key <K> to the Map <me>. Returns the
-- index of the Key. The key is new in the map if
-- Extent has been incremented. The Item <I> is
-- stored with the key. If the key was already in the
-- map the previous item is not replaced by <I>.
is static;
Substitute(me : in out; I : Integer; K : TheKey; T : TheItem)
---Purpose: Substitutes the Key at index <I> with <K>. <I>
-- must be a valid index, <K> must be a new key. <T>
-- becomes the Item stored with <K>.
-- Trigger: Raises OutOfRange if I < 1 or I > Extent.
-- Raises DomainError if Contains(K).
raises
OutOfRange from Standard,
DomainError from Standard
is static;
RemoveLast(me : in out)
---Purpose: Removes the last key entered in the map, i.e the
-- key of index Extent().
-- I must be a valid index and K must be a new key.
-- Exceptions
-- - Standard_OutOfRange if the index I is less than 1 or
-- greater than the number of entries in this map.
-- - Standard_DomainError if the key K is already in this map.
raises
OutOfRange from Standard
is static;
Contains(me; K : TheKey) returns Boolean
---Purpose: Returns True if the key <K> is stored in the map <me>.
is static;
FindKey(me; I : Integer) returns any TheKey
---Purpose: Returns the Key of index <I>.
-- Exceptions
-- Standard_OutOfRange if I is less than 1 or greater than
-- the number of entries in this map.
---C++: return const &
raises OutOfRange from Standard
is static;
FindFromIndex(me; I : Integer) returns any TheItem
---Level: Public
---Purpose: Returns the Item of index <I>.
---Trigger: Raises OutOfRange if I < 1 or I > Extent
---C++: alias operator ()
---C++: return const &
raises OutOfRange from Standard
is static;
ChangeFromIndex(me : in out; I : Integer) returns any TheItem
---Level: Public
---Purpose: Returns the Item of index <I>. The Item can be
-- modified with the syntax aMap(Index) = newItem.
---Trigger: Raises OutOfRange if I < 1 or I > Extent
---C++: alias operator ()
---C++: return &
raises OutOfRange from Standard
is static;
FindIndex(me; K : TheKey) returns Integer
---Purpose: Returns the index of the key <K>.
-- Returns 0 if K is not in the map.
is static;
FindFromKey(me; K : TheKey) returns any TheItem
---Purpose: Returns the Item of the key <K>
-- Trigger: Raises NoSuchObject if K is not in the map.
raises NoSuchObject from Standard
---C++: return const &
is static;
ChangeFromKey(me : in out; K : TheKey) returns any TheItem
---Purpose: Returns the Item of the key <K>
-- Trigger: Raises NoSuchObject if K is not in the map.
raises NoSuchObject from Standard
---C++: return &
is static;
end IndexedDataMap;

View File

@@ -0,0 +1,399 @@
// Lastly modified by :
// +---------------------------------------------------------------------------+
// ! szy ! Modified Assign method ! 7-05-2003! 3.0-00-2!
// +---------------------------------------------------------------------------+
// File: TCollection_IndexedDataMap.gxx
// Created: Fri Jan 8 19:25:35 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <Standard_DomainError.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_OutOfRange.hxx>
#include <TCollection_BasicMapIterator.hxx>
//=======================================================================
//function : TCollection_IndexedDataMap
//purpose :
//=======================================================================
TCollection_IndexedDataMap::TCollection_IndexedDataMap
(const Standard_Integer NbBuckets):
TCollection_BasicMap(NbBuckets,Standard_False)
{
}
//=======================================================================
//function : TCollection_IndexedDataMap
//purpose :
//=======================================================================
TCollection_IndexedDataMap::TCollection_IndexedDataMap
(const TCollection_IndexedDataMap& Other) :
TCollection_BasicMap(Other.NbBuckets(),Standard_False)
{
if (Other.Extent() != 0)
Standard_DomainError::Raise("TCollection:Copy of non empty IndexedDataMap");
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
TCollection_IndexedDataMap& TCollection_IndexedDataMap::Assign
(const TCollection_IndexedDataMap& Other)
{
// very simple implementation
// not optimal (recompute the hashcode values)
if (this == &Other) return *this;
Clear();
// ReSize(Other.NbBuckets());
if (!Other.IsEmpty()) {
ReSize(Other.Extent());
for (Standard_Integer i = 1; i <= Other.Extent(); i++) {
Add(Other.FindKey(i),Other(i));
}
}
return *this;
}
//=======================================================================
//function : ReSize
//purpose :
//=======================================================================
void TCollection_IndexedDataMap::ReSize(const Standard_Integer N)
{
Standard_Integer newBuck;
Standard_Address newData1=NULL, newData2=NULL;
if (BeginResize(N,newBuck,newData1,newData2)) {
if (myData1) {
TCollection_IndexedDataMapNode** newdata1 = (TCollection_IndexedDataMapNode**)newData1;
TCollection_IndexedDataMapNode** newdata2 = (TCollection_IndexedDataMapNode**)newData2;
TCollection_IndexedDataMapNode** olddata1 = (TCollection_IndexedDataMapNode**) myData1;
TCollection_IndexedDataMapNode *p, *q;
Standard_Integer i,k1,k2;
for (i = 0; i <= NbBuckets(); i++) {
if (olddata1[i]) {
p = olddata1[i];
while (p) {
k1 = Hasher::HashCode(p->Key1(),newBuck);
k2 = ::HashCode(p->Key2(),newBuck);
q = (TCollection_IndexedDataMapNode*)p->Next();
p->Next() = newdata1[k1];
p->Next2() = newdata2[k2];
newdata1[k1] = p;
newdata2[k2] = p;
p = q;
}
}
}
}
EndResize(N,newBuck,newData1,newData2);
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TCollection_IndexedDataMap::Clear()
{
if (!IsEmpty()) {
Standard_Integer i;
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**) myData1;
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**) myData2;
TCollection_IndexedDataMapNode *p,*q;
for (i = 0; i <= NbBuckets(); i++) {
p = data1[i];
while (p) {
q = (TCollection_IndexedDataMapNode*) p->Next();
delete p;
p = q;
}
data1[i] = data2[i] = NULL;
}
}
TCollection_BasicMap::Destroy();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Integer TCollection_IndexedDataMap::Add(const TheKey& K1, const TheItem& I)
{
if (Resizable()) ReSize(Extent());
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode* p;
p = data1[k1];
while (p) {
if (Hasher::IsEqual(p->Key1(),K1))
return p->Key2();
p = (TCollection_IndexedDataMapNode*) p->Next();
}
Increment();
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**)myData2;
Standard_Integer k2 = ::HashCode(Extent(),NbBuckets());
p = new TCollection_IndexedDataMapNode(K1,Extent(),I,data1[k1],data2[k2]);
data1[k1] = p;
data2[k2] = p;
return Extent();
}
//=======================================================================
//function : Substitute
//purpose :
//=======================================================================
void TCollection_IndexedDataMap::Substitute(const Standard_Integer I,
const TheKey& K1,
const TheItem& T)
{
Standard_OutOfRange_Raise_if(I < 1 || I > Extent(),
"IndexedMap::Substitute");
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
TCollection_IndexedDataMapNode* p;
// check if K1 is not already in the map
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
p = data1[k1];
while (p) {
if (Hasher::IsEqual(p->Key1(),K1))
Standard_DomainError::Raise("IndexedMap::Substitute");
p = (TCollection_IndexedDataMapNode*) p->Next();
}
// Find the node for the index I
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**)myData2;
Standard_Integer k2 = ::HashCode(I,NbBuckets());
p = data2[k2];
while (p) {
if (p->Key2() == I)
break;
p = (TCollection_IndexedDataMapNode*) p->Next2();
}
// remove the old key
Standard_Integer k = Hasher::HashCode(p->Key1(),NbBuckets());
TCollection_IndexedDataMapNode* q = data1[k];
if (q == p) data1[k] = (TCollection_IndexedDataMapNode*) p->Next();
else {
while(q->Next() != p) q = (TCollection_IndexedDataMapNode*) q->Next();
q->Next() = p->Next();
}
// update the node
p->Key1() = K1;
p->Value() = T;
p->Next() = data1[k1];
data1[k1] = p;
}
//=======================================================================
//function : RemoveLast
//purpose :
//=======================================================================
void TCollection_IndexedDataMap::RemoveLast()
{
Standard_OutOfRange_Raise_if(Extent() == 0,
"IndexedMap::RemoveLast");
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
TCollection_IndexedDataMapNode* p;
TCollection_IndexedDataMapNode* q;
// Find the node for the last index and remove it
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**)myData2;
Standard_Integer k2 = ::HashCode(Extent(),NbBuckets());
p = data2[k2];
q = NULL;
while (p) {
if (p->Key2() == Extent())
break;
q = p;
p = (TCollection_IndexedDataMapNode*) p->Next2();
}
if (q == NULL)
data2[k2] = (TCollection_IndexedDataMapNode*)p->Next2();
else
q->Next2() = p->Next2();
// remove the key
Standard_Integer k = Hasher::HashCode(p->Key1(),NbBuckets());
q = data1[k];
if (q == p) data1[k] = (TCollection_IndexedDataMapNode*) p->Next();
else {
while(q->Next() != p) q = (TCollection_IndexedDataMapNode*) q->Next();
q->Next() = p->Next();
}
Decrement();
delete p;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_IndexedDataMap::Contains(const TheKey& K1) const
{
if (IsEmpty()) return Standard_False;
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return Standard_True;
p1 = (TCollection_IndexedDataMapNode*) p1->Next();
}
return Standard_False;
}
//=======================================================================
//function : FindKey
//purpose :
//=======================================================================
const TheKey& TCollection_IndexedDataMap::FindKey(const Standard_Integer K2) const
{
Standard_OutOfRange_Raise_if(K2 < 1 || K2 > Extent(), "IndexedDataMap");
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**)myData2;
Standard_Integer k2 = ::HashCode(K2,NbBuckets());
TCollection_IndexedDataMapNode *p2;
p2 = data2[k2];
while (p2) {
if (p2->Key2() == K2) return p2->Key1();
p2 = (TCollection_IndexedDataMapNode*)p2->Next2();
}
Standard_OutOfRange::Raise("IndexedDataMap : missing index !!!");
return p2->Key1();
}
//=======================================================================
//function : FindFromIndex
//purpose :
//=======================================================================
const TheItem& TCollection_IndexedDataMap::FindFromIndex
(const Standard_Integer K2) const
{
Standard_OutOfRange_Raise_if(K2 < 1 || K2 > Extent(), "IndexedDataMap");
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**)myData2;
Standard_Integer k2 = ::HashCode(K2,NbBuckets());
TCollection_IndexedDataMapNode *p2;
p2 = data2[k2];
while (p2) {
if (p2->Key2() == K2) return p2->Value();
p2 = (TCollection_IndexedDataMapNode*)p2->Next2();
}
Standard_OutOfRange::Raise("IndexedDataMap : missing index !!!");
return p2->Value();
}
//=======================================================================
//function : ChangeFromIndex
//purpose :
//=======================================================================
TheItem& TCollection_IndexedDataMap::ChangeFromIndex(const Standard_Integer K2)
{
Standard_OutOfRange_Raise_if(K2 < 1 || K2 > Extent(), "IndexedDataMap");
TCollection_IndexedDataMapNode** data2 = (TCollection_IndexedDataMapNode**)myData2;
Standard_Integer k2 = ::HashCode(K2,NbBuckets());
TCollection_IndexedDataMapNode *p2;
p2 = data2[k2];
while (p2) {
if (p2->Key2() == K2) return p2->Value();
p2 = (TCollection_IndexedDataMapNode*)p2->Next2();
}
Standard_OutOfRange::Raise("IndexedDataMap : missing index !!!");
return p2->Value();
}
//=======================================================================
//function : FindIndex
//purpose :
//=======================================================================
Standard_Integer TCollection_IndexedDataMap::FindIndex(const TheKey& K1) const
{
if (IsEmpty()) return 0;
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return p1->Key2();
p1 = (TCollection_IndexedDataMapNode*)p1->Next();
}
return 0;
}
//=======================================================================
//function : FindFromKey
//purpose :
//=======================================================================
const TheItem& TCollection_IndexedDataMap::FindFromKey(const TheKey& K1) const
{
Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::FindFromKey");
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return p1->Value();
p1 = (TCollection_IndexedDataMapNode*) p1->Next();
}
Standard_OutOfRange::Raise("TCollection_IndexedDataMap::FindFromKey");
return p1->Value();
}
//=======================================================================
//function : ChangeFromKey
//purpose :
//=======================================================================
TheItem& TCollection_IndexedDataMap::ChangeFromKey(const TheKey& K1)
{
Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::ChangeFromKey");
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return p1->Value();
p1 = (TCollection_IndexedDataMapNode*)p1->Next();
}
Standard_OutOfRange::Raise("TCollection_IndexedDataMap::ChangeFromKey");
return p1->Value();
}
// @@SDM: begin
// Copyright Open CasCade......................................Version 5.0-00
// Lastly modified by : szy Date : 7-05-2003
// File history synopsis (creation,modification,correction)
// +---------------------------------------------------------------------------+
// ! Developer ! Comments ! Date ! Version !
// +-----------!-----------------------------------------!----------!----------+
// ! rle ! Creation ! 8-01-1993! 5.0-00-2!
// ! szy ! Modified Assign method ! 7-05-2003! 5.0-00-2!
// +---------------------------------------------------------------------------+
// @@SDM: end

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,26 @@
inline TCollection_IndexedDataMapNode::TCollection_IndexedDataMapNode(const TheKey& K1,const Standard_Integer K2,const TheItem& I,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2)
: TCollection_MapNode(n1),myKey1(K1),myKey2(K2),myNext2(n2)
{
myValue = I;
}
inline TheKey& TCollection_IndexedDataMapNode::Key1() const
{
return (TheKey&)myKey1;
}
inline Standard_Integer& TCollection_IndexedDataMapNode::Key2() const
{
return (Standard_Integer&)myKey2;
}
inline TCollection_MapNodePtr& TCollection_IndexedDataMapNode::Next2() const
{
return (TCollection_MapNodePtr&)myNext2;
}
inline TheItem & TCollection_IndexedDataMapNode::Value() const
{
return (TheItem&)myValue;
}

View File

@@ -0,0 +1,147 @@
-- File: TCollection_IndexedMap.cdl
-- Created: Fri Jan 8 17:35:39 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class IndexedMap from TCollection (TheKey as any;
Hasher as any) -- as MapHasher(TheKey)
inherits BasicMap from TCollection
---Purpose: An indexed map is used to store keys and to bind
-- an index to them. An index is assigned to each new key stored in the map.
-- Indexes incremented as keys are stored in the map. A key
-- can be found by the index, and an index by the key. No key
-- except for the last can be removed, so the indexes are in
-- the range 1..Upper where Upper is the number of
-- keys stored in the map.
-- An entry of an IndexedMap is composed of both the key
-- and the index. An IndexedMap is an ordered map, which
-- allows a linear iteration on its contents. But no data is
-- attached to the key. An IndexedMap is typically used by
-- an algorithm to know if some action is still performed on
-- components of a complex data structure.
-- IndexedMap is a generic class which depends on two parameters:
-- - Key is the type of key for an entry in the map,
-- - Hasher is the type of hasher on keys.
-- Notes:
-- - It is not recommended to explore an IndexedMap map
-- with an iterator: you just use indexes.
-- - TCollection_MapHasher class describes the
-- functions required for a Hasher object.
-- - TCollection_IndexedDataMap is a similar map with
-- an item as a new feature.
raises
DomainError from Standard,
OutOfRange from Standard
class IndexedMapNode from TCollection
inherits MapNode from TCollection
uses MapNodePtr from TCollection
is
Create(K1 : TheKey; K2 : Integer; n1,n2 : MapNodePtr from TCollection) returns IndexedMapNode from TCollection;
---C++: inline
Key1(me) returns TheKey;
---C++: return &
---C++: inline
Key2(me) returns Integer;
---C++: return &
---C++: inline
Next2(me) returns MapNodePtr from TCollection;
---C++: return &
---C++: inline
fields
myKey1 : TheKey;
myKey2 : Integer from Standard;
myNext2 : MapNodePtr from TCollection;
end;
is
Create(NbBuckets : Integer = 1) returns IndexedMap from TCollection;
---Purpose: Constructs an IndexedMap with NbBuckets (defaulted to 1) buckets.
-- Note that the map will be automatically redimensioned
-- during its use if the number of entries becomes too large.
-- Use:
-- - the function Add to add a new entry (key, index) to the map,
-- - operator() to read a key from an index,
-- - the function FindIndex to read an index from a key,
-- - the function RemoveLast to remove the last entry from the map.
Create(Other : IndexedMap from TCollection)
returns IndexedMap from TCollection
---Purpose: As copying Map is an expensive operation it is
-- incorrect to do it implicitly. This constructor
-- will raise an error if the Map is not empty. To
-- copy the content of a Map use the Assign method (operator =).
raises DomainError from Standard
is private;
Assign(me : in out; Other : IndexedMap from TCollection)
returns IndexedMap from TCollection
---Purpose: Replace the content of this map by the content of
-- the map <Other>.
---C++: alias operator =
---C++: return &
is static;
ReSize(me : in out; NbBuckets : Integer)
---Purpose: Changes the number of buckets of <me> to be
-- <NbBuckets>. The keys already stored in the map are kept.
is static;
Clear(me : in out)
---Purpose: Removes all keys in the map.
---C++: alias ~
is static;
Add(me : in out; K : TheKey) returns Integer
---Purpose: Adds the Key <K> to the Map <me>. Returns the
-- index of the Key. The key is new in the map if Extent
-- has been incremented.
is static;
Substitute(me : in out; I : Integer; K : TheKey)
---Purpose: Substitutes the Key at index <I> with <K>.
-- <I> must be a valid index, <K> must be a new key.
-- Trigger: Raises OutOfRange if I < 1 or I > Extent
-- Raises DomainError if Contains(K)
raises
OutOfRange from Standard,
DomainError from Standard
is static;
RemoveLast(me : in out)
---Purpose: Removes the last key entered in the map, i.e the
-- key of index Extent().
-- Trigger: Raises OutOfRange if Extent() == 0
raises
OutOfRange from Standard
is static;
Contains(me; K : TheKey) returns Boolean
---Level: Public
---Purpose: Returns True if the key <K> is stored in the map <me>.
is static;
FindKey(me; I : Integer) returns any TheKey
---Purpose: Returns the Key of index <I>.
-- Trigger: Raises OutOfRange if I < 1 or I > Extent
---C++: alias operator ()
---C++: return const &
raises OutOfRange from Standard
is static;
FindIndex(me; K : TheKey) returns Integer
---Purpose: Returns the index of the key <K> Returns 0 if K is
-- not in the map.
is static;
end IndexedMap;

View File

@@ -0,0 +1,316 @@
// Lastly modified by :
// +---------------------------------------------------------------------------+
// ! szy ! Modified Assign method ! 7-05-2003! 3.0-00-3!
// +---------------------------------------------------------------------------+
// File: TCollection_IndexedMap.gxx
// Created: Fri Jan 8 19:07:03 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <Standard_DomainError.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_OutOfRange.hxx>
#include <TCollection_BasicMapIterator.hxx>
//=======================================================================
//function : TCollection_IndexedMap
//purpose :
//=======================================================================
TCollection_IndexedMap::TCollection_IndexedMap
(const Standard_Integer NbBuckets):
TCollection_BasicMap(NbBuckets,Standard_False)
{
}
//=======================================================================
//function : TCollection_IndexedMap
//purpose :
//=======================================================================
TCollection_IndexedMap::TCollection_IndexedMap
(const TCollection_IndexedMap& Other) :
TCollection_BasicMap(Other.NbBuckets(),Standard_False)
{
if (!Other.IsEmpty())
Standard_DomainError::Raise("TCollection:Copy of IndexedMap");
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
TCollection_IndexedMap& TCollection_IndexedMap::Assign
(const TCollection_IndexedMap& Other)
{
// very simple implementation
// not optimal (recompute the hashcode values)
if (this == &Other) return *this;
Clear();
// ReSize(Other.NbBuckets());
if (!Other.IsEmpty()) {
ReSize(Other.Extent());
for (Standard_Integer i = 1; i <= Other.Extent(); i++) {
Add(Other(i));
}
}
return *this;
}
//=======================================================================
//function : ReSize
//purpose :
//=======================================================================
void TCollection_IndexedMap::ReSize(const Standard_Integer N)
{
Standard_Integer newBuck;
Standard_Address newData1, newData2;
if (BeginResize(N,newBuck,newData1,newData2)) {
if (myData1) {
TCollection_IndexedMapNode** newdata1 = (TCollection_IndexedMapNode**)newData1;
TCollection_IndexedMapNode** newdata2 = (TCollection_IndexedMapNode**)newData2;
TCollection_IndexedMapNode** olddata1 = (TCollection_IndexedMapNode**) myData1;
TCollection_IndexedMapNode *p, *q;
Standard_Integer i,k1,k2;
for (i = 0; i <= NbBuckets(); i++) {
if (olddata1[i]) {
p = olddata1[i];
while (p) {
k1 = Hasher::HashCode(p->Key1(),newBuck);
q = (TCollection_IndexedMapNode*) p->Next();
p->Next() = newdata1[k1];
newdata1[k1] = p;
if (p->Key2() > 0) {
k2 = ::HashCode(p->Key2(),newBuck);
p->Next2() = newdata2[k2];
newdata2[k2] = p;
}
p = q;
}
}
}
}
EndResize(N,newBuck,newData1,newData2);
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TCollection_IndexedMap::Clear()
{
if (!IsEmpty()) {
Standard_Integer i;
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**) myData1;
// TCollection_IndexedMapNode** data2 = (TCollection_IndexedMapNode**) myData2;
TCollection_IndexedMapNode *p,*q;
for (i = 0; i <= NbBuckets(); i++) {
p = data1[i];
while (p) {
q = (TCollection_IndexedMapNode*) p->Next();
delete p;
p = q;
}
}
}
TCollection_BasicMap::Destroy();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Integer TCollection_IndexedMap::Add(const TheKey& K1)
{
if (Resizable()) ReSize(Extent());
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedMapNode* p;
p = data1[k1];
while (p) {
if (Hasher::IsEqual(p->Key1(),K1))
return p->Key2();
p = (TCollection_IndexedMapNode*) p->Next();
}
Increment();
TCollection_IndexedMapNode** data2 = (TCollection_IndexedMapNode**)myData2;
Standard_Integer k2 = ::HashCode(Extent(),NbBuckets());
p = new TCollection_IndexedMapNode(K1,Extent(),data1[k1],data2[k2]);
data1[k1] = p;
data2[k2] = p;
return Extent();
}
//=======================================================================
//function : Substitute
//purpose :
//=======================================================================
void TCollection_IndexedMap::Substitute(const Standard_Integer I,
const TheKey& K1)
{
Standard_OutOfRange_Raise_if(I < 1 || I > Extent(),
"IndexedMap::Substitute");
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**)myData1;
TCollection_IndexedMapNode* p;
// check if K1 is not already in the map
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
p = data1[k1];
while (p) {
if (Hasher::IsEqual(p->Key1(),K1))
Standard_DomainError::Raise("IndexedMap::Substitute");
p = (TCollection_IndexedMapNode*) p->Next();
}
// Find the node for the index I
TCollection_IndexedMapNode** data2 = (TCollection_IndexedMapNode**)myData2;
Standard_Integer k2 = ::HashCode(I,NbBuckets());
p = data2[k2];
while (p) {
if (p->Key2() == I)
break;
p = (TCollection_IndexedMapNode*) p->Next2();
}
// remove the old key
Standard_Integer k = Hasher::HashCode(p->Key1(),NbBuckets());
TCollection_IndexedMapNode* q = data1[k];
if (q == p) data1[k] = (TCollection_IndexedMapNode*) p->Next();
else {
while(q->Next() != p) q = (TCollection_IndexedMapNode*) q->Next();
q->Next() = p->Next();
}
// update the node
p->Key1() = K1;
p->Next() = data1[k1];
data1[k1] = p;
}
//=======================================================================
//function : RemoveLast
//purpose :
//=======================================================================
void TCollection_IndexedMap::RemoveLast()
{
Standard_OutOfRange_Raise_if(Extent() == 0,
"IndexedMap::RemoveLast");
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**)myData1;
TCollection_IndexedMapNode* p;
TCollection_IndexedMapNode* q;
// Find the node for the last index and remove it
TCollection_IndexedMapNode** data2 = (TCollection_IndexedMapNode**)myData2;
Standard_Integer k2 = ::HashCode(Extent(),NbBuckets());
p = data2[k2];
q = NULL;
while (p) {
if (p->Key2() == Extent())
break;
q = p;
p = (TCollection_IndexedMapNode*) p->Next2();
}
if (q == NULL)
data2[k2] = (TCollection_IndexedMapNode*)p->Next2();
else
q->Next2() = p->Next2();
// remove the key
Standard_Integer k = Hasher::HashCode(p->Key1(),NbBuckets());
q = data1[k];
if (q == p) data1[k] = (TCollection_IndexedMapNode*) p->Next();
else {
while(q->Next() != p) q = (TCollection_IndexedMapNode*) q->Next();
q->Next() = p->Next();
}
Decrement();
delete p;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_IndexedMap::Contains(const TheKey& K1) const
{
if (IsEmpty()) return Standard_False;
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return Standard_True;
p1 = (TCollection_IndexedMapNode*) p1->Next();
}
return Standard_False;
}
//=======================================================================
//function : FindKey
//purpose :
//=======================================================================
const TheKey& TCollection_IndexedMap::FindKey(const Standard_Integer K2) const
{
Standard_OutOfRange_Raise_if(K2 < 1 || K2 > Extent(), "IndexedMap");
TCollection_IndexedMapNode** data2 = (TCollection_IndexedMapNode**)myData2;
Standard_Integer k2 = ::HashCode(K2,NbBuckets());
TCollection_IndexedMapNode *p2;
p2 = data2[k2];
while (p2) {
if (p2->Key2() == K2) return p2->Key1();
p2 = (TCollection_IndexedMapNode*)p2->Next2();
}
Standard_OutOfRange::Raise("IndexedMap : missing index !!!");
return p2->Key1();
}
//=======================================================================
//function : FindIndex
//purpose :
//=======================================================================
Standard_Integer TCollection_IndexedMap::FindIndex(const TheKey& K1) const
{
if (IsEmpty()) return 0;
TCollection_IndexedMapNode** data1 = (TCollection_IndexedMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return p1->Key2();
p1 = (TCollection_IndexedMapNode*) p1->Next();
}
return 0;
}
// @@SDM: begin
// Copyright Open CasCade .....................................Version 5.0-00
// Lastly modified by : szy Date : 7-05-2003
// File history synopsis (creation,modification,correction)
// +---------------------------------------------------------------------------+
// ! Developer ! Comments ! Date ! Version !
// +-----------!-----------------------------------------!----------!----------+
// ! rle ! Creation ! 8-01-1993! 5.0-00-3!
// ! szy ! Modified Assign method ! 7-05-2003! 5.0-00-3!
// +---------------------------------------------------------------------------+
// @@SDM: end

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,20 @@
inline TCollection_IndexedMapNode::TCollection_IndexedMapNode(const TheKey& K1,const Standard_Integer K2,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2)
: TCollection_MapNode(n1),myKey1(K1),myKey2(K2),myNext2(n2)
{
}
inline TheKey& TCollection_IndexedMapNode::Key1() const
{
return (TheKey&)myKey1;
}
inline Standard_Integer& TCollection_IndexedMapNode::Key2() const
{
return (Standard_Integer&)myKey2;
}
inline TCollection_MapNodePtr& TCollection_IndexedMapNode::Next2() const
{
return (TCollection_MapNodePtr&)myNext2;
}

View File

@@ -0,0 +1,306 @@
-- File: TCollection_List.cdl
-- Created: Thu Dec 17 12:04:18 1992
-- Author: Remi LEQUETTE
-- <rle@phobox>
---Copyright: Matra Datavision 1992
generic class List from TCollection (Item as any)
---Purpose: Ordered lists of non-unique objects which can be
-- accessed sequentially using an iterator.
-- Item insertion in a list is very fast at any position. But
-- searching for items by value may be slow if the list is long,
-- because it requires a sequential search.
-- List is a generic class which depends on Item, the type of
-- element in the structure.
-- Use a ListIterator iterator to explore a List structure.
-- Notes:
-- - An iterator class is automatically instantiated from the
-- TCollection_ListIterator class at the time of
-- instantiation of a List structure.
-- - A sequence is a better structure when searching for
-- items by value is an important goal for a data structure.
-- - Queues and stacks are other kinds of list with a
-- different access to data.
uses
Address from Standard,
Boolean from Standard
raises
NoSuchObject from Standard
class ListNode from TCollection
inherits MapNode from TCollection
uses MapNodePtr from TCollection
is
Create(I : Item; n : MapNodePtr from TCollection) returns ListNode from TCollection;
---C++: inline
Value(me) returns Item;
---C++: return &
---C++: inline
fields
myValue : Item;
end;
class ListIterator
---Purpose: Functions used for iterating the contents of a List data structure.
-- A ListIterator object can be used to go through a list
-- sequentially, and to hold a position in a list as a
-- bookmark. It is not an index, however. Each step of the
-- iteration gives the current position of the iterator, to
-- which corresponds the current item in the list. The
-- current position is undefined if the list is empty, or when
-- the exploration is finished.
-- Note: an iterator class is automatically instantiated from
-- this generic class at the time of instantiation of a List
-- data structure.
raises
NoMoreObject from Standard,
NoSuchObject from Standard
is
Create returns ListIterator;
---Purpose: Constructs an empty iterator for a List data structure. Use
-- the function Initialize to define the list to explore.
Create(L : List) returns ListIterator;
---Purpose: Constructs an iterator on the list list, and positions it on
-- the first item of the list list, if it exists.
-- The current position is undefined if the list list is empty.
-- Use in a loop:
-- - the function More to know if there is a current item,
-- - then the function Value to read the value of the current item,
-- - then the function Next to position the iterator on the
-- next item, if it exists.
Initialize(me : in out; L : List)
---Purpose: Sets, or resets this iterator for the list list, and positions it
-- on the first item of the list list, if it exists.
-- The current position is undefined if the list list is empty.
-- Example
-- TColStd_ListOfInteger list;
-- TColStd_ListIteratorOfListOfInteger
-- pos;
-- pos.Initialize(list);
-- Use in a loop:
-- - the function More to know if there is a current item,
-- - then the function Value to read the value of the current item,
-- - then the function Next to position the iterator on the
-- next item, if it exists.
is static;
More(me) returns Boolean from Standard
---Purpose: Returns true if there is a current item in the list explored
-- with this iterator (i.e. when the current position is defined).
-- More is false if:
-- - the iterator is not initialized, or
-- - the list is empty, or
-- - the exploration is finished.
-- Use:
-- - the function Value to read the current item,
-- - the function Next to position this iterator on the next item, if it exists.
-- Example
-- Standard_Integer i;
-- TColStd_ListOfInteger s;
-- TColStd_ListIteratorOfListOfInteger
-- pos(s);
-- while(pos.More())
-- {
-- i = pos.Value();
-- pos.Next();
-- }
---C++: inline
is static;
Next(me : in out)
---Purpose: Sets this iterator on the next item in the explored list.
-- If the current position of this iterator corresponds to the
-- last item in the list, it becomes undefined.
-- Exceptions
-- Standard_NoMoreObject if the current position of this
-- iterator is undefined.
raises
NoMoreObject from Standard
is static;
Value(me) returns any Item
---Purpose: Returns the value of the current item of this iterator in the
-- explored list.
-- Note: Item is the type of element in the explored List list.
-- Example
-- TColStd_ListOfInteger s;
-- TColStd_ListIteratorOfListOfInteger
-- pos(s);
-- s.Append(1);
-- assert (pos.Value() == s.First() );
-- Exceptions
-- Standard_NoSuchObject if the current position of this
-- iterator is undefined.
---C++: return &
raises
NoSuchObject from Standard
is static;
fields
current : Address from Standard;
previous : Address from Standard;
friends
class List from TCollection
end ListIterator from TCollection;
is
Create returns List from TCollection;
---Purpose: Constructs an empty list.
-- Use:
-- - the function Append or Prepend to add an item or a
-- collection of items at the end, or at the beginning of the list,
-- - a list iterator to explore the list and read its items,
-- - and in conjunction with this iterator:
-- - the function InsertAfter or InsertBefore to add an
-- item or a collection of items at any position in the list,
-- - the function Remove to remove an item at any position in the list.
-- Warning
-- To copy a list, you must explicitly call the assignment operator (operator=).
Create(Other : List from TCollection)
returns List from TCollection
is private;
---Purpose: Creation by copy of existing list.
-- Warning: This constructor prints a warning message.
-- We recommand to use the operator =.
Assign(me : in out; Other : List from TCollection)
---Purpose: Replace <me> by a copy of <Other>.
---C++: alias operator=
is static;
Extent(me) returns Integer
---Purpose: Returns the number of items.
is static;
Clear(me : in out)
---Purpose: Clears the content of the list <me>.
---C++: alias ~
is static;
IsEmpty(me) returns Boolean from Standard
---Purpose: Returns true if this list is empty.
---C++: inline
is static;
Prepend(me : in out; I : Item)
---Level: Public
---Purpose: Insert the Item <I> at the head of the list.
is static;
-- san: 18/04/2003 - addition methods returns ListIterator
Prepend(me : in out; I : Item; theIt : in out ListIterator )
---Level: Public
---Purpose: Insert the Item <I> at the head of the list.
--- Returns ListIterator pointing to the first Item.
is static;
Prepend(me : in out; Other : in out List from TCollection)
---Level: Public
---Purpose: Insert the list <Other> at the head of <me>.
--- <Other> is cleared.
is static;
Append(me : in out; I : Item)
---Level: Public
---Purpose: Insert the Item <I> at the end of the list.
is static;
-- san: 18/04/2003 - addition methods returns ListIterator
Append(me : in out; I : Item; theIt : in out ListIterator )
---Level: Public
---Purpose: Insert the Item <I> at the head of the list.
--- Returns ListIterator pointing to the first Item.
is static;
Append(me : in out; Other : in out List from TCollection)
---Level: Public
---Purpose: Append the list <L> at the end of <me>.
--- <Other> is cleared.
is static;
First(me) returns any Item
---Purpose: Returns the first Item in the list, may be modified.
-- Trigger: Raises an exception when the list is empty.
---C++: return &
raises
NoSuchObject from Standard
is static;
Last(me) returns any Item
---Purpose: Returns the last Item in the list, may be modified.
-- Trigger: Raises an exception when the list is empty.
---C++: return &
raises
NoSuchObject from Standard
is static;
RemoveFirst(me : in out)
---Purpose: Removes the first Item from the list. Nothing is
-- done if the list is empty.
is static;
Remove(me : in out; It : in out ListIterator)
---Purpose: Removes the current Item of the ListIterator from the
-- List. The ListIterator current will be the next Item
-- in the list.
-- Exceptions
-- Standard_NoSuchObject if the current position of the
-- list iterator pos is undefined.
raises
NoSuchObject from Standard
is static;
InsertBefore (me : in out; I : Item;
It : in out ListIterator)
---Level: Public
---Purpose: Insert <I> in the List before the current position
-- of <It>. It is not change.
raises
NoSuchObject from Standard
is static;
InsertBefore (me : in out; Other : in out List from TCollection;
It : in out ListIterator)
---Level: Public
---Purpose: Insert <Other> in the List before the current position
-- of <It>. <It> is not change. <Other> is cleared.
raises
NoSuchObject from Standard
is static;
InsertAfter (me : in out; I : Item;
It : in out ListIterator)
---Level: Public
---Purpose: Insert <I> in the List after the current position
-- if <It>. <It> is not changed.
is static;
InsertAfter (me : in out; Other : in out List from TCollection;
It : in out ListIterator)
---Level: Public
---Purpose: Insert <Other> in the List after the current position
-- if <It>. <It> is not changed. <Other> is cleared.
is static;
fields
myFirst : Address from Standard;
myLast : Address from Standard;
friends
class ListIterator from TCollection
end List;

View File

@@ -0,0 +1,361 @@
// File: TCollection_List.gxx
// Created: Thu Dec 17 16:10:17 1992
// Author: Remi LEQUETTE
// <rle@phobox>
// Revised: Thu Jan 17 11:40:17 1995
// By: Mireille MERCIEN
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : TCollection_List
//purpose :
//=======================================================================
TCollection_List::TCollection_List() :
myFirst(NULL),
myLast(NULL)
{}
//=======================================================================
//function : TCollection_List
//purpose :
//=======================================================================
TCollection_List::TCollection_List(const TCollection_List& Other) :
myFirst(NULL),
myLast(NULL)
{
if (!Other.IsEmpty()) {
// cout << "List copied : magic constructor"<<endl;
TCollection_ListIterator It(Other);
while (It.More()) {
Append(It.Value());
It.Next();
}
}
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
void TCollection_List::Assign(const TCollection_List& Other)
{
if (this != &Other) {
Clear();
TCollection_ListIterator It(Other);
while (It.More()) {
Append(It.Value());
It.Next();
}
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TCollection_List::Clear()
{
TCollection_ListNode* p = (TCollection_ListNode*) myFirst;
TCollection_ListNode* q;
while (p != NULL) {
q = p;
p = (TCollection_ListNode*)q->Next();
delete q;
}
myFirst = myLast = NULL;
}
//=======================================================================
//function : Extent
//purpose :
//=======================================================================
Standard_Integer TCollection_List::Extent() const
{
Standard_Integer Size = 0;
TCollection_ListNode* p = (TCollection_ListNode*) myFirst;
while (p != NULL) {
Size++;
p = (TCollection_ListNode*)p->Next();
}
return Size;
}
//=======================================================================
//function : Prepend
//purpose :
//=======================================================================
void TCollection_List::Prepend(const Item& I)
{
myFirst = new TCollection_ListNode(I,(TCollection_ListNode*)myFirst);
if (myLast == NULL) myLast = myFirst;
}
//=======================================================================
//function : Prepend
//purpose :
//=======================================================================
void TCollection_List::Prepend(const Item& I, TCollection_ListIterator& theIt)
{
myFirst = new TCollection_ListNode(I,(TCollection_ListNode*)myFirst);
theIt.current = myFirst;
theIt.previous = NULL;
if (myLast == NULL) myLast = myFirst;
}
//=======================================================================
//function : Prepend
//purpose :
//=======================================================================
void TCollection_List::Prepend(TCollection_List& Other)
{
if (!Other.IsEmpty()) {
((TCollection_ListNode*)Other.myLast)->Next() = (TCollection_ListNode*)myFirst;
myFirst = Other.myFirst;
Other.myFirst = Other.myLast = NULL;
}
}
//=======================================================================
//function : Append
//purpose :
//=======================================================================
void TCollection_List::Append(const Item& I)
{
TCollection_ListNode* p = new TCollection_ListNode(I,(TCollection_MapNode*)0L);
if (myFirst == NULL) {
myFirst = myLast = p;
}
else {
((TCollection_ListNode*)myLast)->Next() = (TCollection_ListNode*)p;
myLast = p;
}
}
//=======================================================================
//function : Append
//purpose :
//=======================================================================
void TCollection_List::Append(const Item& I, TCollection_ListIterator& theIt)
{
TCollection_ListNode* p = new TCollection_ListNode(I,(TCollection_MapNode*)0L);
theIt.current = p;
theIt.previous = myLast;
if (myFirst == NULL) {
myFirst = myLast = p;
}
else {
((TCollection_ListNode*)myLast)->Next() = (TCollection_ListNode*)p;
myLast = p;
}
}
//=======================================================================
//function : Append
//purpose :
//=======================================================================
void TCollection_List::Append(TCollection_List& Other)
{
if (!Other.IsEmpty()) {
if (IsEmpty()) {
myFirst = Other.myFirst;
myLast = Other.myLast;
}
else {
((TCollection_ListNode*)myLast)->Next() = (TCollection_ListNode*)Other.myFirst;
myLast = Other.myLast;
}
Other.myLast = Other.myFirst = NULL;
}
}
//=======================================================================
//function : First
//purpose :
//=======================================================================
Item& TCollection_List::First() const
{
Standard_NoSuchObject_Raise_if(myFirst == NULL,"List:First");
return ((TCollection_ListNode*) myFirst)->Value();
}
//=======================================================================
//function : Last
//purpose :
//=======================================================================
Item& TCollection_List::Last() const
{
Standard_NoSuchObject_Raise_if(myLast == NULL,"List:Last");
return ((TCollection_ListNode*) myLast)->Value();
}
//=======================================================================
//function : RemoveFirst
//purpose :
//=======================================================================
void TCollection_List::RemoveFirst()
{
if (myFirst == NULL) return;
TCollection_ListNode* p = (TCollection_ListNode*) myFirst;
myFirst = p->Next();
delete p;
if (myFirst == NULL) myLast = NULL;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
void TCollection_List::Remove(TCollection_ListIterator& It)
{
Standard_NoSuchObject_Raise_if(!It.More(),
"TCollection_List::Remove");
if (It.previous == NULL) {
RemoveFirst();
It.current = myFirst;
}
else {
TCollection_ListNode* p = (TCollection_ListNode*)((TCollection_ListNode*) It.current)->Next();
((TCollection_ListNode*)It.previous)->Next() = (TCollection_ListNode*)p;
delete ((TCollection_ListNode*) It.current);
It.current = p;
if (p == NULL) myLast = It.previous;
}
}
//=======================================================================
//function : InsertBefore
//purpose :
//=======================================================================
void TCollection_List::InsertBefore(const Item& I,
TCollection_ListIterator& It)
{
Standard_NoSuchObject_Raise_if(!It.More(), "TCollection_List::InsertBefore");
if (It.previous == NULL) {
Prepend(I);
It.previous = myFirst;
}
else {
TCollection_ListNode* p = new TCollection_ListNode(I,(TCollection_ListNode*)It.current);
((TCollection_ListNode*)It.previous)->Next() = (TCollection_ListNode*)p;
It.previous = p;
}
}
//=======================================================================
//function : InsertBefore
//purpose :
//=======================================================================
void TCollection_List::InsertBefore(TCollection_List& Other,
TCollection_ListIterator& It)
{
Standard_NoSuchObject_Raise_if(!It.More(), "TCollection_List::InsertBefore");
if (!Other.IsEmpty()) {
if (It.previous == NULL) {
It.previous = Other.myLast;
Prepend(Other);
}
else {
((TCollection_ListNode*)It.previous)->Next() = (TCollection_ListNode*)Other.myFirst;
((TCollection_ListNode*)Other.myLast)->Next() = (TCollection_ListNode*)It.current;
It.previous = Other.myLast;
Other.myLast = Other.myFirst = NULL;
}
}
}
//=======================================================================
//function : InsertAfter
//purpose :
//=======================================================================
void TCollection_List::InsertAfter(const Item& I, TCollection_ListIterator& It)
{
Standard_NoSuchObject_Raise_if(!It.More(),"TCollection_List::InsertAfter");
if (It.current == myLast)
Append(I);
else {
TCollection_ListNode* p = new TCollection_ListNode(I,((TCollection_ListNode*)It.current)->Next());
((TCollection_ListNode*)It.current)->Next() = (TCollection_ListNode*)p;
}
}
//=======================================================================
//function : InsertAfter
//purpose :
//=======================================================================
void TCollection_List::InsertAfter(TCollection_List& Other,
TCollection_ListIterator& It)
{
Standard_NoSuchObject_Raise_if(!It.More(),"TCollection_List::InsertAfter");
if (It.current == myLast)
Append(Other);
else if (!Other.IsEmpty()) {
((TCollection_ListNode*)Other.myLast)->Next() = ((TCollection_ListNode*)It.current)->Next();
((TCollection_ListNode*)It.current)->Next() = (TCollection_ListNode*)Other.myFirst;
Other.myLast = Other.myFirst = NULL;
}
}
//=======================================================================
//function : TCollection_ListIterator
//purpose :
//=======================================================================
void TCollection_ListIterator::Next()
{
Standard_NoMoreObject_Raise_if(current == NULL,
"TCollection_ListIteratorOfList");
previous = current;
current = ((TCollection_ListNode*)previous)->Next();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Item& TCollection_ListIterator::Value() const
{
Standard_NoSuchObject_Raise_if(current == NULL,
"TCollection_ListIteratorOfList");
return ((TCollection_ListNode*)current)->Value();
}

View File

@@ -0,0 +1,17 @@
// File: TCollection_List.lxx
// Created: Thu Dec 17 16:30:53 1992
// Author: Remi LEQUETTE
// <rle@phobox>
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_List::IsEmpty() const
{
return myFirst == 0L;
}

View File

@@ -0,0 +1,41 @@
// File: TCollection_ListIterator.gxx
// Created: Thu Dec 17 18:19:38 1992
// Author: Remi LEQUETTE
// <rle@phobox>
//
// The methods of Iterator needing the Node class
// are defined in TCollection_List.gxx
//
//=======================================================================
//function : TCollection_ListIterator
//purpose :
//=======================================================================
TCollection_ListIterator::TCollection_ListIterator() :
current(NULL),
previous(NULL)
{}
//=======================================================================
//function : TCollection_ListIterator
//purpose :
//=======================================================================
TCollection_ListIterator::TCollection_ListIterator(const TCollection_List& L) :
current(L.myFirst),
previous(NULL)
{}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void TCollection_ListIterator::Initialize(const TCollection_List& L)
{
current = L.myFirst;
previous = NULL;
}

View File

@@ -0,0 +1,15 @@
// File: TCollection_ListIterator.lxx
// Created: Thu Dec 17 18:15:01 1992
// Author: Remi LEQUETTE
// <rle@phobox>
//=======================================================================
//function : More
//purpose :
//=======================================================================
inline Standard_Boolean TCollection_ListIterator::More() const
{
return current != 0L;
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,11 @@
inline TCollection_ListNode::TCollection_ListNode(const Item& I,const TCollection_MapNodePtr& n)
: TCollection_MapNode(n)
{
myValue = I;
}
inline Item& TCollection_ListNode::Value() const
{
return (Item&)myValue;
}

View File

@@ -0,0 +1,163 @@
-- File: TCollection_Map.cdl
-- Created: Thu Jan 7 14:39:40 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class Map from TCollection (TheKey as any;
Hasher as any) -- as MapHasher(TheKey)
inherits BasicMap from TCollection
---Purpose: Basic hashed Map. This Map is used to store and
-- retrieve keys in linear time.
--
-- The MapIterator class can be used to explore the
-- content of the map. It is not wise to iterate and
-- modify a map in parallel.
--
-- The Hasher argument is used to computes the
-- hashcode of key and compare two keys.
--
-- The performance of a Map is conditionned by its
-- number of buckets that should be kept greater to
-- the number of keys. This map has an automatic
-- management of the number of buckets. It is resized
-- when the number of Keys becomes greater than the
-- number of buckets.
--
-- If you have a fair idea of the number of objects
-- you can save on automatic resizing by giving a
-- number of buckets at creation or using the ReSize
-- method. This should be consider only for crucial
-- optimisation issues.
-- An entry of a Map is composed of the key only. No data is
-- attached to the key. A Map is typically used by an
-- algorithm to know if some action is still performed on
-- components of a complex data structure.
-- Map is a generic class which depends on two parameters:
-- - Key is the type of key in the map,
-- - Hasher is the type of hasher on keys.
-- Use a MapIterator iterator to explore a Map map.
-- Notes:
-- - An iterator class is automatically instantiated from the
-- TCollection_MapIterator class at the time of
-- instantiation of a Map map.
-- - TCollection_MapHasher class describes the
-- functions required for a Hasher object.
raises
DomainError from Standard
class StdMapNode from TCollection
inherits MapNode from TCollection
uses MapNodePtr from TCollection
is
Create(K : TheKey; n : MapNodePtr from TCollection) returns StdMapNode from TCollection;
---C++: inline
Key(me) returns TheKey;
---C++: return &
---C++: inline
fields
myKey : TheKey;
end;
class MapIterator inherits BasicMapIterator from TCollection
---Purpose: Provides iteration on the content of a map. The
-- iteration methods are inherited from the
-- BasicMapIterator.
-- Note: an iterator class is automatically instantiated from
-- this generic class at the time of instantiation of a <Map>.
-- Warning
-- - A map is a non-ordered data structure. The order in
-- which entries of a map are explored by the iterator
-- depends on its contents, and changes when the map is edited.
-- - It is not recommended to modify the contents of a map
-- during iteration: the result is unpredictable.
raises NoSuchObject from Standard
is
Create returns MapIterator from TCollection;
---Purpose: Creates an empty iterator for a Map map; use the function
-- Initialize to define the map to explore;
Create (aMap : Map from TCollection)
returns MapIterator from TCollection;
---Purpose: Creates an Iterator on the map <aMap>.
Initialize(me : in out; aMap : Map from TCollection)
---Purpose: Sets or resets the Iterator in the map <aMap>.
is static;
Key(me) returns any TheKey
---Purpose: Returns the current Key. An error is raised if
-- the iterator is empty (More returns False).
-- Note: Key is the type of key for an entry in the explored <Map>.
-- Exceptions
-- Standard_NoSuchObject if this iterator is empty (i.e.
-- when the function More returns false).
---C++: return const &
raises
NoSuchObject from Standard
is static;
end MapIterator from TCollection;
is
Create(NbBuckets : Integer = 1) returns Map from TCollection;
---Purpose: Constructs a Map with NbBuckets (defaulted to 1) buckets.
-- Note that the map will be automatically redimensioned
-- during its use if the number of entries becomes too large.
-- Use:
-- - the function Add to add a new key in the map,
-- - the function Remove to remove a key from the map,
-- - and a map iterator to explore the map.
Create(Other : Map from TCollection) returns Map from TCollection
---Purpose: As copying Map is an expensive operation it is
-- incorrect to do it implicitly. This constructor
-- will raise an error if the Map is not empty. To
-- copy the content of a Map use the Assign method (operator =).
raises DomainError from Standard
is private;
Assign(me : in out; Other : Map from TCollection)
returns Map from TCollection
---Purpose: Replace the content of this map by the content of
-- the map <Other>.
---C++: alias operator =
---C++: return &
is static;
ReSize(me : in out; NbBuckets : Integer)
---Purpose: Changes the number of buckets of <me> to be
-- <NbBuckets>. The keys already stored in the map are kept.
is static;
Clear(me : in out)
---Purpose: Removes all keys in the map.
---C++: alias ~
is static;
Add(me : in out; aKey : TheKey) returns Boolean
---Purpose: Adds the Key <aKey> to the Map <me>. Returns True
-- if the Key was not already in the Map.
is static;
Contains(me; aKey : TheKey) returns Boolean
---Purpose: Returns True if the key <aKey> is stored in the
-- map <me>.
is static;
Remove(me : in out; aKey : TheKey) returns Boolean
---Purpose: Removes the Key <aKey> from the map. Returns True
-- if the Key was in the Map.
is static;
end Map;

View File

@@ -0,0 +1,206 @@
// Lastly modified by :
// +---------------------------------------------------------------------------+
// ! szy ! Modified Assign method ! 7-05-2003! 3.0-00-2!
// +---------------------------------------------------------------------------+
// File: TCollection_Map.gxx
// Created: Thu Jan 7 18:14:26 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#include <Standard_DomainError.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : TCollection_Map
//purpose :
//=======================================================================
TCollection_Map::TCollection_Map(const Standard_Integer NbBuckets) :
TCollection_BasicMap(NbBuckets,Standard_True)
{
}
//=======================================================================
//function : TCollection_Map
//purpose :
//=======================================================================
TCollection_Map::TCollection_Map(const TCollection_Map& Other) :
TCollection_BasicMap(Other.NbBuckets(),Standard_True)
{
if (Other.Extent() != 0)
Standard_DomainError::Raise("TCollection:Copy of Map");
}
//=======================================================================
//function : Assign
//purpose :
//=======================================================================
TCollection_Map& TCollection_Map::Assign(const TCollection_Map& Other)
{
if (this == &Other) return *this;
Clear();
// ReSize(Other.NbBuckets());
if (!Other.IsEmpty()) {
ReSize(Other.Extent());
for (TCollection_MapIterator It(Other); It.More(); It.Next()) {
Add(It.Key());
}
}
return *this;
}
//=======================================================================
//function : ReSize
//purpose :
//=======================================================================
void TCollection_Map::ReSize(const Standard_Integer N)
{
Standard_Integer newBuck;
Standard_Address newData1=NULL, dummy=NULL;
if (BeginResize(N,newBuck,newData1,dummy)) {
if (myData1) {
TCollection_StdMapNode** newdata = (TCollection_StdMapNode**)newData1;
TCollection_StdMapNode** olddata = (TCollection_StdMapNode**) myData1;
TCollection_StdMapNode *p, *q;
Standard_Integer i,k;
for (i = 0; i <= NbBuckets(); i++) {
if (olddata[i]) {
p = olddata[i];
while (p) {
k = Hasher::HashCode(p->Key(),newBuck);
q = (TCollection_StdMapNode*) p->Next();
p->Next() = newdata[k];
newdata[k] = p;
p = q;
}
}
}
}
EndResize(N,newBuck,newData1,dummy);
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TCollection_Map::Clear()
{
if (!IsEmpty()) {
Standard_Integer i;
TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
TCollection_StdMapNode *p,*q;
for (i = 0; i <= NbBuckets(); i++) {
if (data[i]) {
p = data[i];
while (p) {
q = (TCollection_StdMapNode*)p->Next();
delete p;
p = q;
}
}
}
}
TCollection_BasicMap::Destroy();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Boolean TCollection_Map::Add(const TheKey& K)
{
if (Resizable()) ReSize(Extent());
TCollection_StdMapNode** data = (TCollection_StdMapNode**)myData1;
Standard_Integer k = Hasher::HashCode(K,NbBuckets());
TCollection_StdMapNode* p = data[k];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) return Standard_False;
p = (TCollection_StdMapNode*)p->Next();
}
data[k] = new TCollection_StdMapNode(K,data[k]);
Increment();
return Standard_True;
}
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_Map::Contains(const TheKey& K) const
{
if (IsEmpty()) return Standard_False;
TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
TCollection_StdMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return Standard_True;
}
p = (TCollection_StdMapNode*)p->Next();
}
return Standard_False;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean TCollection_Map::Remove(const TheKey& K)
{
if (IsEmpty()) return Standard_False;
TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
Standard_Integer k = Hasher::HashCode(K,NbBuckets());
TCollection_StdMapNode* p = data[k];
TCollection_StdMapNode* q = NULL;
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
Decrement();
if (q) q->Next() = p->Next();
else data[k] = (TCollection_StdMapNode*) p->Next();
delete p;
return Standard_True;
}
q = p;
p = (TCollection_StdMapNode*) p->Next();
}
return Standard_False;
}
// method of the iterator
//=======================================================================
//function : Key
//purpose :
//=======================================================================
const TheKey& TCollection_MapIterator::Key() const
{
Standard_NoSuchObject_Raise_if(!More(),"TCollection_MapIterator::Key");
return ((TCollection_StdMapNode*) myNode)->Key();
}
// @@SDM: begin
// Copyright Open CasCade......................................Version 5.0-00
// Lastly modified by : szy Date : 7-05-2003
// File history synopsis (creation,modification,correction)
// +---------------------------------------------------------------------------+
// ! Developer ! Comments ! Date ! Version !
// +-----------!-----------------------------------------!----------!----------+
// ! rle ! Creation ! 7-01-1993! 5.0-00-2!
// ! szy ! Modified Assign method ! 7-05-2003! 5.0-00-2!
// +---------------------------------------------------------------------------+
// @@SDM: end

View File

@@ -0,0 +1,50 @@
-- File: TCollection_MapHasher.cdl
-- Created: Thu Jan 7 15:58:43 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
generic class MapHasher from TCollection (Key as any)
---Purpose: A hasher on the keys of a map instantiated from the
-- Collections component.
-- A hasher provides two functions:
-- - The hashing function (HashCode) transforms a key
-- into a bucket index in the map. The number of values
-- that can be computed by the hashing function is equal
-- to the number of buckets in the map.
-- - IsEqual is the equality test between two keys.
-- Hashers are used as parameters in generic maps
-- provided by the Collections component.
-- MapHasher is a generic class which depends on the type
-- of keys, provided that Key is a type from the Standard
-- package. In such cases MapHasher may be directly
-- instantiated with Key. Note that the package TColStd
-- provides some of these instantiations.
-- But if Key is not a type from the Standard package you
-- must consider MapHasher as a template and build a class
-- which includes its functions, in order to use it as a hasher
-- in a map instantiated from the Collections component.
-- Note that TCollection_AsciiString and
-- TCollection_ExtendedString classes correspond to
-- these specifications, in consequence they may be used as
-- hashers: when Key is one of these two types you may just
-- define the hasher as the same type at the time of
-- instantiation of your map.
is
HashCode(myclass; K : Key; Upper : Integer) returns Integer;
---Level: Public
---Purpose: Returns a HasCode value for the Key <K> in the
-- range 0..Upper.
-- Default ::HashCode(K,Upper)
IsEqual(myclass; K1, K2 : Key) returns Boolean;
---Level: Public
---Purpose: Returns True when the two keys are the same. Two
-- same keys must have the same hashcode, the
-- contrary is not necessary.
-- Default K1 == K2
end MapHasher;

View File

@@ -0,0 +1,18 @@
// File: TCollection_MapHasher.gxx
// Created: Thu Jan 7 19:41:51 1993
// Author: Remi LEQUETTE
// <rle@phylox>
Standard_Integer TCollection_MapHasher::HashCode(const Key& K,
const Standard_Integer Upper)
{
return ::HashCode(K,Upper);
//return K->HashCode(Upper);
}
Standard_Boolean TCollection_MapHasher::IsEqual(const Key& K1,
const Key& K2)
{
return K1 == K2;
}

View File

@@ -0,0 +1,34 @@
// File: TCollection_MapIterator.gxx
// Created: Fri Feb 26 14:51:38 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//function : TCollection_MapIterator
//purpose :
//=======================================================================
TCollection_MapIterator::TCollection_MapIterator() :
TCollection_BasicMapIterator()
{}
//=======================================================================
//function : TCollection_MapIterator
//purpose :
//=======================================================================
TCollection_MapIterator::TCollection_MapIterator(const TCollection_Map& aMap) :
TCollection_BasicMapIterator(aMap)
{}
//=======================================================================
//function : TCollection_MapIterator
//purpose :
//=======================================================================
void TCollection_MapIterator::Initialize(const TCollection_Map& aMap)
{
TCollection_BasicMapIterator::Initialize(aMap);
}

View File

@@ -0,0 +1,22 @@
-- File: TCollection_MapNode.cdl
-- Created: Mon Jan 19 17:41:44 1998
-- Author: Kernel
-- <kernel@parigox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
private class MapNode from TCollection
inherits TShared from MMgt
uses MapNodePtr from TCollection
is
Create(n : MapNodePtr from TCollection) returns MapNode from TCollection;
---C++: inline
Next(me) returns MapNodePtr from TCollection;
---C++: inline
---C++: return &
fields
myNext : MapNodePtr from TCollection;
end;

View File

@@ -0,0 +1 @@
#include <TCollection_MapNode.ixx>

View File

@@ -0,0 +1,11 @@
#include <TCollection_MapNodePtr.hxx>
inline TCollection_MapNode::TCollection_MapNode(const TCollection_MapNodePtr& n)
: myNext(n)
{
}
inline TCollection_MapNodePtr& TCollection_MapNode::Next() const
{
return (TCollection_MapNodePtr&)myNext;
}

View File

@@ -0,0 +1,143 @@
-- File: TCollection_Queue.cdl
-- Created: Mon Jan 18 14:08:21 1993
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1993
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

@@ -0,0 +1,140 @@
// File: TCollection_Queue.gxx
// Created: Mon Jan 18 14:55:37 1993
// Author: Remi LEQUETTE
// <rle@phylox>
#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

@@ -0,0 +1,26 @@
// File: TCollection_Queue.lxx
// Created: Mon Jan 18 14:54:20 1993
// Author: Remi LEQUETTE
// <rle@phylox>
//=======================================================================
//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;
}

Some files were not shown because too many files have changed in this diff Show More