From bc48f2f0a310077074f4e65426e685ca5760f727 Mon Sep 17 00:00:00 2001 From: Radek Oslejsek <oslejsek@fi.muni.cz> Date: Thu, 20 May 2021 07:54:34 +0200 Subject: [PATCH] putIfAbsent replaced with computeIfAbsent --- .../visitors/kdtree/KdTreeApproxDistanceToTriangles.java | 4 ++-- .../analyst/visitors/kdtree/KdTreeDistanceToVertices.java | 4 ++-- .../analyst/visitors/mesh/MeshApproxDistanceToTriangles.java | 4 ++-- .../analyst/visitors/mesh/MeshDistanceToTriangles.java | 4 ++-- .../analyst/visitors/mesh/MeshDistanceToVertices.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeApproxDistanceToTriangles.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeApproxDistanceToTriangles.java index dad64d39..a1539dd4 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeApproxDistanceToTriangles.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeApproxDistanceToTriangles.java @@ -94,8 +94,8 @@ public class KdTreeApproxDistanceToTriangles extends KdTreeVisitor implements Di distance = dist; nearestPoints.clear(); } - nearestPoints.putIfAbsent(facet, new ArrayList<>()); - nearestPoints.get(facet).add(projection); + nearestPoints.computeIfAbsent(facet, meshFacet -> new ArrayList<>()) + .add(projection); } } } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeDistanceToVertices.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeDistanceToVertices.java index c421c48e..2f8594cb 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeDistanceToVertices.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/kdtree/KdTreeDistanceToVertices.java @@ -76,8 +76,8 @@ public class KdTreeDistanceToVertices extends KdTreeVisitor implements DistanceW for (Entry<MeshFacet, Integer> entry: node.getFacets().entrySet()) { MeshFacet facet = entry.getKey(); MeshPoint point = facet.getVertex(entry.getValue()); - nearestPoints.putIfAbsent(facet, new ArrayList<>()); - nearestPoints.get(facet).add(point.getPosition()); + nearestPoints.computeIfAbsent(facet, meshFacet -> new ArrayList<>()) + .add(point.getPosition()); } } } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshApproxDistanceToTriangles.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshApproxDistanceToTriangles.java index 343d9d5d..6d7fa32e 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshApproxDistanceToTriangles.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshApproxDistanceToTriangles.java @@ -101,8 +101,8 @@ public class MeshApproxDistanceToTriangles extends MeshVisitor implements Distan distance = dist; nearestPoints.clear(); } - nearestPoints.putIfAbsent(facet, new ArrayList<>()); - nearestPoints.get(facet).add(projection); + nearestPoints.computeIfAbsent(facet, meshFacet -> new ArrayList<>()) + .add(projection); } } } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToTriangles.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToTriangles.java index e806c298..fa54f1db 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToTriangles.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToTriangles.java @@ -65,8 +65,8 @@ public class MeshDistanceToTriangles extends MeshVisitor implements DistanceWith distance = dist; nearestPoints.clear(); } - nearestPoints.putIfAbsent(facet, new ArrayList<>()); - nearestPoints.get(facet).add(projection); + nearestPoints.computeIfAbsent(facet, meshFacet -> new ArrayList<>()) + .add(projection); } } } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToVertices.java b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToVertices.java index 9520075a..cb4f174b 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToVertices.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/MeshDistanceToVertices.java @@ -67,8 +67,8 @@ public class MeshDistanceToVertices extends MeshVisitor implements DistanceWithN distance = dist; nearestPoints.clear(); } - nearestPoints.putIfAbsent(facet, new ArrayList<>()); - nearestPoints.get(facet).add(pointOnSurface); + nearestPoints.computeIfAbsent(facet, meshFacet -> new ArrayList<>()) + .add(pointOnSurface); } } } -- GitLab