本文整理汇总了C++中Capacity函数的典型用法代码示例。如果您正苦于以下问题:C++ Capacity函数的具体用法?C++ Capacity怎么用?C++ Capacity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Capacity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:blyk,项目名称:BlackCode-Fuse,代码行数:10,代码来源:Uno.IO.g.cpp
示例2: Resolve
/// <summary>オーバーフローを解決する</summary>
void Resolve()
{
if (Count() < Capacity())
{
return;
}
for (Size i = 0; i < Count() - Capacity(); ++i)
{
m_buffer.pop_front();
}
}
开发者ID:rumiaqua,项目名称:DxGame,代码行数:12,代码来源:Memento.hpp
示例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);
}
开发者ID:brijohn,项目名称:exword_tools,代码行数:12,代码来源:ExwordDevice.cpp
示例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());
}
}
开发者ID:etorth,项目名称:mir2x,代码行数:13,代码来源:cachequeue.hpp
示例5: Size
void NxDeviceOscOutputMessage::CheckForAvailableBundleSpace()
{
unsigned long required = Size() + ((ElementSizeSlotRequired())?4:0) + 16;
if( required > Capacity() )
throw OutOfBufferMemoryException();
}
开发者ID:nxgraphics,项目名称:NxGraphics,代码行数:7,代码来源:NxDevice_Device_OscOutputMsg.cpp
示例6: Size
void OutboundPacketStream::CheckForAvailableBundleSpace()
{
unsigned long required = Size() + ((ElementSizeSlotRequired())?4:0) + 16;
if( required > Capacity() )
throw OutOfBufferMemoryException();
}
开发者ID:CPonty,项目名称:reactivision-midi-server,代码行数:7,代码来源:OscOutboundPacketStream.cpp
示例7: PopHead
void PopHead()
{
if(!Empty()){
m_Head = (m_Head + 1) % Capacity();
m_CurrSize--;
}
}
开发者ID:etorth,项目名称:mir2x,代码行数:7,代码来源:cachequeue.hpp
示例8: Allocate
template <class T> void Vector<T>::AutoAllocate()
{
if(_origin == NULL)
Allocate(2U);
else if(_last == _end)
Allocate(Capacity() << 1U);
}
开发者ID:Karkasos,项目名称:Core,代码行数:7,代码来源:Vector.cpp
示例9: Free
/** free the blob's memory */
inline void Free()
{
if (Capacity() > 0) {
RawFree(&Hdr());
InitEmpty();
}
}
开发者ID:habnabit,项目名称:openttd-cargodist,代码行数:8,代码来源:blob.hpp
示例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;
}
}
开发者ID:Tarnyko,项目名称:dali-core,代码行数:25,代码来源:dali-vector.cpp
示例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 );
}
}
开发者ID:ArtVandelae,项目名称:nestopia,代码行数:16,代码来源:NstResourceString.cpp
示例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();
}
开发者ID:blyk,项目名称:BlackCode-Fuse,代码行数:8,代码来源:Uno.IO.g.cpp
示例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;
}
开发者ID:geoffsmith82,项目名称:delphizip,代码行数:32,代码来源:DZRaw.cpp
示例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;
}
开发者ID:dawnbreaks,项目名称:arch,代码行数:29,代码来源:buffer.hpp
示例15: Free
/** free the blob's memory */
FORCEINLINE void Free()
{
if (Capacity() > 0) {
RawFree(&Hdr());
InitEmpty();
}
}
开发者ID:ShaunOfTheLive,项目名称:OpenCoasterTycoon,代码行数:8,代码来源:blob.hpp
示例16: WriteBin
int NDOStreamMsg::WriteBin(void *data, size_t size)
{
if (_end <= _op_addr || size >= Capacity()){
return -1;
}
if (size ==0){
if (-1 == _writeMarker(ENDSTREAM_MARKER_BIN, 0)) {
return -1;
}
return 0;
}
else {
if (-1 == _writeMarker(ENDSTREAM_MARKER_BIN, 1)) {
return -1;
}
}
size_t free_size = _end - _op_addr;
if (size + 2 <= free_size) {
_WriteOrg((NDUINT16)size);
if (size > 0)
memcpy(_op_addr, data, size);
MsgLength() += (NDUINT16)size;
_op_addr += size;
return 0;
}
return -1;
}
开发者ID:neil78duan,项目名称:ndnetsdk,代码行数:29,代码来源:nd_msgpack.cpp
示例17: Size
void OutboundPacketStream::CheckForAvailableMessageSpace( const char *addressPattern )
{
// plus 4 for at least four bytes of type tag
unsigned long required = Size() + ((ElementSizeSlotRequired()) ? 4 : 0) + RoundUp4(static_cast<unsigned long>(strlen(addressPattern)) + 1) + 4;
if( required > Capacity() )
throw OutOfBufferMemoryException();
}
开发者ID:IsemanTech,项目名称:osg,代码行数:8,代码来源:OscOutboundPacketStream.cpp
示例18: Capacity
//============================================================
void TNetMessageBuffer::Update(){
TInt capacity = Capacity();
TNetSerial messageSerial = _messageHead.Serial();
TNetTick messageTick = _messageHead.Tick();
TNetHash hash = CalculateHash(messageSerial, messageTick, _pData, _dataLength);
_netHead.SetLength((TNetLength)capacity);
_netHead.SetHash(hash);
}
开发者ID:favedit,项目名称:MoCross3d,代码行数:9,代码来源:TNetMessageBuffer.cpp
示例19: Size
Errors OutboundPacketStream::CheckForAvailableMessageSpace( const char *addressPattern )
{
// plus 4 for at least four bytes of type tag
std::size_t required = Size() + ((ElementSizeSlotRequired())?4:0)
+ RoundUp4(std::strlen(addressPattern) + 1) + 4;
return (required > Capacity()) ? OUT_OF_BUFFER_MEMORY_ERROR : SUCCESS;
}
开发者ID:lalalaring,项目名称:UE4-OSC,代码行数:8,代码来源:OscOutboundPacketStream.cpp
示例20: RoundUp4
void OutboundPacketStream::CheckForAvailableArgumentSpace( long argumentLength )
{
// plus three for extra type tag, comma and null terminator
unsigned long required = static_cast<unsigned long>((argumentCurrent_ - data_) + argumentLength + RoundUp4( (end_ - typeTagsCurrent_) + 3 ));
if( required > Capacity() )
throw OutOfBufferMemoryException();
}
开发者ID:IsemanTech,项目名称:osg,代码行数:8,代码来源:OscOutboundPacketStream.cpp
注:本文中的Capacity函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论