我正在爲我的客戶端構建一個javascript指示器,他們向我提供了低於他們舊系統的C++代碼。我從來沒有做過C++程序。以下是C++代碼的一部分。我想知道的是
if (it3 != d1Swing.end() && it3->x == h[i].x) --(it1 = it2 = it3);
- (it1 = it2 = it3)是什麼意思?它在javascript中看起來像什麼?在將C++轉換爲javascript時需要幫助
vector<PTPoint::PTIndexPoint> dnSwing;
list<PTPoint::PTIndexPoint> hq, lq;
vector<PTPoint::PTIndexPoint>::iterator it1 = d1Swing.begin(), it2 = d1Swing.begin(), it3 = ++d1Swing.begin();
//
// more code here
//
for (int i = 0; i < period; ++i)
{
while (!hq.empty() && hq.back().y < h[i].y) hq.pop_back();
hq.push_back(h[i]);
while (!lq.empty() && lq.back().y > l[i].y) lq.pop_back();
lq.push_back(l[i]);
if (it3 != d1Swing.end() && it3->x == h[i].x) --(it1 = it2 = it3);
//
// more code here
//
}
//
// more code here
//
p->swap(dnSwing);
在此先感謝。
tslin
你最好發佈最初的C++代碼,以及將您嘗試的翻譯分別發佈到JavaScript。 –
不要翻譯。相反,找出代碼的作用,並使用JavaScript功能複製行爲。 – Rakete1111
謝謝大家的建議。我已經更新了我的問題。 @ Cheersandhth.-Alf我刪除了javascript部分,因爲它沒有必要,也沒有涉及到這個問題。 – tslin