MCPcopy Create free account
hub / github.com/ReadyTalk/avian / resize

Method resize

classpath/java/util/HashMap.java:68–90  ·  view source on GitHub ↗
(int capacity)

Source from the content-addressed store, hash-verified

66 }
67
68 private void resize(int capacity) {
69 Cell<K, V>[] newArray = null;
70 if (capacity != 0) {
71 capacity = Data.nextPowerOfTwo(capacity);
72 if (array != null && array.length == capacity) {
73 return;
74 }
75
76 newArray = new Cell[capacity];
77 if (array != null) {
78 for (int i = 0; i < array.length; ++i) {
79 Cell<K, V> next;
80 for (Cell<K, V> c = array[i]; c != null; c = next) {
81 next = c.next();
82 int index = c.hashCode() & (capacity - 1);
83 c.setNext(newArray[index]);
84 newArray[index] = c;
85 }
86 }
87 }
88 }
89 array = newArray;
90 }
91
92 protected Cell<K, V> find(Object key) {
93 if (array != null) {

Callers 2

growMethod · 0.95
shrinkMethod · 0.95

Calls 4

nextPowerOfTwoMethod · 0.95
nextMethod · 0.65
hashCodeMethod · 0.65
setNextMethod · 0.65

Tested by

no test coverage detected