/
physicalIndexToValueMap.js
41 lines (36 loc) · 1.08 KB
/
physicalIndexToValueMap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import IndexMap from './indexMap';
import { getListWithRemovedItems, getListWithInsertedItems } from './utils/physicallyIndexed';
/**
* Map for storing mappings from an physical index to a value.
*
* Does not update stored values on remove/add row or column action.
*/
class PhysicalIndexToValueMap extends IndexMap {
/**
* Add values to list and reorganize.
*
* @private
* @param {number} insertionIndex Position inside the list.
* @param {Array} insertedIndexes List of inserted indexes.
*/
insert(insertionIndex, insertedIndexes) {
this.indexedValues = getListWithInsertedItems(
this.indexedValues,
insertionIndex,
insertedIndexes,
this.initValueOrFn
);
super.insert(insertionIndex, insertedIndexes);
}
/**
* Remove values from the list and reorganize.
*
* @private
* @param {Array} removedIndexes List of removed indexes.
*/
remove(removedIndexes) {
this.indexedValues = getListWithRemovedItems(this.indexedValues, removedIndexes);
super.remove(removedIndexes);
}
}
export default PhysicalIndexToValueMap;