"""race different types of containers..."""


from container import Container
from stack_as_list import Stack
from queue_as_list import Queue
import stack_as_ll
import queue_as_ll
from time import time


def container_cycle(c: Container, r: int) -> str:
    """
    Add/remove c r times.
    c - Container to add/remove
    r - number of times to add/remove
    """
#    start = time()
    for i in range(r):
        c.add(i)
    start = time()
    for i in range(r):
        # repeatedly add and remove
        c.remove()
        c.add(i)
    print("{} add/remove in {} seconds".format(r, time() - start))


if __name__ == "__main__":

    q = Queue()
    s = Stack()
    ls = stack_as_ll.Stack()
    lq = queue_as_ll.Queue()

    # which are linear?

    print('---------------------Python Stack-------------------')
    for j in [10, 100, 1000, 10000, 100000]:
        container_cycle(s, j)
    print('---------------------LL     Stack-------------------')
    for j in [10, 100, 1000, 10000, 100000]:
        container_cycle(ls, j)
    print('---------------------Python Queue-------------------')
    for j in [10, 100, 1000, 10000, 100000]:
        container_cycle(q, j)
    print('---------------------LL     Queue-------------------')
    for j in [10, 100, 1000, 10000, 100000]:
        container_cycle(lq, j)
