StefanRRichter commented on a change in pull request #8361: 
[FLINK-12434][network] Replace listeners with CompletableFuture in InputGates
URL: https://github.com/apache/flink/pull/8361#discussion_r282052964
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/util/SetArrayDeque.java
 ##########
 @@ -16,20 +16,38 @@
  * limitations under the License.
  */
 
-package org.apache.flink.runtime.io.network.partition.consumer;
+package org.apache.flink.runtime.util;
+
+import java.util.ArrayDeque;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
- * Listener interface implemented by consumers of {@link InputGate} instances
- * that want to be notified of availability of buffer or event instances.
+ * Wrapper of {@link ArrayDeque} with quick {@link HashSet}'s based {@link 
#contains(Object)} method.
  */
-public interface InputGateListener {
+public class SetArrayDeque<T> {
+       private final ArrayDeque<T> deque = new ArrayDeque<>();
+       private final Set<T> set = new HashSet<>();
+
+       public boolean add(T element) {
+               return deque.add(element) || set.add(element);
 
 Review comment:
   This looks wrong, should probably be `set.add(element) && 
deque.add(element)`? So maybe this class should still have a unit test :-) 
Besides, I wonder if this functionality could not also be provided by 
`LinkedHashMap` ... if only it had a more efficient `removeOldest` method not 
involving iterators.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to