Simple implementation of data structures for python
Project description
fds
Simple implementaion of data structures (DS) for python
Content
- linked list
- doubly linked list
- sorted linked list
- stack
- queue
- priority queue
- utils // (package)
Content of utils
- node // single pointer node
- dnode // double pointer node
- pair
how to import utils
from fds.utils import *
pair = Pair()
or
import fds.utils
pair = utils.Pair()
Classes
- List // linked list
- DList // doubly linked list
- SList // sorted linked list
- Stack // stack
- Queue // queue
- PQueue // priority queue
API
List
Properties
- first(self) // TODO: return the data in the first node
- last(self) // TODO: return the data in the last node
Methodes
- insert(self, data, pos=0) // TODO: add node in the entered position (pos=0 => add in the begining)
- append(self, data) // TODO: add node in the end
- delete(self, data) // TODO: delete all nodes hav the entered data
- remove(self, pos=0) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node)
DList
Properties
- first // TODO: return the data in the first node
- last // TODO: return the data in the last node
Methodes
- add_begin(self, data) // TODO: add a node to the begin
- add_fin(self, data) // TODO: add a node to the fin
- delete(self, data) // TODO: delete all nodes hav the entered data
- remove(self, pos=0) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node)
SList
Properties
- first // TODO: return the data in the first node
- last // TODO: return the data in the last node
Methodes
- append(self, data) // TODO: add a node to the list in a sorted way
- delete(self, data) // TODO: delete all nodes hav the entered data
- remove(self, pos=0) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node)
Note
- the (reverse, sort, exchange) are not supported in this DS because they brake the rule of the Sorted Linked List
Stack
Properties
- top // TODO: return the data in the first node
Methodes
- push(self, data) // TODO: add a node to the top
- pop(self) // TODO: return and remove the node in the top
Queue
Properties
- front // TODO: return the data in the first node
- back // TODO: return the data in the last node
Methods
- enqueue(self, data) // TODO: add a node to the end
- dequeue(self) // TODO: return and remove the first element
PQueue
Properties
- front // TODO: return the data in the first node
- back // TODO: return the data in the last node
Methods
- enqueue(self, data) // TODO: add a node to the queue in a sorted way
- dequeue(self) // TODO: return and remove the first element
Methods for all DSs
- str(self) // USE: print([DS_name]) // TODO: display the DS
- len(self) // USE: len([DS_name]) // TODO: return the lenth of the DS
- empty(self) // TODO: return True if the DS is empty
- clear(self) // TODO: clear the DS
- find(self, data) // TODO: return the number of how many the entered data found in the DS
- reverse(self) // TODO: return the reverse of the DS
- sort(self) // TODO: sort the DS if its not sorted
- exchange(self, n) // TODO: circular permutation for n time
classmethods for all DSs
// USE: [DS] = [DS_type].method([DS1], [DS2])
// Examples:
>>> stck3 = Stack.merge(stck1, stck2)
>>> Stack.swap([DS1], [DS2])
the tow DS parameters must be from the same DS
- merge(cls, DS1, DS2) // TODO: return the merge of two DS in new DS
- swap(cls, DS1, DS2) // TODO: swap between DS1 and DS2 (DS1 will be DS2 and DS2 will be DS1)
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
py-fds-3.1.0.tar.gz
(6.7 kB
view details)
Built Distribution
py_fds-3.1.0-py3-none-any.whl
(14.5 kB
view details)
File details
Details for the file py-fds-3.1.0.tar.gz
.
File metadata
- Download URL: py-fds-3.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 948d0262e7a22157482ebaee6592fdc2c3bee9985382512e1ef0c84c4111b5a5 |
|
MD5 | 1067f4799fefe9ac7abb92c2435b5da2 |
|
BLAKE2b-256 | 45d851e1755fd356d6c74f6ad465829ebbc4b249f8c66a1500055baae186b011 |
File details
Details for the file py_fds-3.1.0-py3-none-any.whl
.
File metadata
- Download URL: py_fds-3.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e23fcf43c60ea4ec52c0e2a6b24d5c3c8d579922e8c3fd5abb0347ef41a5844 |
|
MD5 | e44b5716e9845264adca941c517bcb95 |
|
BLAKE2b-256 | 662a59e74dbe66ac9ad69fdf6c5531848ab8dbbe502eb92059385067fd169c8a |