pgm04_20.txt

来自「Data Structures And Algorithms With Obje」· 文本 代码 · 共 33 行

TXT
33
字号
## This file contains the Python code from Program 4.20 of# "Data Structures and Algorithms# with Object-Oriented Design Patterns in Python"# by Bruno R. Preiss.## Copyright (c) 2003 by Bruno R. Preiss, P.Eng.  All rights reserved.## http://www.brpreiss.com/books/opus7/programs/pgm04_20.txt#class LinkedList(object):    class Element(object):        def insertAfter(self, item):            self._next = LinkedList.Element(                self._list, item, self._next)            if self._list._tail is self:                self._list._tail = self._next        def insertBefore(self, item):            tmp = LinkedList.Element(self._list, item, self)            if self is self._list._head:                self._list._head = tmp            else:                prevPtr = self._list._head                while prevPtr is not None \                        and prevPtr._next is not self:                    prevPtr = prevPtr._next                prevPtr._next = tmp    # ...

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?