本文整理汇总了C++中nsTArray::RemoveElementsAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::RemoveElementsAt方法的具体用法?C++ nsTArray::RemoveElementsAt怎么用?C++ nsTArray::RemoveElementsAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::RemoveElementsAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
ParseString(const nsACString& aSource, char aDelimiter,
nsTArray<nsCString>& aArray)
{
int32_t start = 0;
int32_t end = aSource.Length();
uint32_t oldLength = aArray.Length();
for (;;) {
int32_t delimiter = aSource.FindChar(aDelimiter, start);
if (delimiter < 0) {
delimiter = end;
}
if (delimiter != start) {
if (!aArray.AppendElement(Substring(aSource, start, delimiter - start))) {
aArray.RemoveElementsAt(oldLength, aArray.Length() - oldLength);
return false;
}
}
if (delimiter == end)
break;
start = ++delimiter;
if (start == end)
break;
}
return true;
}
示例2: FindCharInReadable
bool
ParseString(const nsACString& aSource, char aDelimiter,
nsTArray<nsCString>& aArray)
{
nsACString::const_iterator start, end;
aSource.BeginReading(start);
aSource.EndReading(end);
uint32_t oldLength = aArray.Length();
for (;;)
{
nsACString::const_iterator delimiter = start;
FindCharInReadable(aDelimiter, delimiter, end);
if (delimiter != start)
{
if (!aArray.AppendElement(Substring(start, delimiter)))
{
aArray.RemoveElementsAt(oldLength, aArray.Length() - oldLength);
return false;
}
}
if (delimiter == end)
break;
start = ++delimiter;
if (start == end)
break;
}
return true;
}
示例3:
PRBool
ParseString(const nsACString& aSource, char aDelimiter,
nsTArray<nsCString>& aArray)
{
PRInt32 start = 0;
PRInt32 end = aSource.Length();
PRUint32 oldLength = aArray.Length();
for (;;) {
PRInt32 delimiter = aSource.FindChar(aDelimiter, start);
if (delimiter < 0) {
delimiter = end;
}
if (delimiter != start) {
if (!aArray.AppendElement(Substring(aSource, start, delimiter - start))) {
aArray.RemoveElementsAt(oldLength, aArray.Length() - oldLength);
return PR_FALSE;
}
}
if (delimiter == end)
break;
start = ++delimiter;
if (start == end)
break;
}
return PR_TRUE;
}
示例4: AudioChannelsUpMix
void
AudioNodeStream::UpMixDownMixChunk(const AudioChunk* aChunk,
uint32_t aOutputChannelCount,
nsTArray<const void*>& aOutputChannels,
nsTArray<float>& aDownmixBuffer)
{
static const float silenceChannel[WEBAUDIO_BLOCK_SIZE] = {0.f};
aOutputChannels.AppendElements(aChunk->mChannelData);
if (aOutputChannels.Length() < aOutputChannelCount) {
if (mChannelInterpretation == ChannelInterpretation::Speakers) {
AudioChannelsUpMix(&aOutputChannels, aOutputChannelCount, nullptr);
NS_ASSERTION(aOutputChannelCount == aOutputChannels.Length(),
"We called GetAudioChannelsSuperset to avoid this");
} else {
// Fill up the remaining aOutputChannels by zeros
for (uint32_t j = aOutputChannels.Length(); j < aOutputChannelCount; ++j) {
aOutputChannels.AppendElement(silenceChannel);
}
}
} else if (aOutputChannels.Length() > aOutputChannelCount) {
if (mChannelInterpretation == ChannelInterpretation::Speakers) {
nsAutoTArray<float*,GUESS_AUDIO_CHANNELS> outputChannels;
outputChannels.SetLength(aOutputChannelCount);
aDownmixBuffer.SetLength(aOutputChannelCount * WEBAUDIO_BLOCK_SIZE);
for (uint32_t j = 0; j < aOutputChannelCount; ++j) {
outputChannels[j] = &aDownmixBuffer[j * WEBAUDIO_BLOCK_SIZE];
}
AudioChannelsDownMix(aOutputChannels, outputChannels.Elements(),
aOutputChannelCount, WEBAUDIO_BLOCK_SIZE);
aOutputChannels.SetLength(aOutputChannelCount);
for (uint32_t j = 0; j < aOutputChannels.Length(); ++j) {
aOutputChannels[j] = outputChannels[j];
}
} else {
// Drop the remaining aOutputChannels
aOutputChannels.RemoveElementsAt(aOutputChannelCount,
aOutputChannels.Length() - aOutputChannelCount);
}
}
}
示例5: SortSubQueueBasedOnStrategy
// This method is a hack to prioritize newly inserted messages,
// without changing the size of the queue. It is required since
// we cannot sort ranges in nsTArray.
nsresult nsAutoSyncState::SortSubQueueBasedOnStrategy(nsTArray<nsMsgKey> &aQueue,
uint32_t aStartingOffset)
{
NS_ASSERTION(aStartingOffset < aQueue.Length(), "*** Starting offset is out of range");
// Copy already downloaded messages into a temporary queue,
// we want to exclude them from the sort.
nsTArray<nsMsgKey> tmpQ;
tmpQ.AppendElements(aQueue.Elements(), aStartingOffset);
// Remove already downloaded messages and sort the resulting queue
aQueue.RemoveElementsAt(0, aStartingOffset);
nsresult rv = SortQueueBasedOnStrategy(aQueue);
// copy excluded messages back
aQueue.InsertElementsAt(0, tmpQ);
return rv;
}