@Test public void resizeOnlyIfNecessary() { char[] keys = new char[1]; int size = 0; MappeableContainer[] values = new MappeableContainer[1]; MutableRoaringArray array = new MutableRoaringArray(keys, values, size); array.extendArray(1); assertSame(keys, array.keys, "Keys were not reallocated"); }
protected void extendArray(int k) { if (this.size + k > this.keys.length) { int newCapacity; if (this.keys.length < 1024) { newCapacity = 2 * (this.size + k); } else { newCapacity = 5 * (this.size + k) / 4; } this.keys = Arrays.copyOf(this.keys, newCapacity); this.values = Arrays.copyOf(this.values, newCapacity); } }
MutableRoaringArray implements Cloneable, Externalizable, PointableRoaringArray,
        AppendableStorage<MappeableContainer> { protected void extendArray(int k) { if (this.size + k > this.keys.length) { int newCapacity; if (this.keys.length < 1024) { newCapacity = 2 * (this.size + k); } else { newCapacity = 5 * (this.size + k) / 4; } this.keys = Arrays.copyOf(this.keys, newCapacity); this.values = Arrays.copyOf(this.values, newCapacity); } } }
MutableRoaringArray implements Cloneable, Externalizable, PointableRoaringArray,
        AppendableStorage<MappeableContainer> { protected void extendArray(int k) { if (this.size + k > this.keys.length) { int newCapacity; if (this.keys.length < 1024) { newCapacity = 2 * (this.size + k); } else { newCapacity = 5 * (this.size + k) / 4; } this.keys = Arrays.copyOf(this.keys, newCapacity); this.values = Arrays.copyOf(this.values, newCapacity); } } protected  MutableRoaringArray();  MutableRoaringArray(int initialCapacity);   MutableRoaringArray(char[] keys, MappeableContainer[] values, int size); }
MutableRoaringArray implements Cloneable, Externalizable, PointableRoaringArray,
        AppendableStorage<MappeableContainer> { protected void extendArray(int k) { if (this.size + k > this.keys.length) { int newCapacity; if (this.keys.length < 1024) { newCapacity = 2 * (this.size + k); } else { newCapacity = 5 * (this.size + k) / 4; } this.keys = Arrays.copyOf(this.keys, newCapacity); this.values = Arrays.copyOf(this.values, newCapacity); } } protected  MutableRoaringArray();  MutableRoaringArray(int initialCapacity);   MutableRoaringArray(char[] keys, MappeableContainer[] values, int size); @Override int advanceUntil(char x, int pos); @Override void append(char key, MappeableContainer value); void trim(); @Override MutableRoaringArray clone(); void deserialize(DataInput in); void deserialize(ByteBuffer bbf); @Override int getCardinality(int i); @Override int getContainerIndex(char x); @Override MappeableContainer getContainerAtIndex(int i); @Override MappeableContainerPointer getContainerPointer(); @Override MappeableContainerPointer getContainerPointer(final int startIndex); @Override int getIndex(char x); @Override char getKeyAtIndex(int i); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean hasRunCompression(); @Override void readExternal(ObjectInput in); @Override void serialize(DataOutput out); @Override void serialize(ByteBuffer buffer); @Override int serializedSizeInBytes(); @Override int size(); @Override void writeExternal(ObjectOutput out); @Override boolean containsForContainerAtIndex(int i, char x); @Override int first(); @Override int last(); }
MutableRoaringArray implements Cloneable, Externalizable, PointableRoaringArray,
        AppendableStorage<MappeableContainer> { protected void extendArray(int k) { if (this.size + k > this.keys.length) { int newCapacity; if (this.keys.length < 1024) { newCapacity = 2 * (this.size + k); } else { newCapacity = 5 * (this.size + k) / 4; } this.keys = Arrays.copyOf(this.keys, newCapacity); this.values = Arrays.copyOf(this.values, newCapacity); } } protected  MutableRoaringArray();  MutableRoaringArray(int initialCapacity);   MutableRoaringArray(char[] keys, MappeableContainer[] values, int size); @Override int advanceUntil(char x, int pos); @Override void append(char key, MappeableContainer value); void trim(); @Override MutableRoaringArray clone(); void deserialize(DataInput in); void deserialize(ByteBuffer bbf); @Override int getCardinality(int i); @Override int getContainerIndex(char x); @Override MappeableContainer getContainerAtIndex(int i); @Override MappeableContainerPointer getContainerPointer(); @Override MappeableContainerPointer getContainerPointer(final int startIndex); @Override int getIndex(char x); @Override char getKeyAtIndex(int i); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean hasRunCompression(); @Override void readExternal(ObjectInput in); @Override void serialize(DataOutput out); @Override void serialize(ByteBuffer buffer); @Override int serializedSizeInBytes(); @Override int size(); @Override void writeExternal(ObjectOutput out); @Override boolean containsForContainerAtIndex(int i, char x); @Override int first(); @Override int last();  }