summaryrefslogtreecommitdiff
path: root/python/linked_list.py
blob: 8754e04e166f031bb5bce622e4a6910afd5a45eb (plain)
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
#!/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