Created
July 6, 2010 00:46
-
-
Save naan/464861 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long randNum = random(); | |
int dart = randNum % totalPercent; | |
int tempTotal = 0; | |
AdWhirlAdNetworkConfig *result = nil; | |
for (AdWhirlAdNetworkConfig *network in prioritizedAdNetworks) { | |
tempTotal += network.trafficPercentage; | |
if (dart < tempTotal) { | |
// this is the one to use. | |
result = network; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment