Salome HOME
This commit was generated by cvs2git to create branch 'IMPORT'.
[modules/smesh.git] / src / SMDS / SMDS_MapOfMeshOrientedElement.cxx
1 using namespace std;
2 // File:        SMDS_MapOfMeshOrientedElement.cxx
3 // Created:     Fri Jan 25 11:47:26 2002
4 // Author:      Jean-Michel BOULCOURT
5 //              <jmb@coulox.paris1.matra-dtv.fr>
6
7
8 #include "SMDS_MapOfMeshOrientedElement.ixx"
9 #include <Standard_NoSuchObject.hxx>
10
11
12 #ifndef _Standard_DomainError_HeaderFile
13 #include <Standard_DomainError.hxx>
14 #endif
15 #ifndef _SMDS_MeshElement_HeaderFile
16 #include "SMDS_MeshElement.hxx"
17 #endif
18 #ifndef _SMDS_MeshElementMapHasher_HeaderFile
19 #include "SMDS_MeshElementMapHasher.hxx"
20 #endif
21 #ifndef _SMDS_StdMapNodeOfExtendedOrientedMap_HeaderFile
22 #include "SMDS_StdMapNodeOfExtendedOrientedMap.hxx"
23 #endif
24 #ifndef _SMDS_MapIteratorOfExtendedOrientedMap_HeaderFile
25 #include "SMDS_MapIteratorOfExtendedOrientedMap.hxx"
26 #endif
27  
28
29 #define TheKey Handle_SMDS_MeshElement
30 #define TheKey_hxx <SMDS_MeshElement.hxx>
31 #define Hasher SMDS_MeshElementMapHasher
32 #define Hasher_hxx <SMDS_MeshElementMapHasher.hxx>
33 #define TCollection_StdMapNode SMDS_StdMapNodeOfExtendedOrientedMap
34 #define TCollection_StdMapNode_hxx <SMDS_StdMapNodeOfExtendedOrientedMap.hxx>
35 #define TCollection_MapIterator SMDS_MapIteratorOfExtendedOrientedMap
36 #define TCollection_MapIterator_hxx <SMDS_MapIteratorOfExtendedOrientedMap.hxx>
37 #define Handle_TCollection_StdMapNode Handle_SMDS_StdMapNodeOfExtendedOrientedMap
38 #define TCollection_StdMapNode_Type_() SMDS_StdMapNodeOfExtendedOrientedMap_Type_()
39 #define TCollection_Map SMDS_ExtendedOrientedMap
40 #define TCollection_Map_hxx <SMDS_ExtendedOrientedMap.hxx>
41
42
43
44 //=======================================================================
45 //function : Find
46 //purpose  : 
47 //=======================================================================
48
49 const Handle(SMDS_MeshElement)& SMDS_MapOfMeshOrientedElement::Find(const TheKey& K) const
50 {
51   if (IsEmpty()) {
52     Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::Find");
53   }
54 //  Standard_NoSuchObject_Raise_if(IsEmpty(),"SMDS_MapOfMeshOrientedElement::Find");
55   TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
56   TCollection_StdMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
57   while (p) {
58     if (Hasher::IsEqual(p->Key(),K)) {
59       return p->Key();
60       }
61     p = (TCollection_StdMapNode*) p->Next();
62   }
63   Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::Find");
64   return p->Key();
65 }
66
67 //=======================================================================
68 //function : ChangeFind
69 //purpose  : 
70 //=======================================================================
71
72 Handle(SMDS_MeshElement)& SMDS_MapOfMeshOrientedElement::ChangeFind(const TheKey& K)
73 {
74   if (IsEmpty()) {
75     Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::ChangeFind");
76   }
77 //Standard_NoSuchObject_Raise_if(IsEmpty(),"SMDS_MapOfMeshOrientedElement::ChangeFind");
78   TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
79   TCollection_StdMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
80   while (p) {
81     if (Hasher::IsEqual(p->Key(),K)) {
82       return p->Key();
83       }
84     p = (TCollection_StdMapNode*)  p->Next();
85   }
86   Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::ChangeFind");
87   return p->Key();
88 }
89
90
91 //=======================================================================
92 //function : FindID
93 //purpose  : 
94 //=======================================================================
95
96 const Handle(SMDS_MeshElement)& SMDS_MapOfMeshOrientedElement::FindID(const Standard_Integer ID) const
97 {
98   if (IsEmpty()) {
99     Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::FindID");
100   }
101 //  Standard_NoSuchObject_Raise_if(IsEmpty(),"SMDS_MapOfMeshOrientedElement::Find");
102   TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
103   TCollection_StdMapNode* p = data[ID % NbBuckets()];
104   while (p) {
105     if (p->Key()->GetID() == ID) {
106       return p->Key();
107       }
108     p = (TCollection_StdMapNode*) p->Next();
109   }
110   Standard_NoSuchObject::Raise("SMDS_MapOfMeshOrientedElement::Find");
111   return  p->Key();
112 }
113
114 //=======================================================================
115 //function : ContainsID
116 //purpose  : 
117 //=======================================================================
118
119 Standard_Boolean SMDS_MapOfMeshOrientedElement::ContainsID(const Standard_Integer ID) const
120 {
121   if (IsEmpty()) return Standard_False;
122   TCollection_StdMapNode** data = (TCollection_StdMapNode**) myData1;
123   TCollection_StdMapNode* p = data[ID % NbBuckets()];
124   while (p) {
125     if (p->Key()->GetID() == ID) {
126       return Standard_True;
127       }
128     p = (TCollection_StdMapNode*)p->Next();
129   }
130   return Standard_False;
131 }