Alex Bikfalvi
SimStream Documentation
ModelSelectMaxRemaining.cpp
00001 #include "Headers.h" 00002 #include "ModelSelectMaxRemaining.h" 00003 00004 CModelSelectMaxRemaining::CModelSelectMaxRemaining( 00005 unsigned int numChannels, 00006 unsigned int numLayers, 00007 unsigned int numPeers 00008 ) : CModelSelect(numChannels, numLayers, numPeers) 00009 { 00010 } 00011 00012 CModelSelectMaxRemaining::~CModelSelectMaxRemaining() 00013 { 00014 } 00015 00016 CPeer** CModelSelectMaxRemaining::Select(__time time, __uint32 channel, __uint32 child) 00017 { 00018 assert(channel < this->numChannels); 00019 assert(child < this->numPeers); 00020 00021 CPeer* peerChild = &this->peers[child]; 00022 00023 for(__uint32 layer = 0; layer < this->numLayers; layer++) 00024 { 00025 __time maxRemaining = -1; 00026 CPeer* maxPeer = NULL; 00027 00028 for(set<CPeer*>::iterator iter = this->index[channel].begin(); iter != this->index[channel].end(); iter++) 00029 { 00030 if(!this->IsResult(*iter, layer)) 00031 { 00032 if(peerChild->VerifyParent(channel, layer, *iter)) 00033 { 00034 maxRemaining = (*iter)->Remaining(time, channel); 00035 maxPeer = *iter; 00036 } 00037 } 00038 } 00039 00040 this->result[layer] = maxPeer; 00041 } 00042 00043 return this->result; 00044 } 00045 00046 CPeer* CModelSelectMaxRemaining::Select(__time time, __uint32 channel, __uint32 layer, __uint32 child) 00047 { 00048 assert(channel < this->numChannels); 00049 assert(child < this->numPeers); 00050 00051 CPeer* peerChild = &this->peers[child]; 00052 00053 __time maxRemaining = -1; 00054 CPeer* maxPeer = NULL; 00055 00056 for(set<CPeer*>::iterator iter = this->index[channel].begin(); iter != this->index[channel].end(); iter++) 00057 { 00058 if(!this->IsResult(*iter, layer)) 00059 { 00060 if(peerChild->VerifyParent(channel, layer, *iter)) 00061 { 00062 maxRemaining = (*iter)->Remaining(time, channel); 00063 maxPeer = *iter; 00064 } 00065 } 00066 } 00067 00068 return maxPeer; 00069 }
Last updated: February 8, 2011