«
class documentation

class PositionalList(_DoublyLinkedBase):

View In Hierarchy

A sequential container of elements allowing positional access.

Class Position An abstraction representing the location of a single element.
Method __iter__ Generate a forward iteration of the elements of the list.
Method add_after Insert element e into list after Position p and return new Position.
Method add_before Insert element e into list before Position p and return new Position.
Method add_first Insert element e at the front of the list and return new Position.
Method add_last Insert element e at the back of the list and return new Position.
Method after Return the Position just after Position p (or None if p is last).
Method before Return the Position just before Position p (or None if p is first).
Method delete Remove and return the element at Position p.
Method first Return the first Position in the list (or None if list is empty).
Method last Return the last Position in the list (or None if list is empty).
Method replace Replace the element at Position p with e.
Method _insert_between Add element between existing nodes and return new Position.
Method _make_position Return Position instance for given node (or None if sentinel).
Method _validate Return position's node, or raise appropriate error if invalid.

Inherited from _DoublyLinkedBase:

Method __init__ Create an empty list.
Method __len__ Return the number of elements in the list.
Method is_empty Return True if list is empty.
Class _Node Lightweight, nonpublic class for storing a doubly linked node.
Method _delete_node Delete nonsentinel node from the list and return its element.
Instance Variable _header Undocumented
Instance Variable _size Undocumented
Instance Variable _trailer Undocumented
def __iter__(self):

Generate a forward iteration of the elements of the list.

def add_after(self, p, e):

Insert element e into list after Position p and return new Position.

def add_before(self, p, e):

Insert element e into list before Position p and return new Position.

def add_first(self, e):

Insert element e at the front of the list and return new Position.

def add_last(self, e):

Insert element e at the back of the list and return new Position.

def after(self, p):

Return the Position just after Position p (or None if p is last).

def before(self, p):

Return the Position just before Position p (or None if p is first).

def delete(self, p):

Remove and return the element at Position p.

def first(self):

Return the first Position in the list (or None if list is empty).

def last(self):

Return the last Position in the list (or None if list is empty).

def replace(self, p, e):

Replace the element at Position p with e.

Return the element formerly at Position p.

def _insert_between(self, e, predecessor, successor):

Add element between existing nodes and return new Position.

def _make_position(self, node):

Return Position instance for given node (or None if sentinel).

def _validate(self, p):

Return position's node, or raise appropriate error if invalid.