コード例 #1
0
bool bst_is_equal(bst_t bst, bst_t other) {


    switch (bst_type(bst) == bst_type(other)) {

    case true:

        if (bst_type(bst) == isNotEmpty) {

            return (pair_is_equal(bst->pair, other->pair)
                    && bst_is_equal(bst->izq, other->izq)
                    && bst_is_equal(bst->der, other->der));

        } else {
            return true;
        }
        break;


    default:

        return false;
        break;
    }
}
コード例 #2
0
ファイル: dict.c プロジェクト: tinrodriguez8/sourceProjects
bool dict_is_equal(dict_t dict, dict_t other) {

    assert(dict != NULL && other != NULL);

    return dict->length == other->length
        && bst_is_equal(dict->data, other->data);
}
コード例 #3
0
bst_t bst_copy(bst_t bst) {

    bst_t copy = bst_empty();

    switch (bst_type(bst)) {

    case isNull:
        bst_destroy(copy);
        return (NULL);
        break;

    case isEmpty:
        break;

    case isNotEmpty:
        copy->pair = pair_copy(bst->pair);
        copy->izq = bst_copy(bst->izq);
        copy->der = bst_copy(bst->der);
        break;
    }

    assert(bst_is_equal(bst, copy));
    /*POST*/ return (copy);

}
コード例 #4
0
ファイル: bst.c プロジェクト: tinrodriguez8/sourceProjects
bool bst_is_equal(bst_t bst, bst_t other) {
    bool result = true;
    /* */
    if (bst != NULL && other != NULL) {
        result = pair_is_equal(bst->pair, other->pair);
        if (result) {
            result = bst_is_equal(bst->left, other->left);
        }
        if (result) {
            result = bst_is_equal(bst->right, other->right);
        }
    } else if (bst != NULL || other != NULL) {
        result = false;
    }
    return (result);
}
コード例 #5
0
bool dict_is_equal(dict_t dict, dict_t other) {

    /*Precondition verification*/
    assert(dict != NULL);
    assert(other != NULL);

    if (dict->length != other->length) {
    
        return false;
        
    } else {

        return (bst_is_equal(dict->data, other->data));
        
    }

}