summaryrefslogtreecommitdiff
path: root/python/linked_list.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/linked_list.py')
-rwxr-xr-xpython/linked_list.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/linked_list.py b/python/linked_list.py
new file mode 100755
index 0000000..8754e04
--- /dev/null
+++ b/python/linked_list.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python2
+
+
+class El():
+ def __init__(self, val=None, nxt=None):
+ self.val = val
+ self.nxt = nxt
+
+ def getNext(self):
+ return self.nxt
+
+ def getVal(self):
+ return self.val
+
+
+class Ll():
+ def __init__(self, first):
+ self.first = first
+
+ def iterv(self):
+ el = self.first
+ while True:
+ yield el.getVal()
+ el = el.getNext()
+ if not el: break
+
+a = Ll(El("first", El("second")))
+
+for i in a.iterv():
+ print i
+