def test_inorder(tree):
    tree = om.put(tree, 2, 'book2')
    tree = om.put(tree, 1, 'book1')
    tree = om.put(tree, 3, 'book3')
    lst = tr.inorder(tree)
    for element in lt.iterator(lst):
        print(element)
def generoMasEscuchado(analyzer,horaI,horaF):

    generos = analyzer['GenerosMusicales']
    tracks = analyzer['pistasIds']
    cantidadTracks = 0


    generoReproducciones = mp.newMap(10,prime=109345121,maptype='PROBING', loadfactor=0.5)
    tracks = mp.newMap(10,prime=109345121,maptype='PROBING', loadfactor=0.5)
    cont = 0
    mayor = None


    keys = tv.inorder(generos)
    for n in keys:
        valor = me.getValue(n)
        reproducciones = valor['eventos']
        numReproducciones = 0

        for elemento in reproducciones:  
            dia = elemento['created_at']
            horaDia = dia.split(' ')
            
            horaEvento = horaDia[1]

            hora1 = datetime.strptime( horaEvento, "%X")
            hora2 = datetime.strptime( horaI, "%X")
            hora3 = datetime.strptime( horaF, "%X")

            if( hora1 > hora2 and hora1 < hora3 ):
                numReproducciones += 1

            
        mp.put(generoReproducciones,numReproducciones,n)
        if (numReproducciones >= cont):
            cont = numReproducciones
            mayor = n
    entry = mp.get(generos, mayor)
    valor = me.getValue(entry)  
    for n in valor:
        trackId = n['track_id']
        etiquetas = buscarlistatracks(analyzer,trackId) 
        lista = lt.newList('ARRAY_LIST')
        contador = 0
        for e in etiquetas():
            entrys = mp.get(etiquetas,e)
            valor = me.getValue(entrys)
            hashtag = valor['hashtag']
            if lt.isPresent(lista,hashtag):
                contador += 1
            else:
                lt.put(lista,hashtag)
        entry = { 'contador' : contador, 'track_id': trackId}
        mp.put(tracks,contador,entry)
            
    sa.sort(tracks, cmpfunction=compareIds)
    sa.sort(generoReproducciones, cmpfunction=compareIds)


    return mayor,cont,generoReproducciones,cantidadTracks,tracks
Exemple #3
0
def test_traversal(tree):
    tree = om.put(tree, 23, 'book21')
    tree = om.put(tree, 7, 'book7')
    tree = om.put(tree, 30, 'book30')
    tree = om.put(tree, 5, 'book5')
    tree = om.put(tree, 4, 'book4')
    tree = om.put(tree, 3, 'book3')
    tree = om.put(tree, 20, 'book20')
    tree = om.put(tree, 25, 'book25')
    tree = om.put(tree, 35, 'book35')
    tree = om.put(tree, 29, 'book29')
    tree = om.put(tree, 11, 'book11')
    tree = om.put(tree, 15, 'book15')
    tree = om.put(tree, 10, 'book10')
    tree = om.put(tree, 37, 'book11')
    tree = om.put(tree, 40, 'book15')
    tree = om.put(tree, 45, 'book10')
    assert om.size(tree) == 16
    lstin = tv.inorder(tree)
    lstpre = tv.preorder(tree)
    lstpost = tv.postorder(tree)
    assert lt.size(lstin) == 16
    assert lt.size(lstpre) == 16
    assert lt.size(lstpost) == 16