- edited description
Inconsistent behaviour for TIntArrayList.clear
Issue #27
resolved
For TIntArrayList.clear a new smallish array is created:
public void clear() {
clear( DEFAULT_CAPACITY );
}
public void clear( int capacity ) {
_data = new int[ capacity ];
_pos = 0;
}
// this is what one would expect for clear:
public void reset() {
_pos = 0;
Arrays.fill( _data, no_entry_value );
}
For TIntIntHashMap.clear the expected behaviour is reseting the values:
public void clear() {
super.clear();
Arrays.fill( _set, 0, _set.length, no_entry_key );
Arrays.fill( _values, 0, _values.length, no_entry_value );
Arrays.fill( _states, 0, _states.length, FREE );
}
Why?
Comments (6)
-
reporter -
reporter - edited description
-
reporter - edited description
-
reporter - edited description
-
Merged in d01ab99
Change behavior of the clear() method to reset() used to do (reset data without reallocating the backing arrays) and remove the reset() and resetQuick() methods. Added clearQuick() method to do what resetQuick() did.
(NOTE: minor API break)
-
- changed status to resolved
- Log in to comment