From charlesreid1

(Created page with "==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 li...")
 
No edit summary
Line 12: Line 12:


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.
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=
{{DataStructuresFlag}}
[[Category:Java]]
[[Category:Python]]
[[Category:Arrays]]

Revision as of 21:49, 2 June 2017

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://charlesreid1.com:3000/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://charlesreid1.com:3000/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