simple stack and queue used DoublyCircularLinkedList
Project description
Welcome! stackNqueue
stackNqueue is simple packages provides stack and queue made up DoublyCircularLinkedList.
This packages includes Stack.py, Queue.py, DoublyCircularLinkedList.py
Stack.py and Queue.py inherit the DoublyCircularLinkedList class from DoublyCircularLinkedList.py
structure of packages
inital states
DoublyCircularLinkedList Methods
Method | works |
---|---|
append(x) | 리스트 끝에 x를 추가한다. |
getNode(i: int) | i번째 인덱스의 노드를 반환한다. |
printList() | 리스트를 출력한다. |
pop(i: int) | i번째 인덱스의 노드를 삭제하고 반환한다. 인자를 주지 않거나 -1을 줬을경우, 끝노드를 삭제하고 반환한다. |
insert(i: int, x) | i번째 인덱스에 item으로 x를 가진 노드를 삽입한다. |
Stack Methods
Stack클래스는 DoublyCircularLinkedList클래스를 상속받는다
Method | works |
---|---|
push(x) | x값을 가진 노드를 리스트 끝에 추가한다. |
pop() | 리스트의 끝 노드를 삭제하고 반환한다. |
top() | 리스트의 끝 노드를 반환한다 |
Queue Methods
Queue클래스는 DoublyCircularLinkedList클래스를 상속받는다
Method | works |
---|---|
enqueue(x) | x를 리스트의 첫번 째 front에 추가한다. |
dequeue() | rear노드 즉, 리스트의 끝 노드를 삭제하고 반환한다. |
rear() | 첫번째로 추가된 리스트의 끝 노드 rear의 값을 반환한다. |
Example
from stackNqueue.Stack import *
from stackNqueue.Queue import *
a = DoublyCircularLinkedList() # DoublyLinkedList 생성
a.append(1) # 1
a.insert(0, 3) # 3 -> 1
a.pop() # 3
a.pop(0) # []
a.printList() # print "there is no Item in List"
b = Stack() # Stack 생성
b.push(1) # 1
b.push(2) # 1 -> 2
b.push(3) # 1 -> 2 -> 3
b.printList() # print 1 -> 2 -> 3
print(b.pop()) # return 3
b.printList() # print 1 -> 2
print(b.top()) # print 2
c = Queue() # Queue 생성
c.enqueue(1) # 1
c.enqueue(2) # 2 -> 1
c.enqueue(3) # 3 -> 2 -> 1
print(c.dequeue()) # print 1
print(c.rear()) # print 2
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for stackNqueue-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f7fab8d7c58e48af10efabd983eadfff18acc6bf3a067fa93d58a3e306fc3d0 |
|
MD5 | 89b72e5819894ed40f458ccdb41de9ee |
|
BLAKE2b-256 | 900f80213707f226eb28dd95ae363b28878296de4d680d02bef8111f37609021 |