From 22b6529e853c982419c2cba94d1207ad18cbc575 Mon Sep 17 00:00:00 2001 From: Franklin Delehelle Date: Tue, 16 Jan 2024 22:20:00 +0100 Subject: [PATCH] fix: ArrayDeque semantics --- .../container/stacked/set/StackedSet.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/set/StackedSet.java b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/set/StackedSet.java index b3a844e7c9..28c1675774 100644 --- a/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/set/StackedSet.java +++ b/arithmetization/src/main/java/net/consensys/linea/zktracer/container/stacked/set/StackedSet.java @@ -42,16 +42,22 @@ public class StackedSet implements StackedContainer, @Override public void enter() { - this.sets.push(new HashSet<>()); + this.sets.addLast(new HashSet<>()); } @Override public void pop() { - Set set = this.sets.pop(); + Set set = this.sets.removeLast(); for (E e : set) { - Integer count = occurrences.get(e); - if (count > 0) occurrences.put(e, count - 1); - else throw new IllegalStateException("asymmetric element removal !"); + occurrences.computeIfPresent( + e, + (k, count) -> { + if (count > 0) { + return count - 1; + } else { + throw new IllegalStateException("asymmetric element removal !"); + } + }); } }