1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Migrate to STL containers/algorithms.

This commit is contained in:
Ilya Zhuravlev 2012-12-20 21:19:49 +04:00 committed by kwolekr
parent e204bedf1d
commit 6a1670dbc3
63 changed files with 1330 additions and 1417 deletions

View file

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "threads.h"
#include "gettime.h"
#include "exceptions.h"
#include <map>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@ -165,7 +166,7 @@ struct DebugStack
int stack_max_i; // Highest i that was seen
};
extern core::map<threadid_t, DebugStack*> g_debug_stacks;
extern std::map<threadid_t, DebugStack*> g_debug_stacks;
extern JMutex g_debug_stacks_mutex;
extern void debug_stacks_init();
@ -205,42 +206,42 @@ public:
void add(u16 command)
{
core::map<u16, u16>::Node *n = m_packets.find(command);
if(n == NULL)
std::map<u16, u16>::iterator n = m_packets.find(command);
if(n == m_packets.end())
{
m_packets[command] = 1;
}
else
{
n->setValue(n->getValue()+1);
n->second++;
}
}
void clear()
{
for(core::map<u16, u16>::Iterator
i = m_packets.getIterator();
i.atEnd() == false; i++)
for(std::map<u16, u16>::iterator
i = m_packets.begin();
i != m_packets.end(); ++i)
{
i.getNode()->setValue(0);
i->second = 0;
}
}
void print(std::ostream &o)
{
for(core::map<u16, u16>::Iterator
i = m_packets.getIterator();
i.atEnd() == false; i++)
for(std::map<u16, u16>::iterator
i = m_packets.begin();
i != m_packets.end(); ++i)
{
o<<"cmd "<<i.getNode()->getKey()
<<" count "<<i.getNode()->getValue()
o<<"cmd "<<i->first
<<" count "<<i->second
<<std::endl;
}
}
private:
// command, count
core::map<u16, u16> m_packets;
std::map<u16, u16> m_packets;
};
/*