Beispiel #1
0
    :type v: same as elements of *l*
    """
    it = list.get_listiterator(l)

    while list.hasNext(it) and it['successor']['value'] < v:
        list.next(it)

    list.add(it, v)


if __name__ == "__main__":
    l = list.empty_list()
    for i in reversed(range(1, 5)):
        list.cons(l, i)

    list.print_list(l)

    # test 0 : impression renversee
    list.print_list(l, reverse=True)

    # test 1 : impression avec iterateurs
    print_with_iterator(l)
    print_with_iterator_reverse(l)

    # test 2 : insertion avant le 3eme element
    it = list.get_listiterator(l)
    print(list.next(it))
    print(list.next(it))
    list.add(it, 23)
    assert (list.previous(it)["value"] == 23)
    print_with_iterator(l)
Beispiel #2
0
    :param l: An ordered list.
    :type l: dict
    :return: the i-th element    
    :rtype: Type of the elements of the list

    Throws NoSuchElementException if *i* is out of bounds.
    """
    pass


if __name__ == "__main__":
    l = list.empty_list()
    for i in reversed(range(1, 5)):
        list.cons(l, i)

    list.print_list(l)

    #    # test 0 : impression renversee
    #    list.print_list(l,reverse=True)

    # test 1 : impression avec iterateurs
    print('--- test 1 ---')
    print_with_iterator(l)
    print_with_iterator_reverse(l)

    # test 2 : verification des exceptions
    print('--- test 2 ---')
    try:
        it = list.get_listiterator(l)
        while True:
            list.next(it)