C++ C++;在OMNET+中编码+;

C++ C++;在OMNET+中编码+;,c++,omnet++,C++,Omnet++,有人能告诉我如何在OMNET++中以不同的方式编写此代码吗 while(outGate==port){ outGate = intuniform(0, n-1); } 另一个: void Txc15::forwardMessage (TicTocMsg15 *msg, int port) { // Increment hop count. msg->setHopCount(msg->getHopCount()+1); int outGate, n

有人能告诉我如何在
OMNET++
中以不同的方式编写此代码吗

while(outGate==port){             
    outGate = intuniform(0, n-1);
}
另一个:

void Txc15::forwardMessage (TicTocMsg15 *msg, int port)
{
// Increment hop count.
msg->setHopCount(msg->getHopCount()+1);
int outGate, n = gateSize("gate");

if(port != -1){
    //we enter here only if the message is forwarded
    outGate=port;
    //checking for more than one gate!
    if (n>1)
    {
        /**
       * It will exit from the while cycle only if the intuniform function
       * will choose a port different from the incoming one.
       */
        while(outGate==port){

            outGate = intuniform(0, n-1);
        }
    }
    EV << "Forwarding message " << msg << " on gate[" << outGate << "]\n";
    //forward the message provided following the conditions.
    send(msg, "gate$o", outGate);
}else{
    //port is equal to -1 if and only if the message in newly generated
    outGate = intuniform(0, n-1); // Randomly choose a gate.
    EV << "Forwarding message " << msg << " on gate[" << outGate << "]\n";
    send(msg, "gate$o", outGate);
} 
}
void Txc15::forwardMessage(TicTocMsg15*msg,int端口)
{
//增加跳数。
msg->setHopCount(msg->getHopCount()+1);
int outGate,n=门尺寸(“门”);
如果(端口!=-1){
//只有在邮件被转发时,我们才进入此处
出口=端口;
//检查多个闸门!
如果(n>1)
{
/**
*仅当intuniform函数
*将选择与传入端口不同的端口。
*/
while(outGate==端口){
outGate=肠管状(0,n-1);
}
}

EV这一个具有有限的运行时成本:

outGate = intuniform(0, n-2);
if (outgate >= port) outgate++;
请注意,均匀随机数是从0到n-2(不是n-1)的范围内抽取的。如果
outgate
大于或等于
port
,我们将其增加1。这有效地导致了0..n-1范围内的随机均匀数,但它不能与port相同。

您所说的“不同”是什么意思?更短?更少出错?更少重复?其他?