Hello ,
I have map of the following type:
typedef map < int, vectorofInts > ,
Now the map has finite size. Each user when he registers, he will be allocated a key.
Lets say the map size is 4.
U1 will be allocated in K1.
next U2 on K2, U3 on K3, U4 on K4.
Later it happens in round robin way, U5 with K1 etc.
Meantime, U1 may dropoff, in that case U6, needs to be allocated K1. to keep uniformity.
Any feedback or idea regarding this alogrithm and optimum way to implement. Sorry that i am not c++ stl expert, working occasionally on this.
This is somewhat smaller version of the legacy program i have written to the one from the legacy code. Sorry for my poor c++ STL skills. Looking for the AddNewUser() function implementation.
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef vector<int> int_vect;
typedef pair < int, int_vect > IntPair ;
typedef map<int,int_vect> outerarray;
outerarray outarr;
int_vect v0;
int AddNewUser()
{
}
int main()
{
// vector of users
int_vect v0;
outarr.insert(std::make_pair(1, v0));
outarr.insert(std::make_pair(2, v0));
outarr.insert(std::make_pair(3, v0));
outarr.insert(std::make_pair(4, v0));
// Add a new User
AddNewUser();
}
thanks
pdk