本文整理汇总了C++中SmallPtrSetImpl::isSmall方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallPtrSetImpl::isSmall方法的具体用法?C++ SmallPtrSetImpl::isSmall怎么用?C++ SmallPtrSetImpl::isSmall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmallPtrSetImpl
的用法示例。
在下文中一共展示了SmallPtrSetImpl::isSmall方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
SmallPtrSetImpl::SmallPtrSetImpl(const SmallPtrSetImpl& that) {
NumElements = that.NumElements;
NumTombstones = 0;
if (that.isSmall()) {
CurArraySize = that.CurArraySize;
CurArray = &SmallArray[0];
memcpy(CurArray, that.CurArray, sizeof(void*)*CurArraySize);
} else {
CurArraySize = that.NumElements < 64 ? 128 : that.NumElements*2;
CurArray = new void*[CurArraySize+1];
memset(CurArray, -1, CurArraySize*sizeof(void*));
// The end pointer, always valid, is set to a valid element to help the
// iterator.
CurArray[CurArraySize] = 0;
// Copy over all valid entries.
for (void **BucketPtr = that.CurArray, **E = that.CurArray+CurArraySize;
BucketPtr != E; ++BucketPtr) {
// Copy over the element if it is valid.
void *Elt = *BucketPtr;
if (Elt != getTombstoneMarker() && Elt != getEmptyMarker())
*const_cast<void**>(FindBucketFor(Elt)) = Elt;
}
}
}
示例2: assert
SmallPtrSetImpl::SmallPtrSetImpl(const SmallPtrSetImpl& that) {
// If we're becoming small, prepare to insert into our stack space
if (that.isSmall()) {
CurArray = &SmallArray[0];
// Otherwise, allocate new heap space (unless we were the same size)
} else {
CurArray = (const void**)malloc(sizeof(void*) * (that.CurArraySize+1));
assert(CurArray && "Failed to allocate memory?");
}
// Copy over the new array size
CurArraySize = that.CurArraySize;
// Copy over the contents from the other set
memcpy(CurArray, that.CurArray, sizeof(void*)*(CurArraySize+1));
NumElements = that.NumElements;
NumTombstones = that.NumTombstones;
}