coinor.blimpy.LinkedList'.LinkedList

Package coinor :: Package blimpy :: Module LinkedList' :: Class LinkedList |
[hide private]
[frames] | no frames]

# Class LinkedList

source code

    implementation of link list data structure.
    The behavior is designed to be the same as a Python list.
    For efficiency when using the list as a stack, the list is stored
    such that the last item in the list is the head node. Thus, the
    append, push, pop, and most other methods are efficient, but
    forward iteration is not. Reverse iteration is efficient, however,
    pre:  Node is the head node of a linked list and length is the length of
          that list
    post: creates a LinkedList type object

Instance Methods | [hide private]
__add__(self, otherLinkedList) | source code
__contains__(self, item) sequential search method pre: self, item to be searched post: True if list contains the item, False otherwise | source code
__delitem__(self, position) | source code
__getitem__(self, index) replace built-in class method that returns the item for the given... | source code
__init__(self, Node=None, length=0) constructor method of the class pre: self | source code
__iter__(self) built-in class method, makes LinkedList objects iterable pre: self post: self.head, first Node on the list | source code
__len__(self) class method that returns the number of items in the list pre: self post: returns number of items in the list | source code
__repr__(self) repr(x) | source code
__reversed__(self) built-in class method, makes LinkedList objects reverse iterable pre: self post: self.head, first Node on the list | source code
append(self, item) class method that appends the given item at the end of the list pre: self, item | source code
backward(self) | source code
count(self, item) class method that counts the number of occurances of item... | source code
extend(self, otherLinkedList) class method that extends the list by adding otherLinkedList at the end of the self pre: self, otherLinkedList | source code
forward(self) | source code
index(self, item) class method that returns the index of the first occurance of item, returns None if there is no any item. | source code
insert(self, position, item) class method that inserts item to the given position pre: self, position, item position should not be greater than length of the list | source code
peek(self, index=None) class method that retrieves, but does not remove, the head (first element) of this list pre: self post: the data of the head of the list or None if the list is empty | source code
pop(self, index=None) class method that removes the item at the given position in the list, and returns it. | source code
remove(self, item) class method that removes the first occurrence of the given item if there is one pre: self, item | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __getitem__(self, index) (Indexing operator) | source code
    replace built-in class method that returns the item for the given
     index
    pre: self, index, index should be less than length of list, list
    should not be empty
    post: return item for the given index

### __init__(self, Node=None, length=0) (Constructor) | source code
constructor method of the class pre: self Overrides: object.__init__

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### count(self, item) | source code
    class method that counts the number of occurances of item
     in the list
    pre: self, item
    post: number of occurances of item in the list

### index(self, item) | source code
class method that returns the index of the first occurance of item, returns None if there is no any item. pre: self, item post: item index or None

### pop(self, index=None) | source code
class method that removes the item at the given position in the list, and returns it. If no index is specified removes and returns the last item in the list pre: self, position (optional), position should be less than length of the list, list should not be empty post: return the item at given index or last item if not specified