void Batcher::ChangeBuffer(ref_ptr<CallbacksWrapper> wrapper) { GLState const & state = wrapper->GetState(); FinalizeBucket(state); ref_ptr<RenderBucket> bucket = GetBucket(state); wrapper->SetVAO(bucket->GetBuffer()); }
void ETHBucketManager::GetIntersectingBuckets(std::list<Vector2> &outList, const Vector2 &v2Pos, const Vector2 &v2Size, const Vector2 &v2BucketSize, const bool includeUpperSeams, const bool includeLowerSeams) { const std::size_t ETH_MAX_BUCKETS = 512; const Vector2 v2Min = GetBucket(v2Pos, v2BucketSize) - ((includeUpperSeams) ? Vector2(1,1) : Vector2(0,0)); const Vector2 v2Max = GetBucket(v2Pos+v2Size, v2BucketSize) + ((includeLowerSeams) ? Vector2(1,1) : Vector2(0,0)); outList.clear(); for (float y = v2Min.y; y<=v2Max.y; y+=1.0f) { for (float x = v2Min.x; x<=v2Max.x; x+=1.0f) { outList.push_back(Vector2(x, y)); if (outList.size() > ETH_MAX_BUCKETS) { return; } } } }
bool contains(const TKey& key) const { return GetBucket(key)->contains(key); }
bool insert(const TKey key, TValue value) { return GetBucket(key)->insert(key, value); }
bool remove(const TKey& key) { return GetBucket(key)->remove(key); }
bool conditional_remove(const TKey& key, std::function<bool(const TKey&, const TValue&)> remove_if) { return GetBucket(key)->conditional_remove(key, remove_if); }
void add_or_update(const TKey& key, std::function<TValue(const TKey&)> add, std::function<TValue(const TKey&, TValue)> update) { return GetBucket(key)->add_or_update(key, add, update); }
TValue get_value_or_default(const TKey& key) { return GetBucket(key)->get_value_or_default(key); }
void thicknessWarehouse(int dataDimension, int kValue) { int i, j, k,flag; int bucketSize = 0; int bucketCount = 1; int iterCount = 0, iterCountB; struct gtPoint *iterA; struct gtPoint *iterB; struct gtPoint *tmpPoint = NULL; struct gtPoint *tmpPoint2 = NULL; struct gtPoint *tmpPoint3 = NULL; struct gtPoint *tmpPointNext; struct gtPoint **tmpPointArray; struct gtBucket *tmpBucket = NULL; struct gtBucket *bucketHead, *bucketTail; Stwh = StartPoint(Stwh, &StwhSize, &StwhHead, &StwhTail, dataDimension); Ses = StartPoint(Ses, &SesSize, &SesHead, &SesTail, dataDimension); Sg = StartPoint(Sg, &SgSize, &SgHead, &SgTail, dataDimension); // [STEP 1] Push all points in S to every bucket according to bitmap for (i = 0; i < dataDimension; i++) bucketCount *= 2; //////////////////////////////////////////////////// // Origin: bucket = new gtBucket[bucketCount]; bucket = StartBucket(bucket, &bucketSize, &bucketHead, &bucketTail, dataDimension); for (i = 0; i < bucketCount; i++) { tmpBucket = (struct gtBucket *)malloc(sizeof(struct gtBucket)); InitBucket(tmpBucket, dataDimension); PushBucket(tmpBucket, &bucketSize, &bucketTail); } //////////////////////////////////////////////////// //////////////////////////////////////////////////// // Origin: bucket[S[i]->bitmap].data.push_back(S[i]); tmpPoint = S; tmpPointNext = tmpPoint->next; while (tmpPointNext != NULL) { tmpPoint = tmpPointNext; tmpPointNext = tmpPoint->next; tmpBucket = GetBucket(tmpPoint->bitmap, bucketHead); PushPoint(tmpPoint, &tmpBucket->dataSize, &tmpBucket->dataTail); } //////////////////////////////////////////////////// // [STEP 2] Divide points in every bucket into Sl and Sln tmpBucket = bucket; tmpPointArray = (struct gtPoint **)malloc(sizeof(struct gtPoint*) * tmpBucket->dataSize); for (i = 1; i < bucketCount; i++) { tmpBucket->bitmap = i; tmpPoint = tmpBucket->data; tmpPointArray[0] = tmpPoint; for (j = 1; j < tmpBucket->dataSize; j++) { tmpPoint = tmpPoint->next; tmpPointArray[j] = tmpPoint; } for (j = 1; j < tmpBucket->dataSize; j++) { tmpPoint = tmpPointArray[j]; for (k = 1; k < tmpBucket->dataSize; k++) { tmpPoint2 = tmpPointArray[k]; if (j != k ) { if (isPoint1DominatePoint2(tmpPoint2, tmpPoint)) { tmpPoint->domainatedCount++; if (tmpPoint->domainatedCount >= kValue) { PushPoint(tmpPoint, &tmpBucket->SlnSize, &tmpBucket->SlnTail); break; } } } } if (k == tmpBucket->dataSize) { // which means data[j] is not dominted more than k times, then put it into Sl. PushPoint(tmpPoint, &tmpBucket->SlSize, &tmpBucket->SlTail); // I think we do not need the above line code, because every point in Sl will be pushed // to Stwh, therefore, we can just put it to Stwh directly. is that right??? ////////////////////////////////////////////////////////////////////////////////////////////////// // [STEP 3] Push Bucket.Sl -> Stwh // Origin: // for (int j = 0; j < bucket[i].SlSize(); j++) { // PushPoint(bucket[i].Sl[j],&StwhSize,&StwhTail); // } PushPoint(tmpPoint, &StwhSize, &StwhTail); ////////////////////////////////////////////////////////////////////////////////////////////////// } } tmpBucket = tmpBucket->next; } // [STEP 4] Push Swth -> Ses // std::sort(Stwh.begin(), Stwh.end(), gtSortAlgo); ///////////////////////////////////////////////////////////////////////////////////// // Origin: // vector<gtPoint *>::iterator itHead, itTail; // for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) { // if(!*itHead) continue; // for (itTail = Stwh.end(); itTail != Stwh.begin(); itTail--) { // if(!*itTail) continue; // if (isPoint1DominatePoint2(*itTail, *itHead)) (*itHead)->domainatedCount ++; // if ((*itHead)->domainatedCount > kValue) { // Ses.push_back(*itHead); // Stwh.erase(itHead); // break; // } // if (isPoint1DominatePoint2(*itHead, *itTail)) (*itTail)->domainatedCount ++; // if ((*itTail)->domainatedCount > kValue) { // Ses.push_back(*itTail); // Stwh.erase(itTail); // } // } // } iterA = Stwh; while (iterA->next != NULL) { iterA = iterA->next; iterCount++; iterB = StwhTail; iterCountB = 0; while (iterB->previous != NULL) { iterB = iterB->previous; iterCountB++; if (isPoint1DominatePoint2(iterB, iterA)) { iterA->domainatedCount++; if (iterA->domainatedCount > kValue) { PushPoint(iterA, &SesSize, &SesTail); DeletePoint(iterCount, &StwhHead, &StwhSize); break; } } if (isPoint1DominatePoint2(iterA, iterB)) { iterB->domainatedCount++; if (iterB->domainatedCount > kValue) { PushPoint(iterB, &SesSize, &SesTail); DeletePoint(iterCountB, &StwhHead, &StwhSize); } } } } ////////////////////////////////////////////////////////////////////////////////////// //[STEP 5] (Stwh, Ses) -> Sg ///////////////////////////////////////////////////////////////////////////////////// // Origin: // for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) { // for (itTail = Ses.begin(); itTail != Ses.end(); itTail++) { // if (isPoint1DominatePoint2(*itTail, *itHead)) (*itHead)->domainatedCount ++; // if ((*itHead)->domainatedCount > kValue) { // Stwh.erase(itHead); // } // } // } /* iterCount = 0; iterA = Stwh; while (iterA->next != NULL) { iterA = iterA->next; iterCount++; iterB = Ses; while (iterB->next != NULL) { iterB = iterB->next; if (isPoint1DominatePoint2(iterB, iterA)) { iterA->domainatedCount++; if (iterA->domainatedCount >= kValue) { DeletePoint(iterCount, &StwhHead, &StwhSize); break; } } } } */ ////////////////////////////////////////////////////////////////////////////////////// tmpPoint = Stwh->next; i = 1; do{ //To compare all the points in Stwh with all points in Stwh and Ses, to see whether they need to compare Slns in some Buckets. dominateBucket = (int *)malloc(bucketCount*sizeof(int)); tmpPoint3 = tmpPoint->next; tmpPoint2 = Ses->next; while (tmpPoint2 != NULL){ if (isPoint1DominatePoint2(tmpPoint2, tmpPoint)){ tmpPoint->domainatedCount++; *(dominateBucket + tmpPoint2->bitmap)=1; } if (tmpPoint->domainatedCount >= kValue){ tmpPoint->previous->next = tmpPoint->next; PushPoint(tmpPoint,SesSize,SesTail); free(dominateBucket); break; } tmpPoint2 = tmpPoint2->next; } if (tmpPoint2 == NULL){ tmpPoint2 = Stwh->next; while (tmpPoint2 != NULL){ if (isPoint1DominatePoint2(tmpPoint2, tmpPoint)){ *(dominateBucket + tmpPoint2->bitmap) = 1; } tmpPoint2 = tmpPoint2->next; } for (j = 1; j < bucketCount; j++){ if (*(dominateBucket + j) == 1){ tmpPoint2 = (bucket + *(dominateBucket + j))->Sln->next; while (tmpPoint2 != NULL){ if (isPoint1DominatePoint2(tmpPoint2, tmpPoint)) tmpPoint->domainatedCount++; if (tmpPoint->domainatedCount >= kValue){ tmpPoint->previous->next = tmpPoint->next; PushPoint(tmpPoint, SesSize, SesTail); free(dominateBucket); break; } } if (tmpPoint2 != NULL) break; } } if (j == bucketCount) PushPoint(tmpPoint, &SgSize, &SgTail); } tmpPoint = tmpPoint3; } while (tmpPoint); /* gtBucket *Stwh_b = new gtBucket [bucketCount]; gtBucket *Ses_b = new gtBucket [bucketCount]; for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) (Stwh_b[(*itHead)->bitmap]).StwhSes.push_back((*itHead)); for (itHead = Ses.begin(); itHead != Ses.end(); itHead++) (Ses_b[(*itHead)->bitmap]).StwhSes.push_back((*itHead)); for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) { vector<gtPoint *> cmpS; for (int i = 0; i < bucketCount; i++) { if (i == (*itHead)->bitmap) continue; else { for (int j = 0; j < Stwh_b[i].StwhSes.size(); j++) cmpS.push_back(Stwh_b[i].StwhSes[j]); for (int j = 0; j < Ses_b[i].StwhSes.size(); j++) cmpS.push_back(Ses_b[i].StwhSes[j]); } } for (int i = 0; i < cmpS.size(); i++) { bool isIteratorErased = false; if (isPoint1DominatePoint2(*itHead, cmpS[i])) continue; else { for (int j = 0; j < bucket[cmpS[i]->bitmap].Sln.size(); j++) { if (isPoint1DominatePoint2(bucket[cmpS[i]->bitmap].Sln[j], *itHead)) (*itHead)->domainatedCount ++; if ((*itHead)->domainatedCount > kValue) {; Stwh.erase(itHead); isIteratorErased = true; break; } } } if (isIteratorErased) break; } } Sg = Stwh; */ }
void thicknessWarehouse(int dataDimension, int kValue) { int i,j,k; struct gtPoint *tmpPoint = NULL; struct gtBucket *tmpBucket; int bucketSize = 0; int bucketCount = 1; struct gtBucket *bucketHead, *bucketTail; Stwh = StartPoint(Stwh, &StwhSize, &StwhHead, &StwhTail, dataDimension); Ses = StartPoint(Ses, &SesSize, &SesHead, &SesTail, dataDimension); Sg = StartPoint(Sg, &SgSize, &SgHead, &SgTail, dataDimension); // [STEP 1] for (i = 0; i < dataDimension; i++) bucketCount *= 2; //////////////////////////////////////////////////// // Origin: bucket = new gtBucket[bucketCount]; bucket = StartBucket(bucket, &bucketSize, &bucketHead, &bucketTail); for (i = 0; i < bucketCount; i++) { tmpBucket = (struct gtBucket *)malloc(sizeof(struct gtBucket)); InitBucket(tmpBucket); PushBucket(tmpBucket, &bucketSize, &bucketTail); } //////////////////////////////////////////////////// /* for (int i = 0; i < SSize; i++){ //////////////////////////////////////////////////// // Origin: bucket[S[i]->bitmap].data.push_back(S[i]); tmpPoint = GetPoint(i, SHead); tmpBucket = GetBucket(tmpPoint->bitmap, bucketHead); //Armour: tmpBucket->data = tmpPoint;There seems to have some problems. tmpBucket->data->PushPoint(tmpPoint,&i,&bucketTail); //////////////////////////////////////////////////// }*/ for (i = 0; i < SSize; ){ //i will automatically increment in tmpBucket->data->PushPint(); //////////////////////////////////////////////////// // Origin: bucket[S[i]->bitmap].data.push_back(S[i]); tmpPoint = GetPoint(i, SHead); tmpBucket = GetBucket(tmpPoint->bitmap, bucketHead); //Armour: tmpBucket->data = tmpPoint;There seems to have some problems. //tmpBucket->data->PushPoint(tmpPoint,&i,&bucketTail); //PushPoint(tmpPoint,&i,&bucketTail); //////////////////////////////////////////////////// } // [STEP 2] for (i = 0; i < bucketCount; i++) { //////////////////////////////////////////////////// // Origin: bucket[i].bitmap = i; tmpBucket = GetBucket(i, bucketHead); tmpBucket->bitmap = i; // Set Bitmap //////////////////////////////////////////////////// //Calculate DominanceCount and put each node into Sl or Sln for (j = 0; j < SSize; j++) { for (k = 0; k < SSize; k++) { //Changed if (isPoint1DominatePoint2(&bucket[i].data[k], &bucket[i].data[j])){ bucket[i].data[j]->domainatedCount++; } if (bucket[i].data[j]->domainatedCount >= kValue){ PushPoint(&bucket[i].data[j],&(bucket[i].SlnSize),bucket[i].SlnTail); break; } } if (k == SSize) // which means data[j] is not dominted more than k times, then put it into Sl. PushPoint(&bucket[i].data[j],&(bucket[i].SlTaillSize),bucket[i].SlTail); } FreeAllPoints(bucket[i].data,&(bucket[i].dataSize); /* // [STEP 3] Push Bucket.Sl -> Stwh for (int j = 0; j < bucket[i].SlSize(); j++) Stwh.push_back(bucket[i].Sl[j]); } */ // [STEP 3] Push Bucket.Sl -> Stwh //for (int j = 0; j < bucket[i].Sl.size(); j++) // Stwh.push_back(bucket[i].Sl[j]); /* // [STEP 4] Push Swth -> Ses std::sort(Stwh.begin(), Stwh.end(), gtSortAlgo); vector<gtPoint *>::iterator itHead, itTail; for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) { if(!*itHead) continue; for (itTail = Stwh.end(); itTail != Stwh.begin(); itTail--) { if(!*itTail) continue; if (isPoint1DominatePoint2(*itTail, *itHead)) (*itHead)->domainatedCount ++; if ((*itHead)->domainatedCount > kValue) { Ses.push_back(*itHead); Stwh.erase(itHead); break; } if (isPoint1DominatePoint2(*itHead, *itTail)) (*itTail)->domainatedCount ++; if ((*itTail)->domainatedCount > kValue) { Ses.push_back(*itTail); Stwh.erase(itTail); } } } // [STEP 5] (Stwh, Ses) -> Sg for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) { for (itTail = Ses.begin(); itTail != Ses.end(); itTail++) { if (isPoint1DominatePoint2(*itTail, *itHead)) (*itHead)->domainatedCount ++; if ((*itHead)->domainatedCount > kValue) { Stwh.erase(itHead); } } } gtBucket *Stwh_b = new gtBucket [bucketCount]; gtBucket *Ses_b = new gtBucket [bucketCount]; for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) (Stwh_b[(*itHead)->bitmap]).StwhSes.push_back((*itHead)); for (itHead = Ses.begin(); itHead != Ses.end(); itHead++) (Ses_b[(*itHead)->bitmap]).StwhSes.push_back((*itHead)); for (itHead = Stwh.begin(); itHead != Stwh.end(); itHead++) { vector<gtPoint *> cmpS; for (int i = 0; i < bucketCount; i++) { if (i == (*itHead)->bitmap) continue; else { for (int j = 0; j < Stwh_b[i].StwhSes.size(); j++) cmpS.push_back(Stwh_b[i].StwhSes[j]); for (int j = 0; j < Ses_b[i].StwhSes.size(); j++) cmpS.push_back(Ses_b[i].StwhSes[j]); } } for (int i = 0; i < cmpS.size(); i++) { bool isIteratorErased = false; if (isPoint1DominatePoint2(*itHead, cmpS[i])) continue; else { for (int j = 0; j < bucket[cmpS[i]->bitmap].Sln.size(); j++) { if (isPoint1DominatePoint2(bucket[cmpS[i]->bitmap].Sln[j], *itHead)) (*itHead)->domainatedCount ++; if ((*itHead)->domainatedCount > kValue) {; Stwh.erase(itHead); isIteratorErased = true; break; } } } if (isIteratorErased) break; } } Sg = Stwh; */ } int main(int argc, const char * argv[]) { /* cin >> dataCount >> kValue >> dataDimension; cout << "Count: [" << dataCount << "]data in " << dataDimension << "-Dimensions\n"; cout << "K-Value: " << kValue << endl; */ scanf("%d %d", &dataDimension, &dataCount); inputData(dataDimension, dataCount); kValue = 1; thicknessWarehouse(dataDimension, kValue); /* for (int i = 0; i < Sg.size(); i++) { Sg[i]->printPoint(); } */ return 0; }