2007-05-17 16:45:03 +02:00
|
|
|
#include <vector>
|
|
|
|
|
#include <stdlib.h>
|
2007-05-25 10:02:50 +02:00
|
|
|
#include "ns3/object.h"
|
2007-05-17 16:45:03 +02:00
|
|
|
|
|
|
|
|
using namespace ns3;
|
|
|
|
|
|
2007-05-25 10:02:50 +02:00
|
|
|
class BaseA : public ns3::Object
|
2007-05-17 16:45:03 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2007-05-25 10:56:03 +02:00
|
|
|
static const ns3::InterfaceId iid;
|
2007-05-17 16:45:03 +02:00
|
|
|
BaseA ()
|
|
|
|
|
{
|
|
|
|
|
SetInterfaceId (BaseA::iid);
|
|
|
|
|
}
|
|
|
|
|
virtual void Dispose (void) {}
|
|
|
|
|
};
|
|
|
|
|
|
2007-05-25 10:56:03 +02:00
|
|
|
const ns3::InterfaceId BaseA::iid =
|
2007-05-25 10:02:50 +02:00
|
|
|
ns3::MakeInterfaceId ("BaseABench", Object::iid);
|
2007-05-17 16:45:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
int nobjects = atoi (argv[1]);
|
|
|
|
|
int nswaps = atoi (argv[2]);
|
|
|
|
|
|
|
|
|
|
std::vector< Ptr<BaseA> > objlist;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < nobjects; ++i)
|
2007-06-04 16:32:37 +02:00
|
|
|
objlist.push_back (Create<BaseA> ());
|
2007-05-17 16:45:03 +02:00
|
|
|
|
|
|
|
|
for (int swapCounter = nswaps; swapCounter; --swapCounter)
|
|
|
|
|
{
|
|
|
|
|
int x1 = swapCounter % nobjects;
|
|
|
|
|
int x2 = (swapCounter+1) % nobjects;
|
|
|
|
|
Ptr<BaseA> obj1 = objlist[x1];
|
|
|
|
|
Ptr<BaseA> obj2 = objlist[x2];
|
|
|
|
|
objlist[x2] = obj1;
|
|
|
|
|
objlist[x1] = obj2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|