本文整理汇总了C++中Capacity函数的典型用法代码示例。如果您正苦于以下问题:C++ Capacity函数的具体用法?C++ Capacity怎么用?C++ Capacity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Capacity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// private void EnsureCapacity(int byteCount) [instance] :1355
void MemoryStream::EnsureCapacity(int byteCount)
{
if ((Position() + (int64_t)byteCount) <= (int64_t)Capacity())
return;
else if ((Position() + (int64_t)byteCount) <= (int64_t)(Capacity() + _nextIncrease))
ResizeTo(Capacity() + _nextIncrease);
else
ResizeTo((int)Position() + byteCount);
}
示例2: Resolve
/// <summary>オーバーフローを解決する</summary>
void Resolve()
{
if (Count() < Capacity())
{
return;
}
for (Size i = 0; i < Count() - Capacity(); ++i)
{
m_buffer.pop_front();
}
}
示例3: exword_setpath
Capacity Exword::GetCapacity()
{
exword_capacity_t cap = {0,};
int rsp;
if (IsConnected()) {
exword_setpath(m_device, (uint8_t*)GetStoragePath().utf8_str().data(), 0);
rsp = exword_get_capacity(m_device, &cap);
if (rsp != EXWORD_SUCCESS)
return Capacity();
}
return Capacity(cap.total, cap.free);
}
示例4: PushHead
template<typename... U> void PushHead(U&&... u)
{
condcheck(Capacity() != 0);
if(Empty()){
m_Head = 0;
m_CircleQ[0] = T(std::forward<U>(u)...);
m_CurrSize = 1;
}else{
m_Head = ((m_Head + Capacity() - 1) % Capacity());
m_CircleQ[m_Head] = T(std::forward<U>(u)...);
m_CurrSize = std::min<size_t>(m_CurrSize + 1, Capacity());
}
}
示例5: Size
void NxDeviceOscOutputMessage::CheckForAvailableBundleSpace()
{
unsigned long required = Size() + ((ElementSizeSlotRequired())?4:0) + 16;
if( required > Capacity() )
throw OutOfBufferMemoryException();
}
示例6: Size
void OutboundPacketStream::CheckForAvailableBundleSpace()
{
unsigned long required = Size() + ((ElementSizeSlotRequired())?4:0) + 16;
if( required > Capacity() )
throw OutOfBufferMemoryException();
}
示例7: PopHead
void PopHead()
{
if(!Empty()){
m_Head = (m_Head + 1) % Capacity();
m_CurrSize--;
}
}
示例8: Allocate
template <class T> void Vector<T>::AutoAllocate()
{
if(_origin == NULL)
Allocate(2U);
else if(_last == _end)
Allocate(Capacity() << 1U);
}
示例9: Free
/** free the blob's memory */
inline void Free()
{
if (Capacity() > 0) {
RawFree(&Hdr());
InitEmpty();
}
}
示例10: Capacity
void VectorBase::Reserve( SizeType capacity, SizeType elementSize )
{
SizeType oldCapacity = Capacity();
SizeType oldCount = Count();
if( capacity > oldCapacity )
{
const SizeType wholeAllocation = sizeof(SizeType) * 2 + capacity * elementSize;
void* wholeData = (void*)malloc( wholeAllocation );
#if defined( DEBUG_ENABLED )
// in debug build this will help identify a vector of uninitialized data
memset( wholeData, 0xaa, wholeAllocation );
#endif
SizeType* metaData = reinterpret_cast< SizeType* >( wholeData );
*metaData++ = capacity;
*metaData++ = oldCount;
if( mData )
{
// copy over the old data
memcpy( metaData, mData, oldCount * elementSize );
// release old buffer
Release();
}
mData = metaData;
}
}
示例11: Reserve
String::String(const uint id)
{
if (HINSTANCE const hInstance = Application::Instance::GetLanguage().GetResourceHandle())
{
uint length;
do
{
Reserve( Capacity() + BLOCK_SIZE );
length = ::LoadString( hInstance, id, Ptr(), Capacity() + 1 );
}
while (length == Capacity());
ShrinkTo( length );
}
}
示例12: uPtr
// private void ResizeTo(int newSize) [instance] :1371
void MemoryStream::ResizeTo(int newSize)
{
uArray* newBuffer = uArray::New(::TYPES[0/*byte[]*/], newSize);
::g::Uno::Array::Copy1(::TYPES[6/*Uno.Array.Copy<byte>*/], _buffer, newBuffer, uPtr(_buffer)->Length());
_buffer = newBuffer;
_nextIncrease = Capacity();
}
示例13: res
DZRawData __fastcall DZRawData::operator-(WORD tag)
{
DZRawData res(Capacity());
if (imp)
{
const unsigned char *p = begin();
const unsigned char *e = end();
XWord tg, sz;
while (p + 3 < e)
{
tg.b[0] = *p++;
tg.b[1] = *p++;
sz.b[0] = *p++;
sz.b[1] = *p++;
if (tg.w != tag)
{
res += tg.w;
res += sz.w;
while (p < e && sz.w-- > 0)
res += *p++;
}
else
p += sz.w;
}
while (p < e)
res += *p++;
}
return res;
}
示例14: Compact
inline size_t Compact(size_t leastLength)
{
uint32_t writableBytes = WriteableBytes();
if (writableBytes < leastLength)
{
return 0;
}
uint32_t readableBytes = ReadableBytes();
uint32_t total = Capacity();
char* newSpace = NULL;
if (readableBytes > 0)
{
newSpace = (char*) malloc(readableBytes);
if (NULL == newSpace)
{
return 0;
}
memcpy(newSpace, m_buffer + m_read_idx, readableBytes);
}
if (NULL != m_buffer)
{
free(m_buffer);
}
m_read_idx = 0;
m_write_idx = readableBytes;
m_buffer_len = readableBytes;
m_buffer = newSpace;
return total - readableBytes;
}
示例15: Free
/** free the blob's memory */
FORCEINLINE void Free()
{
if (Capacity() > 0) {
RawFree(&Hdr());
InitEmpty();
}
}