即時工作與c + +和NS3。 所以我想排序結構的向量與stl函數排序,所以我會發布我的頭文件,我的向量所在,我會解釋我想要做什麼。如何爲我的論文命令一個向量結構
#include "ns3/net-device.h"
#include "ns3/object.h"
#include "ns3/log.h"
#include <vector>
#include <stdint.h>
#include "miscellaneous.h"
namespace ns3 {
/**
* \brief The UeRecord class is developed in order to store at the eNodeB
* all information (such as feedback cqi, mac address etc...) of a UE registered
* into that eNodeB. All UE records are managed by the UeManager class
*/
class UeRecord : public Object
{
public:
UeRecord();
~UeRecord();
/**
* \brief CqiFeedbacks represents a list of CQI feedbacks
* sent by the UE. The downlink packet scheduler of
* the eNB uses these values to assign accordingly
* radio resources.
*/
/**
* \brief a list of CQI feedbacks
*/
typedef std::vector<struct CqiFeedback> CqiFeedbacks;
/**
* \brief Creates a ue record of the UE registered into the eNB
* \param ue the pointer of the ue device
* \param enb the pointer of the enb device
*/
UeRecord (Ptr<NetDevice> ue, Ptr<NetDevice> enb);
/**
* \brief Set the UE of the record
* \param ue the pointer of the ue device
*/
void SetUe (Ptr<NetDevice> ue);
/**
* \brief Get the UE of the record
* \returns the pointer of the UE
*/
Ptr<NetDevice> GetUe (void);
/**
* \brief Set the eNB of the record
* \param enb the pointer of the enb device
*/
void SetEnb (Ptr<NetDevice> enb);
/**
* \brief Get the eNB of the record
* \returns the pointer of the eNB
*/
Ptr<NetDevice> GetEnb (void);
/**
* \brief Set CQI feedbacks of the registered UE
* \param cqiFeedbacks a list of CQI feedback
*/
void SetCqiFeedbacks (CqiFeedbacks cqiFeedbacks);
/**
* \brief Get CQI feedbacks of the registered UE
* \returns a list of CQI feedback
*/
CqiFeedbacks GetCqiFeedbacks (void);
public:
friend bool operator > (const struct CqiFeedback &a, const struct CqiFeedback &b);
inline bool operator > (const struct CqiFeedback &a, const struct CqiFeedback &b)
{
if(a.m_cqi>b.mcqi) return true;
return false;
}
private:
Ptr<NetDevice> m_ue;
Ptr<NetDevice> m_enb;
CqiFeedbacks m_cqiFeedbacks;
};
的結構是這
struct CqiFeedback
{
/** the sub channel */
int m_subChannelId;
/** the cqi feedback */
int m_cqi;
};
我想以降序由m_cqi參數矢量m_cqiFeedbacks,包含在頭文件miscellaneous.h內部 結構體進行排序。 所以我嘗試過載在前面的方式操作>但是我得到這個錯誤:
debug/ns3/ue-record.h:121: error: ‘bool ns3::UeRecord::operator>(const CqiFeedback&, const CqiFeedback&)’ must take exactly one argument
我不明白什麼是錯的! 可能你幫我請,我試圖讀取前面的討論,但我沒有意識到很好的問題是什麼....
「服務員,更換
結構向量請!「 –
與問題無關,但您可以在比較函數中「返回a.m_cqi> b.mcqi;'。 – juanchopanza
@KerrekSB:哈哈我的英雄 –