circular_list_algorithms public static functions

Effects: Returns true is "this_node" is in a non-used state as if it was initialized by the "init" function.

Complexity: Constant

Throws: Nothing.

staticvoidinit_header(node_ptr this_node);

Effects: Constructs an empty list, making this_node the only node of the circular list: NodeTraits::get_next(this_node) == NodeTraits::get_previous(this_node) == this_node.

Complexity: Constant

Throws: Nothing.

staticboolunique(const_node_ptr this_node);

Requires: this_node must be in a circular list or be an empty circular list.

Effects: Returns true is "this_node" is the only node of a circular list: return NodeTraits::get_next(this_node) == this_node

Complexity: Constant

Throws: Nothing.

staticstd::size_tcount(const_node_ptr this_node);

Requires: this_node must be in a circular list or be an empty circular list.

Effects: Returns the number of nodes in a circular list. If the circular list is empty, returns 1.

Complexity: Linear

Throws: Nothing.

staticnode_ptrunlink(node_ptr this_node);

Requires: this_node must be in a circular list or be an empty circular list.

Effects: Unlinks the node from the circular list.

Complexity: Constant

Throws: Nothing.

staticvoidunlink(node_ptr b,node_ptr e);

Requires: b and e must be nodes of the same circular list or an empty range.

Effects: Unlinks the node [b, e) from the circular list.

Complexity: Constant

Throws: Nothing.

staticvoidlink_before(node_ptr nxt_node,node_ptr this_node);

Requires: nxt_node must be a node of a circular list.

Effects: Links this_node before nxt_node in the circular list.

Complexity: Constant

Throws: Nothing.

staticvoidlink_after(node_ptr prev_node,node_ptr this_node);

Requires: prev_node must be a node of a circular list.

Effects: Links this_node after prev_node in the circular list.

Complexity: Constant

Throws: Nothing.

staticvoidswap_nodes(node_ptr this_node,node_ptr other_node);

staticvoidtransfer(node_ptr p,node_ptr b,node_ptr e);

Requires: b and e must be nodes of the same circular list or an empty range. and p must be a node of a different circular list or may not be an iterator in Effects: Removes the nodes from [b, e) range from their circular list and inserts them before p in p's circular list.

Complexity: Constant

Throws: Nothing.

staticvoidtransfer(node_ptr p,node_ptr i);

Requires: i must a node of a circular list and p must be a node of a different circular list.

Effects: Removes the node i from its circular list and inserts it before p in p's circular list. If p == i or p == NodeTraits::get_next(i), this function is a null operation.

Complexity: Constant

Throws: Nothing.

staticvoidreverse(node_ptr p);

Effects: Reverses the order of elements in the list.

Throws: Nothing.

Complexity: This function is linear time.

staticvoidmove_backwards(node_ptr p,std::size_t n);

Effects: Moves the node p n positions towards the end of the list.

Throws: Nothing.

Complexity: Linear to the number of moved positions.

staticvoidmove_forward(node_ptr p,std::size_t n);

Effects: Moves the node p n positions towards the beginning of the list.

Throws: Nothing.

Complexity: Linear to the number of moved positions.

circular_list_algorithms private static functions

staticvoidswap_prev(node_ptr this_node,node_ptr other_node);

Requires: this_node and other_node must be nodes inserted in circular lists or be empty circular lists.

Effects: Swaps the position of the nodes: this_node is inserted in other_nodes position in the second circular list and the other_node is inserted in this_node's position in the first circular list.