/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified capacity * and load factor. * * @param capacity * the initial capacity of this map. * @param loadFactor * the initial load factor. * @throws IllegalArgumentException * if the capacity is less than zero or the load factor is less * or equal to zero. */ public WeakHashMap(int capacity, float loadFactor) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } if (loadFactor <= 0) { throw new IllegalArgumentException("loadFactor <= 0: " + loadFactor); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); this.loadFactor = (int) (loadFactor * 10000); computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified * capacity. * * @param capacity * the initial capacity of this map. * @throws IllegalArgumentException * if the capacity is less than zero. */ public WeakHashMap(int capacity) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); loadFactor = 7500; // Default load factor of 0.75 computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
private void rehash() { int length = elementData.length * 2; if (length == 0) { length = 1; } Entry<K, V>[] newData = newEntryArray(length); for (int i = 0; i < elementData.length; i++) { Entry<K, V> entry = elementData[i]; while (entry != null) { int index = entry.isNull ? 0 : (entry.hash & 0x7FFFFFFF) % length; Entry<K, V> next = entry.next; entry.next = newData[index]; newData[index] = entry; entry = next; } } elementData = newData; computeMaxSize(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified capacity * and load factor. * * @param capacity * the initial capacity of this map. * @param loadFactor * the initial load factor. * @throws IllegalArgumentException * if the capacity is less than zero or the load factor is less * or equal to zero. */ public WeakHashMap(int capacity, float loadFactor) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } if (loadFactor <= 0) { throw new IllegalArgumentException("loadFactor <= 0: " + loadFactor); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); this.loadFactor = (int) (loadFactor * 10000); computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified capacity * and load factor. * * @param capacity * the initial capacity of this map. * @param loadFactor * the initial load factor. * @throws IllegalArgumentException * if the capacity is less than zero or the load factor is less * or equal to zero. */ public WeakHashMap(int capacity, float loadFactor) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } if (loadFactor <= 0) { throw new IllegalArgumentException("loadFactor <= 0: " + loadFactor); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); this.loadFactor = (int) (loadFactor * 10000); computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }
/** * Constructs a new {@code WeakHashMap} instance with the specified capacity * and load factor. * * @param capacity * the initial capacity of this map. * @param loadFactor * the initial load factor. * @throws IllegalArgumentException * if the capacity is less than zero or the load factor is less * or equal to zero. */ public WeakHashMap(int capacity, float loadFactor) { if (capacity < 0) { throw new IllegalArgumentException("capacity < 0: " + capacity); } if (loadFactor <= 0) { throw new IllegalArgumentException("loadFactor <= 0: " + loadFactor); } elementCount = 0; elementData = newEntryArray(capacity == 0 ? 1 : capacity); this.loadFactor = (int) (loadFactor * 10000); computeMaxSize(); referenceQueue = new ReferenceQueue<K>(); }