forked from vipinkjonwal/SV-Media-Player-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoublyLinkedList.py
More file actions
112 lines (95 loc) · 2.98 KB
/
doublyLinkedList.py
File metadata and controls
112 lines (95 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
'''
Program : Doubly Linked list Class
Author(s) : 1. Smrity Chaudhary
2. Vipin Kumar
'''
# Import necessary libraries.
from os import listdir
from os.path import isfile,join
# -----------------------------------------------------------------------------
# Class Definition
class Node:
'''
Node: Node class.
'''
def __init__(self,data):
'''
Objective: To initialize data members of object Node
Input Parameters:
self (implicit parameter) - object of type Node
data - int
Return Value: None
'''
self.data = data
self.next = None
self.prev = None
class Doublylinkedlist:
'''
DoublyLinkedList Class Implementation.
'''
def __init__(self):
'''
Objective: To initialize data members of object DoublyLinkedList
Input Parameters:
self (implicit parameter) - object of type MyDate
Return Value: None
'''
self.head = None
def insert(self,newData):
'''
Objective: To insert data at end into doubly linked list.
Input Parameters:
self (implicit parameter) - object of type MyDate
newData - string type, path for song.
Return Value: None
'''
newNode = Node(newData)
if self.head is None:
self.head = newNode
newNode.next = self.head
newNode.prev = self.head
return
temp = self.head
while(temp.next is not self.head):
temp = temp.next
newNode.prev = temp
temp.next = newNode
self.head.prev = newNode
newNode.next = self.head
def display(self):
'''
Objective: To display the contents of linked list.
Input Parameters:
self (implicit parameter) - object of type MyDate
Return Value: None
'''
temp = self.head
while(temp is not self.head.prev):
print(temp.data," ")
temp = temp.next
print(self.head.prev.data)
def getNext(self):
'''
Objective: Get next value from linked list.
Input Parameters:
self (implicit parameter) - object of type MyDate
Return Value: Value of head.next.
'''
self.head = self.head.next
return self.head.data
def getPrev(self):
'''
Objective: Get previous value from linked list.
Input Parameters:
self (implicit parameter) - object of type MyDate
Return Value: Value of head.prev.
'''
self.head = self.head.prev
return self.head.data
def getFileName(self,path):
files = [f for f in listdir(path) if isfile(join(path,f))]
mp3Files = []
for i in files:
if '.mp3' in i:
mp3Files.append(i)
return mp3Files