what is the best way to store and count duplicates of an string or integer?
<p>This code explains what I want to do:</p>

<pre><code>unsigned long g_PlayerIP[MAX_AMOUNT_OF_PLAYERS];//save the IP address of each player
int g_max_ip = MAX_CONNECTED_FROM_ONE_IP;

PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect(int playerid)
{
    PlayerLoopList.push_back(playerid);

    char szIP[32];
    GetPlayerIp(playerid,szIP);//get the ip of the player into szIP
    unsigned short explodeIP[4];//declare 4 eight bit variables, to store the exploded ip
    sscanf(szIP, " %d[^.].%d[^.].%d[^.].%d", &amp;explodeIP[0], &amp;explodeIP[1], &amp;explodeIP[2], &amp;explodeIP[3]);//explode ip into 4 pats ranging from 0 to 255
    g_PlayerIP[playerid] = (explodeIP[0] + (explodeIP[1] &lt;&lt; 8) + (explodeIP[2] &lt;&lt; 16) + (explodeIP[3] &lt;&lt; 24));//store the ip as a 32bit integer
    int connected = 0;//variable for counting connected players fron one ip
    for(list &lt;int&gt;::iterator i = PlayerLoopList.begin(); i != PlayerLoopList.end(); ++i)
    {
        if(g_PlayerIP[playerid] == g_PlayerIP[*i])
        {
            ++connected;
        }
    }
    if(connected &gt;= g_max_ip)
    {
        Report(playerid,IP_FLOOD,g_PlayerIP[playerid]);//too many connected from one ip, report it.
    }
    return true;
}
</code></pre>

<p>and seeing this part:</p>

<pre><code>    sscanf(szIP, " %d[^.].%d[^.].%d[^.].%d", &amp;explodeIP[0], &amp;explodeIP[1], &amp;explodeIP[2], &amp;explodeIP[3]);//explode ip into 4 pats ranging from 0 to 255
    g_PlayerIP[playerid] = (explodeIP[0] + (explodeIP[1] &lt;&lt; 8) + (explodeIP[2] &lt;&lt; 16) + (explodeIP[3] &lt;&lt; 24));//store the ip as a 32bit integer
    int connected = 0;//variable for counting connected players fron one ip
    for(list &lt;int&gt;::iterator i = PlayerLoopList.begin(); i != PlayerLoopList.end(); ++i)
    {
        if(g_PlayerIP[playerid] == g_PlayerIP[*i])
        {
            ++connected;
        }
    }
</code></pre>

<p>makes me a bit, well, questioning me about if it can be done faster, there has to be a superb way in c++?</p>
