コード例 #1
0
def test():
    ll = LinkedList()
    ll.add("a")
    ll.add("b")
    ll.debug_print()
    ll.set(1, "B")
    ll.debug_print()
    ll.add("c")
    ll.debug_print()
    # ll.delete(3)
    ll.swap(0, 1)
    ll.debug_print()
コード例 #2
0
def main():
    with open(FILE_INPUT) as input_file:
        # with open(FILE_OUTPUT, 'w') as output_file:
        # sys.stdout = output_file
        csv_reader = csv.reader(input_file, delimiter=',')
        line = 0

        for row in csv_reader:
            command = row[0]
            param_one = row[1]
            param_two = row[2]

            # print line number and command
            print('{}:{},{},{}'.format(line, command, param_one, param_two))

            # call appropriate method based on command
            if command == 'CREATE':
                linkedlist = LinkedList()
            else:
                exec_command(command, linkedlist, param_one, param_two)

            line += 1
コード例 #3
0
def array_runner(command, arg1, arg2):
    global a

    if arg1.isdigit():
        arg1 = int(arg1)
    if arg2.isdigit():
        arg2 = int(arg2)
    if command == 'CREATE':
        a = LinkedList()
    elif command == 'DEBUG':
        a.debug_print()
    elif command == 'ADD':
        a.add(arg1)
    elif command == 'SET':
        a.set(arg1, arg2)
    elif command == 'GET':
        a.get(arg1)
    elif command == 'DELETE':
        a.delete(arg1)
    elif command == 'INSERT':
        a.insert(arg1, arg2)
    elif command == 'SWAP':
        a.swap(arg1, arg2)
    return []
コード例 #4
0
ファイル: main.py プロジェクト: trevanreeser41/linkedlist
from linkedlist_api import LinkedList
import csv

linkedList = LinkedList()

linkedList.add(1)
linkedList.add(2)
linkedList.add(3)
linkedList.debug_print()
linkedList.set(1,0)
a=linkedList.get(1)
linkedList.debug_print()
linkedList.swap(0,1)
print(a)
linkedList.debug_print()
linkedList.insert(1,9)
linkedList.debug_print()
linkedList.delete(0)
linkedList.debug_print()

with open('data_example.csv', newline='') as csvfile:
    reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
    for row in reader:
        items = row[0].split(",",1)
        parameters=items[1].split(",")
        action = items[0]
        if action ==  'CREATE':
            linkedList = LinkedList()
        elif action == 'DEBUG':
            linkedList.debug_print()
        elif action == 'ADD':
コード例 #5
0
 def __init__(self):
     '''Constructor'''
     self.queue = LinkedList()
コード例 #6
0
ファイル: main.py プロジェクト: gbird3/is537
 def cmd_create(self, *args):
     self.list = LinkedList()
コード例 #7
0
ファイル: main.py プロジェクト: cbbeyer/linked_lists
from linkedlist_api import LinkedList, Node
import csv
import sys

orig_stdout = sys.stdout
f = open('output.txt', 'w')
sys.stdout = f
line_count = 0

with open('data.csv') as csvfile:
    reader = csv.reader(csvfile, delimiter=',')
    for row in reader:
        print("{}:{}".format(line_count, ','.join(str(item) for item in row)))
        command = row[0]
        if command == 'CREATE':
            linked_list = LinkedList()
        elif command == 'DEBUG':
            linked_list.debug_print()
        elif command == 'ADD':
            linked_list.add(row[1])
        elif command == 'GET':
            linked_list.get(int(row[1]))
        elif command == 'SET':
            linked_list.set(int(row[1]), row[2])
        elif command == 'INSERT':
            linked_list.insert(int(row[1]), row[2])
        elif command == 'DELETE':
            linked_list.delete(int(row[1]))
        elif command == 'SWAP':
            linked_list.swap(int(row[1]), int(row[2]))