/usr/include/opencascade/PCollection_HSet.gxx is in libopencascade-ocaf-lite-dev 6.5.0.dfsg-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | #include <Standard_NoSuchObject.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NotImplemented.hxx>
// ------------
// constructor
// -----------
PCollection_HSet::PCollection_HSet()
{
TheExtent = 0;
TheLast = new PCollection_SetNode;
}
// -----------------------------
// IsEmpty : is the Set empty ?
// -----------------------------
Standard_Boolean PCollection_HSet::IsEmpty() const
{
return TheLast->IsEmpty();
}
// ----------------
// Contains an item
// ----------------
Standard_Boolean PCollection_HSet::Contains(const Item& T) const
{
Standard_Boolean Ilela;
Handle(PCollection_SetNode) TheCurrent;
TheCurrent = TheLast;
Ilela = Standard_False;
while (!Ilela && !TheCurrent->IsEmpty())
{
if (TheCurrent->Value() == T)
Ilela = Standard_True;
else
TheCurrent = TheCurrent->Tail();
};
return Ilela;
}
// ---------------------------------
// The Set S IsASubset of the set me
// ---------------------------------
Standard_Boolean PCollection_HSet::IsASubset(const Handle(PCollection_HSet)& S) const
{
Standard_Boolean Ilela,Ilsonla;
Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
TheCurrent1 = TheLast;
TheCurrent2 = S->Last();
Ilela = Standard_False;
Ilsonla = Standard_True;
while (Ilsonla && !TheCurrent2->IsEmpty())
{
while (!Ilela && !TheCurrent1->IsEmpty())
{
if (TheCurrent1->Value() == TheCurrent2->Value())
Ilela = Standard_True;
else
TheCurrent1 = TheCurrent1->Tail();
};
if (!Ilela)
Ilsonla = Standard_False;
else
{
TheCurrent2 = TheCurrent2->Tail();
TheCurrent1 = TheLast;
};
};
return Ilsonla;
}
// ----------------------------------------
// The Set S IsAProperSubset of the set me
// ----------------------------------------
Standard_Boolean PCollection_HSet::IsAProperSubset(const Handle(PCollection_HSet)& S) const
{
Standard_Boolean Ilela,Ilsonla;
Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
TheCurrent1 = TheLast;
TheCurrent2 = S->Last();
Ilela = Standard_False;
Ilsonla = Standard_True;
if (S->Extent() >= TheExtent) Ilsonla = Standard_False;
while (Ilsonla && !TheCurrent2->IsEmpty())
{
while (!Ilela && !TheCurrent1->IsEmpty())
{
if (TheCurrent1->Value() == TheCurrent2->Value())
Ilela = Standard_True;
else
TheCurrent1 = TheCurrent1->Tail();
};
if (!Ilela)
Ilsonla = Standard_False;
else
{
TheCurrent2 = TheCurrent2->Tail();
TheCurrent1 = TheLast;
};
};
return Ilsonla;
}
// ------------------------------------
// Clear : remove all items
// ------------------------------------
void PCollection_HSet::Clear()
{
Handle(PCollection_SetNode) temp;
while (TheExtent != 0) {
temp = TheLast;
TheLast = TheLast->Tail();
#ifndef CSFDB
temp.Delete();
#endif
--TheExtent;
}
}
// -------------------------------------------
// Add : insert an item
// returns Standard_True if the item has been inserted,
// Standard_False otherwise
// -------------------------------------------
Standard_Boolean PCollection_HSet::Add(const Item& T)
{
Standard_Boolean Dejala;
Handle(PCollection_SetNode) TheCurrent;
TheCurrent = TheLast;
Dejala = Standard_False;
while (!Dejala && !TheCurrent->IsEmpty())
{ if (TheCurrent->Value() == T) Dejala = Standard_True;
TheCurrent = TheCurrent->Tail();
};
if (!Dejala)
{
TheLast = TheLast->Construct(T);
TheExtent = TheExtent + 1;
};
return !Dejala;
}
// ------------------------
// Remove : remove an item
// from the set me.
// Raises Standard_NoSuchObject
// ------------------------
void PCollection_HSet::Remove(const Item& T)
{
Standard_Boolean Nepala;
Handle(PCollection_SetNode) TheCurrent,ThePrevious;
TheCurrent = TheLast;
ThePrevious = TheLast;
Nepala = Standard_True;
while (Nepala && !TheCurrent->IsEmpty()) {
if (TheCurrent->Value() == T)
Nepala = Standard_False;
else {
ThePrevious = TheCurrent;
TheCurrent = TheCurrent->Tail();
}
}
if (Nepala)
Standard_NoSuchObject::Raise();
else {
if (TheCurrent == ThePrevious)
TheLast = TheLast->Tail();
else
ThePrevious->ChangeForwardPointer(TheCurrent->Tail());
TheExtent = TheExtent - 1;
#ifndef CSFDB
TheCurrent.Delete();
#endif
}
}
// ------------------------------------
// Union with the set S
// returns a set containing all the
// items of the set me and all the items
// of the set B which are not in me
// ------------------------------------
Handle(PCollection_HSet) PCollection_HSet::Union(const Handle(PCollection_HSet)& S)
const
{
Standard_Boolean Insere;
Handle(PCollection_SetNode) TheCurrent;
Handle(PCollection_HSet) Lunion;
Lunion = new PCollection_HSet;
// copier this dans Lunion
TheCurrent = TheLast;
while (!TheCurrent->IsEmpty())
{
Insere = Lunion->Add(TheCurrent->Value());
TheCurrent = TheCurrent->Tail();
};
// Inserer dans Lunion les items de S
TheCurrent = S->Last();
while (!TheCurrent->IsEmpty())
{
Insere = Lunion->Add(TheCurrent->Value());
TheCurrent = TheCurrent->Tail();
};
return Lunion;
}
// -----------------------------
// Intersection with the set S
// -----------------------------
Handle(PCollection_HSet) PCollection_HSet::
Intersection(const Handle(PCollection_HSet)& S)
const
{
Item Litem;
Standard_Boolean Insere;
Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
Handle(PCollection_HSet) Linter;
Linter = new PCollection_HSet;
TheCurrent1 = TheLast;
while (!TheCurrent1->IsEmpty())
{
Litem = TheCurrent1->Value();
TheCurrent2 = S->Last();
while (!TheCurrent2->IsEmpty())
{
if (TheCurrent2->Value() == Litem)
Insere = Linter->Add(Litem);
TheCurrent2 = TheCurrent2->Tail();
};
TheCurrent1 = TheCurrent1->Tail();
};
return Linter;
}
// -----------------------------
// Difference with the set S
// returns a set containing the
// items which are in the set me
// and not in the set B
// -----------------------------
Handle(PCollection_HSet) PCollection_HSet::
Difference(const Handle(PCollection_HSet)& S)
const
{
Item Litem;
Standard_Boolean Insere,Ilela;
Handle(PCollection_SetNode) TheCurrent1,TheCurrent2;
Handle(PCollection_HSet) Ladif;
Ladif = new PCollection_HSet;
TheCurrent1 = TheLast;
while (!TheCurrent1->IsEmpty())
{
Litem = TheCurrent1->Value();
TheCurrent2 = S->Last();
Ilela = Standard_False;
while (!TheCurrent2->IsEmpty() && !Ilela)
{
if (TheCurrent2->Value() == Litem)
Ilela = Standard_True;
else
TheCurrent2 = TheCurrent2->Tail();
};
if (!Ilela)
Insere = Ladif->Add(Litem);
TheCurrent1 = TheCurrent1->Tail();
};
return Ladif;
}
//---------------------------------------------------------------------
// ShallowCopy
//---------------------------------------------------------------------
Handle(Standard_Persistent) PCollection_HSet::ShallowCopy() const
{
PCollection_HSet* TheCopy = new PCollection_HSet (*this);
TheCopy->TheLast =
Handle(PCollection_SetNode)::DownCast(::ShallowCopy(TheLast));
return TheCopy;
}
//---------------------------------------------------------------------
// ShallowDump
//---------------------------------------------------------------------
void PCollection_HSet::ShallowDump(Standard_OStream& S) const
{
S << "begin class Set "<<endl;
S << "extent of Set : "<< TheExtent << endl;
TheLast->ShallowDump(S);
S << "end of class Set." << endl;
}
// -----------------------------
// Extent : numbers of items
// -----------------------------
Standard_Integer PCollection_HSet::Extent() const {
return TheExtent;
}
// -----------------------------
// Last : last enterred item
// -----------------------------
Handle(PCollection_SetNode) PCollection_HSet::Last() const {
return TheLast;
}
|