codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
202 stars 270 forks source link

BUG: DynamicOneDimensionalArray's size is not updated properly #557

Open Kishan-Ved opened 6 months ago

Kishan-Ved commented 6 months ago

Description of the problem

BUG: DynamicOneDimensionalArray's size is not updated properly

Example of the problem

def test_DynamicOneDimensionalArray3():
    DODA = DynamicOneDimensionalArray
    A = DODA(int, 1)
    A.delete(1)
    print(A._size)
    print(str(A))
    A.append(2)
    print(str(A))
    print(A.size)
    A.append(3)
    print(str(A))
    print(A.size)

Output:

1
[]
['2']
1
['2', '3']
3

The final size should be 2, but it is 3.

czgdp1807 commented 6 months ago

What's the output given by len(A)?

Kishan-Ved commented 6 months ago

It is the same as A.size for all the 3 cases in the code above.

czgdp1807 commented 6 months ago

Actually size is correct. len(A) should give 2 in the end. Also check the references in the DODA docs.