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


C++ SortedVector::clear方法代码示例

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


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

示例1: closeGlobalTransactionImpl

void Composer::closeGlobalTransactionImpl(bool synchronous) {
    sp<ISurfaceComposer> sm(ComposerService::getComposerService());

    Vector<ComposerState> transaction;
    Vector<DisplayState> displayTransaction;
    uint32_t flags = 0;

    { // scope for the lock
        Mutex::Autolock _l(mLock);
        transaction = mComposerStates;
        mComposerStates.clear();

        displayTransaction = mDisplayStates;
        mDisplayStates.clear();

        if (synchronous || mForceSynchronous) {
            flags |= ISurfaceComposer::eSynchronous;
        }
        if (mAnimation) {
            flags |= ISurfaceComposer::eAnimation;
        }

        mForceSynchronous = false;
        mAnimation = false;
    }

   sm->setTransactionState(transaction, displayTransaction, flags);
}
开发者ID:Android4SAM,项目名称:platform_frameworks_native,代码行数:28,代码来源:SurfaceComposerClient.cpp

示例2: closeGlobalTransactionImpl

void Composer::closeGlobalTransactionImpl(bool synchronous) {
    sp<ISurfaceComposer> sm(ComposerService::getComposerService());

    Vector<ComposerState> transaction;
    Vector<DisplayState> displayTransaction;
    uint32_t flags = 0;

    { // scope for the lock
        Mutex::Autolock _l(mLock);
        mForceSynchronous |= synchronous;
        if (!mTransactionNestCount) {
            ALOGW("At least one call to closeGlobalTransaction() was not matched by a prior "
                    "call to openGlobalTransaction().");
        } else if (--mTransactionNestCount) {
            return;
        }

        transaction = mComposerStates;
        mComposerStates.clear();

        displayTransaction = mDisplayStates;
        mDisplayStates.clear();

        if (mForceSynchronous) {
            flags |= ISurfaceComposer::eSynchronous;
        }
        if (mAnimation) {
            flags |= ISurfaceComposer::eAnimation;
        }

        mForceSynchronous = false;
        mAnimation = false;
    }

   sm->setTransactionState(transaction, displayTransaction, flags);
}
开发者ID:GeyerA,项目名称:platform_frameworks_native,代码行数:36,代码来源:SurfaceComposerClient.cpp

示例3: main

int main()
{
  Vector<int> v;

  v.addElement(4);
  v.addElement(5);
  v.addElement(6);

  assert(v.elementAt(0) == 4);
  assert(v.elementAt(2) == 6);

  v.removeElement(5);

  assert(v.elementAt(1) == 6);

  v.insertElementAt(100, 2);

  assert(v.elementAt(2) == 100);

  printf("passed: Vector\n");

  
  
  SortedVector<int> sv;

  sv.addElement(7);
  assert(sv.elementAt(0) == 7);

  sv.addElement(6);
  assert(sv.elementAt(0) == 6);
  assert(sv.elementAt(1) == 7);

  sv.addElement(9);
  assert(sv.elementAt(2) == 9);

  sv.addElement(3);
  assert(sv.elementAt(0) == 3);
  assert(sv.elementAt(3) == 9);

  sv.addElement(1);

  sv.removeElement(6);

  assert(sv.size() == 4);
  assert(sv.elementAt(3) == 9);
  assert(sv.indexOf(9) == 3);
  assert(sv.indexOf(1) == 0);

  int numbers = 100;
  while(numbers--){
    sv.addElement(numbers%2 ? -numbers : numbers);
  }

  int maxel = -1000000;
  for (int idx = 0; idx < sv.size(); idx++) {
    //printf("%d, ", sv.elementAt(idx));
    if (sv.elementAt(idx) < maxel) assert(!"sv order failed");
    maxel = sv.elementAt(idx);
  }

  assert(sv.indexOf(10000) == -1);
  assert(sv.indexOf(-10000) == -1);
  
  sv.clear();

  assert(sv.size() == 0);

  sv.addElement(0);
  sv.addElement(2);
  sv.addElement(2);
  sv.addElement(2);

  assert(sv.size() == 4);
  // undefined assert(sv.indexOf(2) == 1);

  assert(sv.elementAt(0) == 0);
  assert(sv.elementAt(3) == 2);


  printf("passed: SortedVector\n");

}
开发者ID:CS-svnmirror,项目名称:colorer,代码行数:82,代码来源:test-vector.cpp


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