Skip to content

Commit

Permalink
Expose the allocateTable method as protected in primitive maps and set,
Browse files Browse the repository at this point in the history
resolves #787.

This will provide a way to dynamically restrict the growth of the backing arrays.

Signed-off-by: Anton Klaren <anton.klaren@neotechnology.com>
  • Loading branch information
klaren committed Jan 23, 2020
1 parent 6f463f1 commit 1406d5e
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ public class Object<name>HashMap\<K> implements MutableObject<name>Map\<K>, Exte
return false;
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.keys = new Object[sizeToAllocate];
this.values = new <type>[sizeToAllocate];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ public class Object<name>HashMapWithHashingStrategy\<K> implements MutableObject
return false;
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.keys = new Object[sizeToAllocate];
this.values = new <type>[sizeToAllocate];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public class <name>BooleanHashMap extends AbstractMutableBooleanValuesMap implem
return !isEmptyKey(key) && !isRemovedKey(key);
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.keys = new <type>[sizeToAllocate];
this.values = new BitSet(sizeToAllocate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,7 @@ public class <name>ObjectHashMap\<V> implements Mutable<name>ObjectMap\<V>, Exte
return spread & (this.keys.length - 1);
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.keys = new <type>[sizeToAllocate];
this.values = (V[]) new Object[sizeToAllocate];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ public class <name1><name2>HashMap extends AbstractMutable<name2>ValuesMap imple
return spread & (<if(sameTwoPrimitives)>(<endif>this.<keyArray>.length<if(sameTwoPrimitives)> \>> 1)<endif> - 1);
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.<keyArray> = new <type1>[sizeToAllocate<if(sameTwoPrimitives)> \<\< 1<endif>];
<if(!sameTwoPrimitives)>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ public class <name>HashSet extends Abstract<name>Set implements Mutable<name>Set
}
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.table = new <type>[sizeToAllocate];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ private void rehash(int newCapacity)
}
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.keys = new Object[sizeToAllocate];
this.values = new BitSet(sizeToAllocate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ private void rehash(int newCapacity)
}
}

private void allocateTable(int sizeToAllocate)
protected void allocateTable(int sizeToAllocate)
{
this.keys = new Object[sizeToAllocate];
this.values = new BitSet(sizeToAllocate);
Expand Down

0 comments on commit 1406d5e

Please sign in to comment.