簡體   English   中英

我如何在std :: vector中push_back ShortBuffer數據 <short> ?

[英]How can i push_back ShortBuffer data in std::vector<short>?

我在ShortBuffer變量中有數據。

我想在std::vector<short> input變量中push_back 我使用了以下代碼,但由於循環時間長,應用程序凍結。

還有另一種方法嗎?

ShortBuffer *pBuffer1 = pData->AsShortBufferN();

std::vector<short> input(BUFFER_SIZE);

for (int i = 0; i < BUFFER_SIZE-1; ++i) {
    short out1;
    pBuffer1->Get(out1);
    input.push_back(out1);
}

如果ShortBuffer我認為的樣子 ,這應該可以工作:

// Allocate enough space to avoid push_back
std::vector<short> input(BUFFER_SIZE, 0);
// Let the GetArray method do the copying
pBuffer1->GetArray(&input[0], 0, BUFFER_SIZE);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM