From charlesreid1

PythonList class

The PythonList class is a data structure that uses a dynamically resized array to store data. This gives an object that works much like a Python-style list.

The code is in the Java CS repository on git.charlesreid1.com:

https://git.charlesreid1.com/cs/java/src/master/arrays/python-list/PythonList.java

Indeed, the corresponding Python implementation is the DynamicArray class, which is in the Python CS repository on git.charlesreid1.com:

https://git.charlesreid1.com/cs/python/src/master/arrays/DynamicArray.py

The way this data structure works is to use an array with some initial size (in this case, 10). When the array needs to be expanded, it is doubled in size. When it needs to be shrunk, the array will be cut in half each time it drops below 1/4 occupancy.


Flags