Click here to Skip to main content
15,887,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all,

I'm constructing a javascript indicator for my client and they gave me below C++ code from their old system. I have never done C++ program before. Below is the part of the C++ code. What I want to know is in the line
if (it3 != d1Swing.end() && it3->x == h[i].x) --(it1 = it2 = it3);
what is the meaning of --(it1 = it2 = it3)? What will it looks like in 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);


Thanks in advanced.
tslin

What I have tried:

I've googled for a long time but search include special characters and those characters were used in most of the languages.
Posted
Updated 9-Jan-17 21:44pm
v2
Comments
KarstenK 10-Jan-17 3:45am    
Tip: use braces and new lines after the while and the if command to make the code clearer.

1 solution

Quote:
what is the meaning of --(it1 = it2 = it3)? What will it looks like in javascript?

  1. assign it3 to it2.
  2. assign it2 to it1.
  3. decrement it1.

You may rewrite it (C++ code) this way:
C++
{
  it2 = it3;
  it1 = it2;
  it1 = it1 - 1;
}

I suppose Javascript code would be very similar.
 
Share this answer
 
Comments
tslin89 10-Jan-17 4:44am    
Thanks a lot for the answer.
CPallini 10-Jan-17 6:09am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900