Module dalpy.factory_utils
This module provides factory functions for creating and modifying DALPy objects.
The functions contained in this module are meant to be used when writing test cases for problems implemented in DALPy.
Functions
def copy_stack(s)-
Creates a copy of a
Stack.Args
s- The
Stackto copy.
def make_array(ls)-
Makes an
Arrayfrom alistof elements.Args
ls- The
listof elements to insert into a newArray.
def make_queue(ls)-
Creates a
Queuefrom alistof elements, enqueueing from left to right.Args
ls- A
listof elements to be enqueued into theQueue.
def make_stack(ls)-
Creates a
Stackfrom alistof elements, pushing from left to right.Args
ls- A
listof elements to be enqueued into theStack.
def nary_add_children(root, children)-
Adds
NaryTreeNodes to be the children of anotherNaryTreeNode.Args
root- an
NaryTreeNodeto which we will be adding children. This will be modified in place by this function. children- a
listofNaryTreeNodes that are the children to be added. These nodes will be added as the children ofrootin the order they occur in thislist.children[0]will be the leftmost child ofroot,children[1]will be the right sibling ofchildren[0]and so on.