Changeset 854

Show
Ignore:
Timestamp:
10/12/08 15:05:54 (3 years ago)
Author:
walter
Message:

fold in changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/phobos-1.x/phobos/internal/aaA.d

    r744 r854  
    583583 
    584584        *paa.a = newb; 
     585        _aaBalance(paa); 
    585586    } 
    586587    return (*paa).a; 
    587588    } 
    588589 
     590/******************************************** 
     591 * Balance an array. 
     592 */ 
     593 
     594void _aaBalance(AA* paa) 
     595{ 
     596    //printf("_aaBalance()\n"); 
     597    if (paa.a) 
     598    { 
     599    aaA*[16] tmp; 
     600    aaA*[] array = tmp; 
     601 
     602    auto aa = paa.a; 
     603    foreach (j, e; aa.b) 
     604    { 
     605        /* Temporarily store contents of bucket in array[] 
     606         */ 
     607        size_t k = 0; 
     608 
     609        void addToArray(aaA* e) 
     610        { 
     611        while (e) 
     612        {   addToArray(e.left); 
     613            if (k == array.length) 
     614            array.length = array.length * 2; 
     615            array[k++] = e; 
     616            e = e.right; 
     617        } 
     618        } 
     619 
     620        addToArray(e); 
     621 
     622        /* The contents of the bucket are now sorted into array[]. 
     623         * Rebuild the tree. 
     624         */ 
     625 
     626        void buildTree(aaA** p, size_t x1, size_t x2) 
     627        { 
     628        if (x1 >= x2) 
     629            *p = null; 
     630        else 
     631        {   auto mid = (x1 + x2) >> 1; 
     632            *p = array[mid]; 
     633            buildTree(&(*p).left, x1, mid); 
     634            buildTree(&(*p).right, mid + 1, x2); 
     635        } 
     636        } 
     637 
     638        auto p = &aa.b[j]; 
     639        buildTree(p, 0, k); 
     640    } 
     641    } 
     642} 
    589643 
    590644/******************************************** 
  • branches/phobos-1.x/phobos/std/socket.d

    r811 r854  
    15361536    static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, int microseconds) 
    15371537    { 
    1538        timeval tv; 
    1539        tv.seconds = 0; 
    1540        tv.microseconds = microseconds
    1541        return select(checkRead, checkWrite, checkError, &tv); 
     1538        timeval tv; 
     1539        tv.seconds = microseconds / 1_000_000; 
     1540        tv.microseconds = microseconds % 1_000_000
     1541        return select(checkRead, checkWrite, checkError, &tv); 
    15421542    } 
    15431543