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
Stack
to copy.
def make_array(ls)
-
Makes an
Array
from alist
of elements.Args
ls
- The
list
of elements to insert into a newArray
.
def make_queue(ls)
-
Creates a
Queue
from alist
of elements, enqueueing from left to right.Args
ls
- A
list
of elements to be enqueued into theQueue
.
def make_stack(ls)
-
Creates a
Stack
from alist
of elements, pushing from left to right.Args
ls
- A
list
of elements to be enqueued into theStack
.
def nary_add_children(root, children)
-
Adds
NaryTreeNode
s to be the children of anotherNaryTreeNode
.Args
root
- an
NaryTreeNode
to which we will be adding children. This will be modified in place by this function. children
- a
list
ofNaryTreeNode
s that are the children to be added. These nodes will be added as the children ofroot
in 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.