1# Copyright (c) 2014-2021 Cedric Bellegarde <cedric.bellegarde@adishatz.org>
2# This program is free software: you can redistribute it and/or modify
3# it under the terms of the GNU General Public License as published by
4# the Free Software Foundation, either version 3 of the License, or
5# (at your option) any later version.
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU General Public License for more details.
10# You should have received a copy of the GNU General Public License
11# along with this program. If not, see <http://www.gnu.org/licenses/>.
12
13
14class LinkedList:
15    """
16        Double linked list
17    """
18
19    def __init__(self, value=None, next=None, prev=None):
20        """
21            Init list
22            @param value as int
23        """
24        self.__value = value
25        self.__next = next
26        self.__prev = prev
27
28    def set_next(self, next):
29        """
30            Set next
31            @param next as linked list
32        """
33        self.__next = next
34
35    def set_prev(self, prev):
36        """
37            Set prev
38            @param prev as linked list
39        """
40        self.__prev = prev
41
42    @property
43    def has_next(self):
44        """
45            True if list has next
46            @return bool
47        """
48        return self.__next is not None
49
50    @property
51    def has_prev(self):
52        """
53            True if list has prev
54            @return bool
55        """
56        return self.__prev is not None
57
58    @property
59    def prev(self):
60        """
61            Return prev
62            @return prev as LinkedList
63        """
64        return self.__prev
65
66    @property
67    def next(self):
68        """
69            Return next
70            @return next as LinkedList
71        """
72        return self.__next
73
74    @property
75    def value(self):
76        """
77            Get value
78            @return value as int
79        """
80        return self.__value
81