Esempio n. 1
0
// write all ranges who's depth equals de depth given as argument
void write_with_depth(unsigned int depth, FILE* fp) {
    range_tree_t* node = root;
    unsigned long flags = 0;
    range_t       node_tmp;

    unsigned int cdepth = 0;

    for (;;) {
        range_tree_t* curr = node;

        if (!(flags & done_this) && (cdepth == depth)) {
            memset(&node_tmp, 0, sizeof(range_t));

            node_tmp.left    = (curr->left  != NULL) ? curr->left->id  : UINT_MAX;
            node_tmp.right   = (curr->right != NULL) ? curr->right->id : UINT_MAX;
            node_tmp.start   = curr->start;
            node_tmp.end     = curr->end;
            node_tmp.country = curr->country->id;

            fwrite(&node_tmp, sizeof(range_t), 1, fp);

            curr->id = next_id++;
        }

        node = tree_left(&flags, curr);

        if (node == NULL) {
            node = tree_right(&flags, curr);

            if (node == NULL) {
                node = tree_up(&flags, curr);

                if (node == NULL) {
                    return;
                } else {
                    cdepth--;
                }
            } else {
                cdepth++;
            }
        } else {
            cdepth++;
        }
    }
}
Esempio n. 2
0
//-----------------------------------------------
void show_mess(char* p1, char* p2, char* p3, char* p4,int m_sec)
{
bgnd_par(p1,p2,p3,p4);
tree_up(iSM,sub_ind,sub_ind1,sub_ind2);
ret((char)(m_sec/100));
}