
I would be very interested in such a container. Even more, I would be interested in a priority queue which allows one to specify a distribution based on either the order statistic or the priority. The head/front/pop operator would then select based on the distribution. Joel

----- Original Message ----- From: "Joel Young" <jdy@cs.brown.edu> To: <boost@lists.boost.org>; <anglewyrm@hotmail.com> Cc: <jdy@cs.brown.edu> Sent: Friday, September 03, 2004 7:25 AM Subject: C++ Random Container
I would be very interested in such a container.
The current working implementation of the hat container (v1.44) is at: http://home.comcast.net/~anglewyrm/hat.html It is a non-sequential associative container which allows both the key (probability weight) and the value (associated item) to be modified, and neither one has to be unique.
Even more, I would be interested in a priority queue which allows one to specify a distribution based on either the order statistic or the priority. The head/front/pop operator would then select based on the distribution.
Are you speaking of a three-valued system, or are you applying a sorting order? Could you give an example of a few lines of code that demonstrate the usage? -:|:- AngleWyrm

Its me say:
priority. The head/front/pop operator would then select based on the distribution.
Wyrm Say:
order? Could you give an example of a few lines of code that demonstrate the usage?
It would be used exactly like a priority queue, except that the next item returned would be selected randomly, either by some weight based on the priority (one case, bout like you have) or based on its order. If it was one from the front then 50 percent chance, 2 from the front 25% and so on. (just an example) Joel

Its me say:
priority. The head/front/pop operator would then select based on the distribution.
Wyrm Say:
order? Could you give an example of a few lines of code that demonstrate
----- Original Message ----- From: "Joel Young" <jdy@cs.brown.edu> To: "AngleWyrm" <anglewyrm@hotmail.com> Cc: <jdy@cs.brown.edu>; <boost@lists.boost.org> Sent: Friday, September 03, 2004 7:32 PM Subject: Re: C++ Random Container the
usage?
It would be used exactly like a priority queue, except that the next item returned would be selected randomly, either by some weight based on the priority (one case, bout like you have) or based on its order. If it was one from the front then 50 percent chance, 2 from the front 25% and so on. (just an example)
One way this could be accomplished is like so: // Near Top #include <cstdlib> #include <iostream> #include "hat.h" using namespace std; int main() { // some alphabetical names; we mostly want near the beginning string names[7] = { "Amy", "Betty", "Carol", "Debbie", "Ethyl", "Freda", "Gertrude" }; // build a hat of offsets, with a high probability of a low offset hat<int> offsets; float data[7] = { 0.60, 0.20, 0.10, 0.05, 0.03, 0.01, 0.01 }; for( int i=0; i<7; i++){ offsets.put_normalized( i, data[i] ); } // initialize random number generator srand( time(NULL) ); rand(); cout << names[ offsets.get() ] << endl; system("pause"); }
participants (2)
-
AngleWyrm
-
Joel Young