private void ensureCapacity(int size) { if (size > this.maxSize) { size = (int) (size / this.loadFactor) + 1; int capacity = Integer.highestOneBit(size); if (size != capacity) { capacity <<= 1; } this.rehash(capacity); } }
private void ensureCapacity(int size) { if (size > this.maxSize) { size = (int) (size / this.loadFactor) + 1; int capacity = Integer.highestOneBit(size); if (size != capacity) { capacity <<= 1; } this.rehash(capacity); } }
@Override public boolean add(T key) { int index = this.index(key); Object cur = this.table[index]; if (cur == null) { this.table[index] = UnifiedSet.toSentinelIfNull(key); if (++this.occupied > this.maxSize) { this.rehash(); } return true; } if (cur instanceof ChainedBucket || !this.nonNullTableObjectEquals(cur, key)) { return this.chainedAdd(key, index); } return false; }
@Override public boolean add(T key) { int index = this.index(key); Object cur = this.table[index]; if (cur == null) { this.table[index] = UnifiedSet.toSentinelIfNull(key); if (++this.occupied > this.maxSize) { this.rehash(); } return true; } if (cur instanceof ChainedBucket || !this.nonNullTableObjectEquals(cur, key)) { return this.chainedAdd(key, index); } return false; }
@Override public T put(T key) { int index = this.index(key); Object cur = this.table[index]; if (cur == null) { this.table[index] = UnifiedSet.toSentinelIfNull(key); if (++this.occupied > this.maxSize) { this.rehash(); } return key; } if (cur instanceof ChainedBucket || !this.nonNullTableObjectEquals(cur, key)) { return this.chainedPut(key, index); } return this.nonSentinel(cur); }
@Override public T put(T key) { int index = this.index(key); Object cur = this.table[index]; if (cur == null) { this.table[index] = UnifiedSet.toSentinelIfNull(key); if (++this.occupied > this.maxSize) { this.rehash(); } return key; } if (cur instanceof ChainedBucket || !this.nonNullTableObjectEquals(cur, key)) { return this.chainedPut(key, index); } return this.nonSentinel(cur); }
private void ensureCapacity(int size) { if (size > this.maxSize) { size = (int) (size / this.loadFactor) + 1; int capacity = Integer.highestOneBit(size); if (size != capacity) { capacity <<= 1; } this.rehash(capacity); } }
@Override public boolean add(T key) { int index = this.index(key); Object cur = this.table[index]; if (cur == null) { this.table[index] = UnifiedSet.toSentinelIfNull(key); if (++this.occupied > this.maxSize) { this.rehash(); } return true; } if (cur instanceof ChainedBucket || !this.nonNullTableObjectEquals(cur, key)) { return this.chainedAdd(key, index); } return false; }
@Override public T put(T key) { int index = this.index(key); Object cur = this.table[index]; if (cur == null) { this.table[index] = UnifiedSet.toSentinelIfNull(key); if (++this.occupied > this.maxSize) { this.rehash(); } return key; } if (cur instanceof ChainedBucket || !this.nonNullTableObjectEquals(cur, key)) { return this.chainedPut(key, index); } return this.nonSentinel(cur); }