public LightWeightResizableGSet(int initCapacity, float loadFactor) { if (initCapacity < 0) { throw new HadoopIllegalArgumentException("Illegal initial capacity: " + initCapacity); } if (loadFactor <= 0 || loadFactor > 1.0f) { throw new HadoopIllegalArgumentException("Illegal load factor: " + loadFactor); } this.capacity = actualArrayLength(initCapacity); this.hash_mask = capacity - 1; this.loadFactor = loadFactor; this.threshold = (int) (capacity * loadFactor); entries = new LinkedElement[capacity]; }
/** * Resize the internal table to given capacity. */ @SuppressWarnings("unchecked") protected void resize(int cap) { int newCapacity = actualArrayLength(cap); if (newCapacity == this.capacity) { return; } this.capacity = newCapacity; this.threshold = (int) (capacity * loadFactor); this.hash_mask = capacity - 1; LinkedElement[] oldEntries = entries; entries = new LinkedElement[capacity]; for (int i = 0; i < oldEntries.length; i++) { LinkedElement e = oldEntries[i]; while (e != null) { LinkedElement next = e.getNext(); int index = getIndex((E)e); e.setNext(entries[index]); entries[index] = e; e = next; } } }
public LightWeightResizableGSet(int initCapacity, float loadFactor) { if (initCapacity < 0) { throw new HadoopIllegalArgumentException("Illegal initial capacity: " + initCapacity); } if (loadFactor <= 0 || loadFactor > 1.0f) { throw new HadoopIllegalArgumentException("Illegal load factor: " + loadFactor); } this.capacity = actualArrayLength(initCapacity); this.hash_mask = capacity - 1; this.loadFactor = loadFactor; this.threshold = (int) (capacity * loadFactor); entries = new LinkedElement[capacity]; }
/** * Resize the internal table to given capacity. */ @SuppressWarnings("unchecked") protected void resize(int cap) { int newCapacity = actualArrayLength(cap); if (newCapacity == this.capacity) { return; } this.capacity = newCapacity; this.threshold = (int) (capacity * loadFactor); this.hash_mask = capacity - 1; LinkedElement[] oldEntries = entries; entries = new LinkedElement[capacity]; for (int i = 0; i < oldEntries.length; i++) { LinkedElement e = oldEntries[i]; while (e != null) { LinkedElement next = e.getNext(); int index = getIndex((E)e); e.setNext(entries[index]); entries[index] = e; e = next; } } }