本文整理汇总了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);
}
示例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);
}
示例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");
}