hash-table with optional Get

This commit is contained in:
Joachim Schoeberl 2023-05-19 14:45:56 +02:00
parent f802197576
commit e8286776df
2 changed files with 15 additions and 1 deletions

View File

@ -773,6 +773,15 @@ public:
return (pos != -1);
}
inline optional<T> GetIfUsed (const INDEX_2 & ahash) const
{
int pos = Position0 (ahash);
if (pos != -1)
return cont[pos];
else
return nullopt;
}
inline void SetData0 (int pos, const INDEX_2 & ahash, const T & acont)
{
hash[pos] = ahash;

View File

@ -3279,10 +3279,16 @@ namespace netgen
edge.Sort();
PointIndex newp;
/*
if (cutedges.Used (edge))
{
newp = cutedges.Get(edge);
}
*/
if (auto optnewp = cutedges.GetIfUsed(edge))
{
newp = *optnewp;
}
else
{
Point<3> npt = Center (mesh.Point (edge.I1()),
@ -3296,7 +3302,6 @@ namespace netgen
mtets.Elem(i) = newtet1;
mtets.Append (newtet2);
mesh.mlparentelement.Append (i);
}
NgProfiler::StopTimer (timer_bisecttet);