Ejemplo n.º 1
0
/*-------------------------------------------------------------------------------------
 * PURPOSE: increments the count for the given item in the table
 *          - If the item does not exist, then adds the given item to table
 *          - else increments the existing similar item in table
 * PARM   : FPTreeItem, item to be incremented
 *-----------------------------------------------------------------------------------*/
void HeaderTable::increment(FPTreeItem *item){
    HeaderItem* found;
    int hashIndex;

    if (item != NULL){
        hashIndex = getHashIndex(item);
        
        if (hashIndex >=0 && hashIndex < MAX_DOMAIN_ITEMS){
            found = freqItems[hashIndex];
            
            if (found == NULL){ //if no entry
                FPTreeNode *tempFPTreeNode = new FPTreeNode(item, NULL, NULL);
                HeaderItem *tempHeader  = new HeaderItem(tempFPTreeNode);
                this->freqItems[hashIndex] = tempHeader;
                this->numDomainItems++;
            } else {
                found->getNode()->getData()->increaseSupport(item);
                delete(item);
            }
        }
    }
}
Ejemplo n.º 2
0
void  HeaderTable::incrementHashItem(HeaderItem *hash[MAX_DOMAIN_ITEMS], FPTreeItem *item){
    HeaderItem *found;
    int hashIndex = -1;
    
    if (item != NULL && hash != NULL){
        hashIndex = HeaderTable::getHashIndex(item);
        
        if (hashIndex >= 0 && hashIndex < MAX_DOMAIN_ITEMS){
            found = hash[hashIndex];
            
            if (found == NULL){ //if no entry
                FPTreeNode *tempFPTreeNode = new FPTreeNode(item, NULL, NULL);
                HeaderItem *tempHeader  = new HeaderItem(tempFPTreeNode);
                hash[hashIndex] = tempHeader;
            } else {
                found->getNode()->getData()->increaseSupport(item);
                delete(item);
            }

        }
    }
}