We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3613556 commit 92f2c92Copy full SHA for 92f2c92
pydatastructs/linear_data_structures/arrays.py
@@ -380,10 +380,12 @@ def _modify(self, force=False):
380
below load factor.
381
"""
382
if force:
383
- i = self._size - 1
384
- while i >= 0 and self._data[i] is None:
385
- i -= 1
386
- self._last_pos_filled = i
+ left = 0
+ for i in range(self._size):
+ if self._data[i] is not None:
+ self._data[left], self._data[i] = self._data[i], self._data[left]
387
+ left += 1
388
+ self._last_pos_filled = left - 1
389
if (self._num/self._size < self._load_factor):
390
arr_new = OneDimensionalArray(self._dtype, 2*self._num + 1)
391
j = 0
0 commit comments