void GPartitionPolicy::addBarrel(MergeBarrelEntry* pEntry)
{
    Partition* pPartition = NULL;
    int32_t nPartition = getPartition(curPartitionSize_);
    map<int32_t,Partition*>::iterator iter = partitionMap_.find(nPartition);
    if (iter != partitionMap_.end())
    {
        pPartition = iter->second;
        pPartition->nPartitionSize_ += curPartitionSize_;///update partition size
        pPartition->add(pEntry);
        if ((int32_t)pPartition->pBarrelQueue_->size() >= 2) ///collision,trigger a merge event
        {
            triggerMerge(pPartition,nPartition);
        }
    }
    else
    {
        pPartition = new Partition(nPartition,curPartitionSize_,2*MAX_TRIGGERS);
        pPartition->add(pEntry);
        partitionMap_.insert(make_pair(nPartition,pPartition));
    }
}
// starts the first fit algorithm
void FirstFit::begin()
{
    // for every job search every partition
    std::list<Job>::iterator iterator;
    for (iterator = jobs.begin(); iterator != jobs.end(); ++iterator) {
        Job tempJ = *iterator;

        std::list<Partition>::iterator iterator2;
        for (iterator2 = parts.begin(); iterator2 != parts.end(); ++iterator2) {
            Partition tempP = *iterator2;

            // if the partition is not busy, it fits, and the job is not already running,
            // assign the job to the partition
            if(!tempP.isBusy() && tempJ.getSize() <= tempP.getSize() && !tempJ.isRunning()){
                tempP.add(tempJ);
                tempJ.setRunning(tempP.getPartNum());
            }
            *iterator2 = tempP;
        }

        *iterator = tempJ;
    }
}