Game Development Reference
In-Depth Information
void CDentist::AddBucket( USHORT Size,
GUM_RECOMMENDATION Recommendation )
{
sRECOMMENDATION CurrentRecommendation;
mTotalSize += Size; // Calculate the new edge
CurrentRecommendation.Size = Size;
CurrentRecommendation.Edge = mTotalSize;
CurrentRecommendation.Recommendation = Recommendation;
mvRecommendations.push_back( CurrentRecommendation );
}
One important thing to note is how Edge works. As we add each bucket, we re-
trieve the total size of all the buckets we have added so far. That value represents the
right-most edge of the whole collection. Because we are adding our new bucket on
the end of the row, the edge of the new bucket is the total size plus the size of the
new bucket.
We can fill our dentist recommendation list with the following function:
void CDentist::InitVector()
{
mTotalSize = 0;
AddBucket( 4, SUGARLESS );
AddBucket( 1, SUGARRY );
}
This adds our two buckets to the vector. After running InitVector() , the data
stored in the vector is:
i
Size
Edge
Recommendation
0
4
4
SUGARLESS
1
1
5
SUGARY
Search WWH ::




Custom Search