Exemplo n.º 1
0
def p_traversal():
    lst = pointerlist()
    for i in range(0, n):
        lst.insert(1, lst.end())
    c = lst.first()
    while c:
        c = lst.next_cell(c)
Exemplo n.º 2
0
def pointer_tail():
    l = pointerlist()
    start = time.time()
    for i in range(n):
        l.insert(1, l.end())
    stop = time.time()
    timetaken = (stop - start) * 1000
    timetaken = "{:.4f}".format(timetaken)
    return timetaken
Exemplo n.º 3
0
def p_del_head():
    lst = pointerlist()
    for i in range(0, n):
        lst.insert(1, lst.first())
    for i in range(0, n):
        lst.delete(0)
Exemplo n.º 4
0
def p_tail():
    lst = pointerlist()
    for i in range(0, n):
        lst.insert(1, lst.end())
Exemplo n.º 5
0
def p_head():
    lst = pointerlist()
    for i in range(0, n):
        lst.insert(1, 0)
Exemplo n.º 6
0
def p_assign():
    lst = pointerlist()
Exemplo n.º 7
0
#!/usr/bin/env python

#it is recommended to pipe the output to a file for easier reading

from pointerlist import *

#pointerlist tests

print "pointerlist.py tests"
print
print "head insertion:"
test = pointerlist()
test.insert(1, 0)
test.insert(2, 0)
test.insert(3, 0)
test.insert(4, 0)
test.insert(5, 0)
print "The following list should be 5 4 3 2 1:"
test.printlist()

print "After delete, should be 4 3 2"
test.delete(0)
test.delete(test.end())
test.printlist()
print
print "Pointer to first cell and its element, 4:"
print test.first(), "element:", test.first().element
print
print "Cell with 4 points to next:"
c = test.first()
print test.next_cell(c), "element: ", test.next_cell(c).element