### Circular Array
Project description
Python Circular Array Implementation
Python module implementing an indexable, double sided, auto-resizing queue data structure.
- Repositories
- grscheller.circular-array project on PyPI
- Source code on GitHub
- Detailed documentation
- Detailed API documentation on GH-Pages
Overview
O(1) indexing and O(1) pushes and pops either end. Useful if used directly as an improved version of a Python List and in the implementation of other data structures in a "has-a" relationship.
Usage
from grscheller.circular_array.ca import CA
ca = CA(1, 2, 3)
assert ca.popL() == 1
assert ca.popR() == 3
ca.pushR(42, 0)
ca.pushL(0, 1)
assert repr(ca) == 'CA(1, 0, 2, 42, 0)'
assert str(ca) == '(|1, 0, 2, 42, 0|)'
ca = CA(*range(1,11))
assert repr(ca) == 'CA(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)'
assert str(ca) == '(|1, 2, 3, 4, 5, 6, 7, 8, 9, 10|)'
assert len(ca) == 10
tup3 = ca.popLT(3)
tup4 = ca.popRT(4)
assert tup3 == (1, 2, 3)
assert tup4 == (10, 9, 8, 7)
assert ca == CA(4, 5, 6)
four, *rest = ca.popFT(1000)
assert four == 4
assert rest == [5, 6]
assert len(ca) == 0
ca = CA(1, 2, 3)
assert ca.popLD(42) == 1
assert ca.popRD(42) == 3
assert ca.popLD(42) == 2
assert ca.popRD(42) == 42
assert ca.popLD(42) == 42
assert len(ca) == 0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for grscheller_circular_array-3.4.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fcde637c0cf8a459cf6b5cc9b321b67ba0bcdf293025a68920d6d8e407a7633 |
|
MD5 | 2a317273def83ab62e8411aa435e2950 |
|
BLAKE2b-256 | bf13782a24767e1b12d6925668f1107f3a724d304f9a372c97a80fbcb8a58781 |
Close
Hashes for grscheller_circular_array-3.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fac0bedf692d76210d42ea5a7d4d767e6a874bf15832a9500bc840b92b1c91b8 |
|
MD5 | 38ef9168983d08c30dcfa3ae7c639c0b |
|
BLAKE2b-256 | deb6b6bd8199dde5600f0ca39fbc054c88e8eff5759a23ff9c2e182681237d35 |