当前位置: 首页>>代码示例>>C++>>正文


C++ nsTArray::InsertElementsAt方法代码示例

本文整理汇总了C++中nsTArray::InsertElementsAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::InsertElementsAt方法的具体用法?C++ nsTArray::InsertElementsAt怎么用?C++ nsTArray::InsertElementsAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsTArray的用法示例。


在下文中一共展示了nsTArray::InsertElementsAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: autoFree

// Copies a subscription key buffer into an array.
nsresult
CopySubscriptionKeyToArray(nsIPushSubscription* aSubscription,
                           const nsAString& aKeyName,
                           nsTArray<uint8_t>& aKey)
{
  uint8_t* keyBuffer = nullptr;
  AutoFreeKeyBuffer autoFree(&keyBuffer);

  uint32_t keyLen;
  nsresult rv = aSubscription->GetKey(aKeyName, &keyLen, &keyBuffer);
  if (NS_FAILED(rv)) {
    return rv;
  }
  if (!aKey.SetCapacity(keyLen, fallible) ||
      !aKey.InsertElementsAt(0, keyBuffer, keyLen, fallible)) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  return NS_OK;
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:20,代码来源:PushManager.cpp

示例2: 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;
}
开发者ID:rickysarraf,项目名称:icedove,代码行数:23,代码来源:nsAutoSyncState.cpp


注:本文中的nsTArray::InsertElementsAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。