Exemple #1
0
def lastElement (lst):
    """
    Retorna el último elemento de la lista, sin eliminarlo.
    """
    if (lst['type']=='ARRAY_LIST'):
        return alt.lastElement(lst)
    else:
        return slt.lastElement(lst)
def test_addLast(lst, books):
    assert slt.isEmpty(lst) == True
    assert slt.size(lst) == 0
    slt.addLast(lst, books[1])
    assert slt.size(lst) == 1
    slt.addLast(lst, books[2])
    assert slt.size(lst) == 2
    book = slt.firstElement(lst)
    assert book == books[1]
    book = slt.lastElement(lst)
    assert book == books[2]
Exemple #3
0
def test_addLast(lst, casting):
    assert slt.isEmpty(lst) == True
    assert slt.size(lst) == 0
    slt.addLast(lst, casting[1])
    assert slt.size(lst) == 1
    slt.addLast(lst, casting[2])
    assert slt.size(lst) == 2
    cast = slt.firstElement(lst)
    assert cast == casting[1]
    cast = slt.lastElement(lst)
    assert cast == casting[2]
Exemple #4
0
def test_addLast(lst, peliculas):
    assert slt.isEmpty(lst) == True
    assert slt.size(lst) == 0
    slt.addLast(lst, peliculas[1])
    assert slt.size(lst) == 1
    slt.addLast(lst, peliculas[2])
    assert slt.size(lst) == 2
    pelicula = slt.firstElement(lst)
    assert pelicula == peliculas[1]
    pelicula = slt.lastElement(lst)
    assert pelicula == peliculas[2]
Exemple #5
0
def lastElement(lst):
    """
    Retorna el último elemento de la lista, sin eliminarlo.
    Args:
        lst
            Lista a evaluar
    Return::int
        El último elemento dentro de la lista
    """
    if (lst['type'] == 'ARRAY_LIST'):
        return alt.lastElement(lst)
    else:
        return slt.lastElement(lst)
Exemple #6
0
def lastElement(lst):
    """ Retorna el último elemento de una  lista no vacia.  No se elimina el elemento.

    Args:
        lst: La lista a examinar

    Raises:
        Exception
    """
    try:
        if (lst['type'] == 'ARRAY_LIST'):
            return alt.lastElement(lst)
        else:
            return slt.lastElement(lst)
    except Exception as exp:
        error.reraise(exp, 'List->lastElement: ')