### 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
Useful if used directly as an improved version of a Python List or in a "has-a" relationship when implementing other data structures.
- O(1) pushes and pops either end.
- O(1) indexing
- does not support slicing
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.6.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 189863d8f9011d6cd5eb8fd5f65bc884070daf8fad3331e73506b35379c3eafa |
|
MD5 | 190c4b134523c3de7792977c2c5fcad3 |
|
BLAKE2b-256 | 9aecfcac806f1da287e3131d13f14b80fa9339aca9c5bef4a983e378c88ed5b3 |
Close
Hashes for grscheller_circular_array-3.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08656848d0a3752f2568f124374053fd4d44961f1c7739595e1bd68b89d0332 |
|
MD5 | e26901ed3d0c1bfc3a50035495279780 |
|
BLAKE2b-256 | 7b5a1076cd6351de54a085fd40a2c75a371228c90ced29c015705d22ea1b5ec6 |