Browse Source

queque python

pull/10/head
dafinoer 2 years ago
parent
commit
f463f8ba31
2 changed files with 47 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +44
    -0
      sorting/queque.py

+ 3
- 0
.gitignore View File

@@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

#texteditor
.vscode

+ 44
- 0
sorting/queque.py View File

@@ -0,0 +1,44 @@
class Queque:

def __init__(self):
self.queque = []


def enqueue(self, data):
if data not in self.queque:
self.queque.append(data)
return True
return False

def dequeue(self):
if len(self.queque) > 0:

return self.queque.pop(0)
return ('Queque empty')

def sizeQueque(self):
return len(self.queque)
def printQueque(self):
return self.queque


if __name__ == '__main__':
myqueque = Queque()

data = myqueque.enqueue(5)
data = myqueque.enqueue(6)
data = myqueque.enqueue(7)
data = myqueque.enqueue(10)

print(myqueque.sizeQueque())
print(myqueque.printQueque())


dequeue = myqueque.dequeue() # delete 5
dequeue = myqueque.dequeue() # delete 6


print(myqueque.printQueque())
print(myqueque.sizeQueque())

Loading…
Cancel
Save