本文整理汇总了C++中nsTArray::InsertElementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::InsertElementAt方法的具体用法?C++ nsTArray::InsertElementAt怎么用?C++ nsTArray::InsertElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::InsertElementAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Invalidate
void
nsWindow::BringToTop()
{
if (!sTopWindows.IsEmpty()) {
if (nsIWidgetListener* listener = sTopWindows[0]->GetWidgetListener())
listener->WindowDeactivated();
}
sTopWindows.RemoveElement(this);
sTopWindows.InsertElementAt(0, this);
if (mWidgetListener)
mWidgetListener->WindowActivated();
Invalidate(sVirtualBounds);
}
示例2: event
void
nsWindow::BringToTop()
{
if (!sTopWindows.IsEmpty()) {
nsGUIEvent event(true, NS_DEACTIVATE, sTopWindows[0]);
(*mEventCallback)(&event);
}
sTopWindows.RemoveElement(this);
sTopWindows.InsertElementAt(0, this);
nsGUIEvent event(true, NS_ACTIVATE, this);
(*mEventCallback)(&event);
Invalidate(sVirtualBounds);
}
示例3: getNumberOfCameras
nsresult
ICameraControl::GetListOfCameras(nsTArray<nsString>& aList)
{
int32_t count = android::Camera::getNumberOfCameras();
DOM_CAMERA_LOGI("getListOfCameras : getNumberOfCameras() returned %d\n", count);
if (count <= 0) {
aList.Clear();
return NS_OK;
}
// Allocate 2 extra slots to reserve space for 'front' and 'back' cameras
// at the front of the array--we will collapse any empty slots below.
aList.SetLength(2);
uint32_t extraIdx = 2;
bool gotFront = false;
bool gotBack = false;
while (count--) {
nsCString cameraName;
nsresult result = GetCameraName(count, cameraName);
if (result != NS_OK) {
continue;
}
// The first camera we find named 'back' gets slot 0; and the first
// we find named 'front' gets slot 1. All others appear after these.
if (cameraName.EqualsLiteral("back")) {
CopyUTF8toUTF16(cameraName, aList[0]);
gotBack = true;
} else if (cameraName.EqualsLiteral("front")) {
CopyUTF8toUTF16(cameraName, aList[1]);
gotFront = true;
} else {
CopyUTF8toUTF16(cameraName, *aList.InsertElementAt(extraIdx));
extraIdx++;
}
}
if (!gotFront) {
aList.RemoveElementAt(1);
}
if (!gotBack) {
aList.RemoveElementAt(0);
}
return NS_OK;
}
示例4: Append
//.........这里部分代码省略.........
mSkipBytes = mElement.mSize.mValue;
mState = SKIP_DATA;
mNextState = READ_ELEMENT_ID;
break;
}
break;
case READ_VINT: {
unsigned char c = *p++;
uint32_t mask;
mVInt.mLength = VIntLength(c, &mask);
mVIntLeft = mVInt.mLength - 1;
mVInt.mValue = mVIntRaw ? c : c & ~mask;
mState = READ_VINT_REST;
break;
}
case READ_VINT_REST:
if (mVIntLeft) {
mVInt.mValue <<= 8;
mVInt.mValue |= *p++;
mVIntLeft -= 1;
} else {
mState = mNextState;
}
break;
case READ_TIMECODESCALE:
MOZ_ASSERT(mGotTimecodeScale);
mTimecodeScale = mVInt.mValue;
mState = READ_ELEMENT_ID;
break;
case READ_CLUSTER_TIMECODE:
mClusterTimecode = mVInt.mValue;
mState = READ_ELEMENT_ID;
break;
case READ_BLOCK_TIMECODE:
if (mBlockTimecodeLength) {
mBlockTimecode <<= 8;
mBlockTimecode |= *p++;
mBlockTimecodeLength -= 1;
} else {
// It's possible we've parsed this data before, so avoid inserting
// duplicate WebMTimeDataOffset entries.
{
ReentrantMonitorAutoEnter mon(aReentrantMonitor);
int64_t endOffset = mBlockOffset + mBlockSize +
mElement.mID.mLength + mElement.mSize.mLength;
uint32_t idx = aMapping.IndexOfFirstElementGt(endOffset);
if (idx == 0 || aMapping[idx - 1] != endOffset) {
// Don't insert invalid negative timecodes.
if (mBlockTimecode >= 0 || mClusterTimecode >= uint16_t(abs(mBlockTimecode))) {
MOZ_ASSERT(mGotTimecodeScale);
uint64_t absTimecode = mClusterTimecode + mBlockTimecode;
absTimecode *= mTimecodeScale;
WebMTimeDataOffset entry(endOffset, absTimecode, mLastInitStartOffset,
mClusterOffset, mClusterEndOffset);
aMapping.InsertElementAt(idx, entry);
}
}
}
// Skip rest of block header and the block's payload.
mBlockSize -= mVInt.mLength;
mBlockSize -= BLOCK_TIMECODE_LENGTH;
mSkipBytes = uint32_t(mBlockSize);
mState = SKIP_DATA;
mNextState = READ_ELEMENT_ID;
}
break;
case SKIP_DATA:
if (mSkipBytes) {
uint32_t left = aLength - (p - aBuffer);
left = std::min(left, mSkipBytes);
p += left;
mSkipBytes -= left;
}
if (!mSkipBytes) {
mBlockEndOffset = mCurrentOffset + (p - aBuffer);
mState = mNextState;
}
break;
case CHECK_INIT_FOUND:
if (mSkipBytes) {
uint32_t left = aLength - (p - aBuffer);
left = std::min(left, mSkipBytes);
p += left;
mSkipBytes -= left;
}
if (!mSkipBytes) {
if (mInitEndOffset < 0) {
mInitEndOffset = mCurrentOffset + (p - aBuffer);
mBlockEndOffset = mCurrentOffset + (p - aBuffer);
}
mState = READ_ELEMENT_ID;
}
break;
}
}
NS_ASSERTION(p == aBuffer + aLength, "Must have parsed to end of data.");
mCurrentOffset += aLength;
}
示例5: addStripSpace
nsresult txStylesheet::addStripSpace(
txStripSpaceItem* aStripSpaceItem,
nsTArray<txStripSpaceTest*>& aFrameStripSpaceTests) {
int32_t testCount = aStripSpaceItem->mStripSpaceTests.Length();
for (; testCount > 0; --testCount) {
txStripSpaceTest* sst = aStripSpaceItem->mStripSpaceTests[testCount - 1];
double priority = sst->getDefaultPriority();
int32_t i, frameCount = aFrameStripSpaceTests.Length();
for (i = 0; i < frameCount; ++i) {
if (aFrameStripSpaceTests[i]->getDefaultPriority() < priority) {
break;
}
}
if (!aFrameStripSpaceTests.InsertElementAt(i, sst)) {
return NS_ERROR_OUT_OF_MEMORY;
}
aStripSpaceItem->mStripSpaceTests.RemoveElementAt(testCount - 1);
}
return NS_OK;
}
示例6: Append
//.........这里部分代码省略.........
mVInt <<= 8;
mVInt |= *p++;
mVIntLeft -= 1;
} else {
mState = mNextState;
}
break;
case TIMECODE_SYNC:
if (*p++ != TIMECODE_ID) {
p -= 1;
mState = CLUSTER_SYNC;
break;
}
mClusterTimecode = 0;
mState = READ_VINT;
mNextState = READ_CLUSTER_TIMECODE;
break;
case READ_CLUSTER_TIMECODE:
if (mVInt) {
mClusterTimecode <<= 8;
mClusterTimecode |= *p++;
mVInt -= 1;
} else {
mState = ANY_BLOCK_SYNC;
}
break;
case ANY_BLOCK_SYNC: {
unsigned char c = *p++;
if (c == BLOCKGROUP_ID) {
mState = READ_VINT;
mNextState = ANY_BLOCK_SYNC;
} else if (c == SIMPLEBLOCK_ID || c == BLOCK_ID) {
mBlockOffset = mCurrentOffset + (p - aBuffer) - 1;
mState = READ_VINT;
mNextState = READ_BLOCK;
} else {
uint32_t length = VIntLength(c, nullptr);
if (length == 4) {
p -= 1;
mState = CLUSTER_SYNC;
} else {
mState = READ_VINT;
mNextState = SKIP_ELEMENT;
}
}
break;
}
case READ_BLOCK:
mBlockSize = mVInt;
mBlockTimecode = 0;
mBlockTimecodeLength = 2;
mState = READ_VINT;
mNextState = READ_BLOCK_TIMECODE;
break;
case READ_BLOCK_TIMECODE:
if (mBlockTimecodeLength) {
mBlockTimecode <<= 8;
mBlockTimecode |= *p++;
mBlockTimecodeLength -= 1;
} else {
// It's possible we've parsed this data before, so avoid inserting
// duplicate nsWebMTimeDataOffset entries.
{
ReentrantMonitorAutoEnter mon(aReentrantMonitor);
uint32_t idx;
if (!aMapping.GreatestIndexLtEq(mBlockOffset, idx)) {
nsWebMTimeDataOffset entry(mBlockOffset, mClusterTimecode + mBlockTimecode);
aMapping.InsertElementAt(idx, entry);
}
}
// Skip rest of block header and the block's payload.
mBlockSize -= mVIntLength;
mBlockSize -= 2;
mSkipBytes = uint32_t(mBlockSize);
mState = SKIP_DATA;
mNextState = ANY_BLOCK_SYNC;
}
break;
case SKIP_DATA:
if (mSkipBytes) {
uint32_t left = aLength - (p - aBuffer);
left = NS_MIN(left, mSkipBytes);
p += left;
mSkipBytes -= left;
} else {
mState = mNextState;
}
break;
case SKIP_ELEMENT:
mSkipBytes = uint32_t(mVInt);
mState = SKIP_DATA;
mNextState = ANY_BLOCK_SYNC;
break;
}
}
NS_ASSERTION(p == aBuffer + aLength, "Must have parsed to end of data.");
mCurrentOffset += aLength;
}