franz1981 commented on a change in pull request #2548: ARTEMIS-2118 Enhanced 
Message Groups Support
URL: https://github.com/apache/activemq-artemis/pull/2548#discussion_r256599873
 
 

 ##########
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/IntHashMap.java
 ##########
 @@ -0,0 +1,878 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.utils.collections;
+
+import java.io.Serializable;
+import java.util.AbstractCollection;
+import java.util.AbstractSet;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.function.IntFunction;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * {@link java.util.Map} implementation specialised for int keys using open 
addressing and
+ * linear probing for cache efficient access.
+ *
+ * @param <V> type of values stored in the {@link java.util.Map}
+ */
+public class IntHashMap<V> implements Map<Integer, V>, Serializable {
+   /**
+    * Default load factor to be used in open addressing hashed data structures.
+    */
+   static final float DEFAULT_LOAD_FACTOR = 0.55f;
+   static final int MIN_CAPACITY = 8;
+
+   private final float loadFactor;
+   private int resizeThreshold;
+   private int size;
+   private final boolean shouldAvoidAllocation;
+
+   private int[] keys;
+   private Object[] values;
+
+   private ValueCollection valueCollection;
+   private KeySet keySet;
+   private EntrySet entrySet;
+
+   public IntHashMap() {
+      this(MIN_CAPACITY, DEFAULT_LOAD_FACTOR, true);
+   }
+
+   public IntHashMap(
+      final int initialCapacity,
+      final float loadFactor) {
+      this(initialCapacity, loadFactor, true);
+   }
+
+   /**
+    * Construct a new map allowing a configuration for initial capacity and 
load factor.
+    * @param initialCapacity      for the backing array
+    * @param loadFactor         limit for resizing on puts
+    * @param shouldAvoidAllocation should allocation be avoided by caching 
iterators and map entries.
+    */
+   public IntHashMap(
 
 Review comment:
   If it is taken from agrona I would reference it somehow to both give proper 
credits and track eventual issues on it...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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