# `gbp.rpm.linkedlist.LinkedList(collections.Iterable)` class documentation

Part of `gbp.rpm.linkedlist` (View In Hierarchy)

Doubly linked list

Method | __init__ | Undocumented
Method | __iter__ | Undocumented
Method | __len__ | Undocumented
Method | first | Get the first node of the list
Method | prepend | Insert to the beginning of list
Method | append | Insert to the end of list
Method | insert_before | Insert before a node
Method | insert_after | Insert after a node
Method | delete | Delete node

def __init__(self):
Undocumented
def __iter__(self):
Undocumented
def __len__(self):
Undocumented
@property
def first(self):

Get the first node of the list

def 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']

def 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']

def 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']

def 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']

def 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]
    []