Ejemplo n.º 1
0
_WPRTLINK unsigned WCHashBase::occurrencesOf( TTypePtr elem ) const {
    unsigned bucket = 0;
    unsigned index = 0;
    unsigned count = 0;
    if( base_find( elem, &bucket, &index, FIND_FIRST ) ) {
        do {
            count++;
            index++;
        } while( base_find( elem, &bucket, &index, NEXT_MULT_FIND ) );
    }
    return( count );
}
Ejemplo n.º 2
0
_WPRTLINK unsigned WCHashBase::removeAll( TTypePtr elem ) {
    unsigned bucket = 0;
    unsigned index = 0;
    unsigned count = 0;
    if( base_find( elem, &bucket, &index, FIND_FIRST ) ) {
        BaseHashLink * link;
        do {
            link = hash_array[ bucket ].get( index );
            WCHashDelete( link );
            count++;
        } while( base_find( elem, &bucket, &index, NEXT_MULT_FIND ) );
    }
    num_entries -= count;
    return( count );
}
Ejemplo n.º 3
0
_WPRTLINK WCSLink * WCHashBase::base_remove_but_not_delete( TTypePtr elem ) {
    unsigned bucket = 0;
    unsigned index = 0;
    if( base_find( elem, &bucket, &index, FIND_FIRST ) ) {
        BaseHashLink * link = (BaseHashLink *)hash_array[ bucket ].get( index );
        num_entries--;
        return( link );
    }
    return( 0 );
};
Ejemplo n.º 4
0
_WPRTLINK unsigned WCSkipNonTempBase::base_occurrencesOf( TTypePtr elem ) const {
    unsigned count = 0;
    node_ptr curr = base_find( elem );

    if( curr != 0 ) {
        do {
            count++;
            curr = curr->forward[ 0 ];
        } while( curr != 0 && base_equiv( curr, elem ) );
    }
    return( count );
};
Ejemplo n.º 5
0
_WPRTLINK WCSLink * WCHashBase::base_set_insert( TTypePtr elem ) {
    unsigned bucket = 0;
    unsigned index = 0;
    if( base_find( elem, &bucket, &index, FIND_FIRST ) == 0 ) {
        if( num_buckets == 0 ) {
            base_throw_out_of_memory();
            return( 0 );
        }
        BaseHashLink * link = WCHashNew( elem );
        if( link == 0 ) {
            base_throw_out_of_memory();
            return( 0 );
        }
        hash_array[ bucket ].append( link );
        num_entries++;
        return( link );
    }
    // find succeeded: an equivalent element was previously in the hash set
    base_throw_not_unique();
    return( 0 );
};