File: ListNode.py

package info (click to toggle)
forg 0.5.1-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 532 kB
  • ctags: 738
  • sloc: python: 5,407; xml: 85; makefile: 63
file content (62 lines) | stat: -rw-r--r-- 1,973 bytes parent folder | download | duplicates (5)
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
# ListNode.py
# $Id: ListNode.py,v 1.6 2001/07/11 22:43:09 s2mdalle Exp $
# Nodes to be placed in List objects.
# Subclass freely!  Life is short!
#
# Written by David Allen <mda@idatar.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#############################################################################

class ListNode:
    def __init__(self, data=None, next=None, prev=None):
        self.next = next
        self.prev = prev
        self.data = data
        return None
    
    def __str__(self):
        return self.data.__str__
    
    def __repr__(self):
        return self.data.__repr__
    
    def getNext(self):
        """Return the next item in the list"""
        return self.next
    
    def getPrev(self):
        """Return the previous item in the list"""
        return self.prev
    
    def getData(self):
        """Return the data inside this object Node"""
        return self.data
    
    def setNext(self, newnext):
        """Set the next item in the list"""
        self.next = newnext
        return self.next
    
    def setPrev(self, newprev):
        """Set the previous item in the list"""
        self.prev = newprev
        return self.prev
    
    def setData(self, data):
        """Set the data inside the object."""
        self.data = data
        return self.data