Package gbp :: Package rpm :: Module linkedlist :: Class LinkedList

[hide private]
[frames] | no frames]

# Class LinkedList

          object --+
                   |
    _abcoll.Iterable --+
                       |
                      LinkedList

Doubly linked list

Nested Classes | [hide private]

Inherited from `_abcoll.Iterable`: `__metaclass__`

Instance Methods | [hide private]

__init__(self) x.__init__(...) initializes x; see help(type(x)) for signature |

__iter__(self) |

__len__(self) |

prepend(self, data) Insert to the beginning of list |

append(self, data) Insert to the end of list |

insert_before(self, node, data=`'````'`) Insert before a node |

insert_after(self, node, data=`'````'`) Insert after a node |

delete(self, node) Delete node |

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`

Class Methods | [hide private]

Inherited from `_abcoll.Iterable`: `__subclasshook__`

Class Variables | [hide private]

| __abstractmethods__ = ``frozenset([``])``
| _abc_negative_cache = `<_weakrefset.WeakSet object>`
| _abc_negative_cache_version = `21`
| _abc_registry = `<_weakrefset.WeakSet object>`
Inherited from `_abcoll.Iterable` (private): `_abc_cache`

Properties | [hide private]

| first Get the first node of the list
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self)
(Constructor)

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
  (inherited documentation)

### __iter__(self)

Overrides: _abcoll.Iterable.__iter__

### prepend(self, data)

Insert to the beginning of list

    >>> list = LinkedList()
    >>> [str(data) for data in list]
    []
    >>> node = list.prepend("foo")
    >>> len(list)
    1
    >>> node = list.prepend("bar")
    >>> [str(data) for data in list]
    ['bar', 'foo']

### append(self, data)

Insert to the end of list

    >>> list = LinkedList()
    >>> node = list.append('foo')
    >>> len(list)
    1
    >>> node = list.append('bar')
    >>> [str(data) for data in list]
    ['foo', 'bar']

### insert_before(self, node, data=`'````'`)

Insert before a node

    >>> list = LinkedList()
    >>> node1 = list.append('foo')
    >>> node2 = list.insert_before(node1, 'bar')
    >>> node3 = list.insert_before(node1, 'baz')
    >>> [str(data) for data in list]
    ['bar', 'baz', 'foo']

### insert_after(self, node, data=`'````'`)

Insert after a node

    >>> list = LinkedList()
    >>> node1 = list.prepend('foo')
    >>> node2 = list.insert_after(node1, 'bar')
    >>> node3 = list.insert_after(node1, 'baz')
    >>> [str(data) for data in list]
    ['foo', 'baz', 'bar']

### delete(self, node)

Delete node

    >>> list = LinkedList()
    >>> node1 = list.prepend('foo')
    >>> node2 = list.insert_after(node1, 'bar')
    >>> node3 = list.insert_before(node2, 'baz')
    >>> [str(data) for data in list]
    ['foo', 'baz', 'bar']
    >>> str(list.delete(node3))
    'foo'
    >>> [str(data) for data in list]
    ['foo', 'bar']
    >>> print("%s" % node3)
    <BLANKLINE>
    >>> str(list.delete(node1))
    'bar'
    >>> [str(data) for data in list]
    ['bar']
    >>> list.delete(node2)
    >>> [str(data) for data in list]
    []

Property Details | [hide private]

### first

Get the first node of the list

Get Method:
  unreachable.first(self) - Get the first node of the list