pymasep.circular_head_list
Classes
Implementation of a circular list with a head pointer. |
Module Contents
- class pymasep.circular_head_list.CircularHeadList(initlist=None)
Bases:
collections.UserListImplementation of a circular list with a head pointer.
Initialize a circular list. The list is empty by default, and head points to nothing.
- Parameters:
initlist – Initialize the circular list. Head point to the first element if initList is passed.
- _head_idx
- property head
- The pointer to the head of the circular list.
- Returns:
The element pointed by the head
- append(item)
Append an element at the end of the list (not circular). Change the head only if the list was empty.
- Parameters:
item – Item to add in the list
- Return type:
None
- next()
Return the next element of the circular list.
- Returns:
Return the next element. Return None if the list is empty
- move_head_next()
Move head to the next element. Head stay None if the list is empty.
- Return type:
None
- insert(i, item)
Insert item at position i. The head remains at the same position except if the insertion is in an empty list.
- Parameters:
i (int) – Position
item – item to insert
- Return type:
None
- remove(item)
Remove is not permitted.
- Parameters:
item – Any ite.
- Raises:
AttributeError – Remove is not permitted for CircularHeadList objects
- Return type:
None
- to_xml()
Transform a circular list to an XML structure.
Format (empty list) is
<CircularHeadList><data><list /></data><head_idx>-1</head_idx></CircularHeadList>- Returns:
An XML Element
- Return type:
xml.etree.ElementTree.Element
- from_xml(xml_node)
Transform all XML elements from the xml_node to the current instance.
- Parameters:
xml_node (xml.etree.ElementTree.Element) – The XML node that contains the CircularList data.
- Returns:
None. The current instance is modified
- Return type:
None