Skip to content

Commit 3613556

Browse files
Handle Edge Case in _last_pos_filled Calculation
1 parent ed88315 commit 3613556

File tree

1 file changed

+3
-3
lines changed
  • pydatastructs/linear_data_structures

1 file changed

+3
-3
lines changed

pydatastructs/linear_data_structures/arrays.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ def _modify(self, force=False):
380380
below load factor.
381381
"""
382382
if force:
383-
i = -1
384-
while self._data[i] is None:
383+
i = self._size - 1
384+
while i >= 0 and self._data[i] is None:
385385
i -= 1
386-
self._last_pos_filled = i%self._size
386+
self._last_pos_filled = i
387387
if (self._num/self._size < self._load_factor):
388388
arr_new = OneDimensionalArray(self._dtype, 2*self._num + 1)
389389
j = 0

0 commit comments

Comments
 (0)