无法访问滑动窗口中的值?

时间:2017-11-28 10:24:00

标签: c++ vector iterator sliding-window

我目前正在为vector<double>实现滑动窗口功能。问题是我似乎不能cout价值观?当我输出它时,我似乎得到了记忆位置,而不是实际值..

我需要处理窗口所包含的数据,因此对值的访问将是整洁的。

typedef double SAMPLE;
std::vector<std::vector<SAMPLES> > loaded_files;
//Some init
std::vector<SAMPLE>::iterator it;
for (it = loaded_file.samples[0].begin() ; (it + (NUM_SECONDS*SAMPLE_RATE)) != loaded_file.samples[0].end(); ++it)
{
     auto window = *it;
     std::cout << "printing the window!" << std::endl;
     std::cout << &(window) << std::endl; // prints out memory location?
}

1 个答案:

答案 0 :(得分:1)

每次打印窗口内容时,都需要遍历窗口本身。这可以通过更改const tables = document.querySelectorAll('.wikitable'); const table = tables[1]; const tr = table.querySelectorAll('tbody tr'); var output = []; for(var i = 0; i < tr.length; i++){ const theTD = Array.from(tr[i].querySelectorAll('td')); const theText = theTD.map(item => item.innerText); if(theText.length > 0 ){ output.push(theText); } } 循环的内容来完成,如下所示:

for

请注意,窗口的宽度为typedef double SAMPLE; std::vector<<SAMPLES>> loaded_files; //Some init std::vector<SAMPLE>::iterator it; for (it = loaded_file.samples[0].begin(); (it + (NUM_SECONDS*SAMPLE_RATE)) != loaded_file.samples[0].end(); ++it) { std::cout << "printing the window!" << std::endl; std::vector<SAMPLE>::iterator wit; // window iterator for (wit = it; wit != it + (NUM_SECONDS*SAMPLE_RATE); ++wit) { std::cout << *wit << ','; } std::cout << std::endl; } 。这可以存储在(NUM_SECONDS*SAMPLE_RATE)或类似的变量中,以帮助提高可读性。