• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ensureSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ensureSize函数的典型用法代码示例。如果您正苦于以下问题:C++ ensureSize函数的具体用法?C++ ensureSize怎么用?C++ ensureSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: putTweetRetweet1VertexValueIfAbsent

TweetRetweet1VertexValueEntry* putTweetRetweet1VertexValueIfAbsent(TweetRetweet1VertexValueMap* tweetRetweet1VertexValueMap, int& tweetTweetIdRetweet1RetweetTweetId ) {
	int h = 31;
	hashCode(h, tweetTweetIdRetweet1RetweetTweetId ); 
	h = h & (tweetRetweet1VertexValueMap->capacity - 1);
	TweetRetweet1VertexValueEntry* candidate = tweetRetweet1VertexValueMap->tweetRetweet1VertexValueEntryArray[h];
	TweetRetweet1VertexValueEntry* lastP = NULL;
	while(candidate) {
		if(
		  candidate->tweetTweetIdRetweet1RetweetTweetId == (tweetTweetIdRetweet1RetweetTweetId)
	      ) {
			return candidate;
		} else {
			lastP = candidate;
			candidate = candidate->next;
		}
	}
	TweetRetweet1VertexValueEntry* p = new TweetRetweet1VertexValueEntry;
	p->tweetTweetIdRetweet1RetweetTweetId = tweetTweetIdRetweet1RetweetTweetId;
	if(lastP)
		lastP->next = p;
	else
		tweetRetweet1VertexValueMap->tweetRetweet1VertexValueEntryArray[h] = p;
	tweetRetweet1VertexValueMap->size++;
	ensureSize(tweetRetweet1VertexValueMap);
	return p;
}
开发者ID:gauravsaxena81,项目名称:GraphIVM,代码行数:26,代码来源:TweetRetweet1VertexValueMapManager.cpp


示例2: putFollower4TweetVertexValueIfAbsent

//%4 - vertex value attributes
Follower4TweetVertexValueEntry* putFollower4TweetVertexValueIfAbsent(Follower4TweetVertexValueMap* follower4TweetVertexValueMap, int& follower4IdTweetUserId ) {
	int h = 31;
	//%1 - vertex value attribute values
	hashCode(h, follower4IdTweetUserId ); 
	h = h & (follower4TweetVertexValueMap->capacity - 1);
	Follower4TweetVertexValueEntry* candidate = follower4TweetVertexValueMap->follower4TweetVertexValueEntryArray[h];
	Follower4TweetVertexValueEntry* lastP = candidate;
	while(candidate) {
		if(
		  candidate->follower4IdTweetUserId == (follower4IdTweetUserId)
	      ) {
			return candidate;
		} else {
			lastP = candidate;
			candidate = candidate->next;
		}
	}
	Follower4TweetVertexValueEntry* p = new Follower4TweetVertexValueEntry;
	p->follower4IdTweetUserId = follower4IdTweetUserId;
	if(lastP)
		lastP->next = p;
	else
		follower4TweetVertexValueMap->follower4TweetVertexValueEntryArray[h] = p;
	follower4TweetVertexValueMap->size++;
	ensureSize(follower4TweetVertexValueMap);
	return p;
}
开发者ID:gauravsaxena81,项目名称:GraphIVM,代码行数:28,代码来源:Follower4TweetVertexValueMapManager.cpp


示例3: putRetweet3Retweet4VertexValueIfAbsent

Retweet3Retweet4VertexValueEntry* putRetweet3Retweet4VertexValueIfAbsent(Retweet3Retweet4VertexValueMap* retweet3Retweet4VertexValueMap, int& r3TweetIdR4RetweetTweetId ) {
	int h = 31;
	hashCode(h, r3TweetIdR4RetweetTweetId ); 
	h = h & (retweet3Retweet4VertexValueMap->capacity - 1);
	Retweet3Retweet4VertexValueEntry* candidate = retweet3Retweet4VertexValueMap->retweet3Retweet4VertexValueEntryArray[h];
	Retweet3Retweet4VertexValueEntry* lastP = candidate;
	while(candidate) {
		if(
		  candidate->r3TweetIdR4RetweetTweetId == (r3TweetIdR4RetweetTweetId)
	      ) {
			return candidate;
		} else {
			lastP = candidate;
			candidate = candidate->next;
		}
	}
	Retweet3Retweet4VertexValueEntry* p = new Retweet3Retweet4VertexValueEntry;
	p->r3TweetIdR4RetweetTweetId = r3TweetIdR4RetweetTweetId;
	if(lastP)
		lastP->next = p;
	else
		retweet3Retweet4VertexValueMap->retweet3Retweet4VertexValueEntryArray[h] = p;
	retweet3Retweet4VertexValueMap->size++;
	ensureSize(retweet3Retweet4VertexValueMap);
	return p;
}
开发者ID:gauravsaxena81,项目名称:GraphIVM,代码行数:26,代码来源:Retweet3Retweet4VertexValueMapManager.cpp


示例4: putRetweet1JoinTupleIfAbsent

Retweet1JoinTupleEntry* putRetweet1JoinTupleIfAbsent(Retweet1JoinTupleMap* retweet1JoinTupleMap, int& r1TweetIdR2RetweetTweetId, Retweet1Retweet2VertexValueMap* retweet1Retweet2VertexValueMap ) {
    int h = 31;
    hashCode(h, r1TweetIdR2RetweetTweetId ); 
    h = h & (retweet1JoinTupleMap->capacity - 1);
    Retweet1JoinTupleEntry* candidate = retweet1JoinTupleMap->retweet1JoinTupleEntryArray[h];
    Retweet1JoinTupleEntry* lastP = candidate;
    while(candidate) {
        if(
                candidate->retweet1Retweet2VertexValue->r1TweetIdR2RetweetTweetId == r1TweetIdR2RetweetTweetId
        ) {
            return candidate;
        } else {
            lastP = candidate;
            candidate = candidate->next;
        }
    }
    Retweet1JoinTupleEntry* p = new Retweet1JoinTupleEntry;
    if(!lastP)
        retweet1JoinTupleMap->retweet1JoinTupleEntryArray[h] = p;
    else
        lastP->next = p;
    retweet1JoinTupleMap->size++;
    ensureSize(retweet1JoinTupleMap, r1TweetIdR2RetweetTweetId );
    addToVertexValues(r1TweetIdR2RetweetTweetId , p, retweet1Retweet2VertexValueMap);
    return p;
}
开发者ID:gauravsaxena81,项目名称:GraphIVM,代码行数:26,代码来源:Retweet1JoinTupleMapManager.cpp


示例5: putUserTweetVertexValueIfAbsent

UserTweetVertexValueEntry* putUserTweetVertexValueIfAbsent(UserTweetVertexValueMap* userTweetVertexValueMap, int& userIdTweetUserId ) {
	int h = 31;
	hashCode(h, userIdTweetUserId ); 
	h = h & (userTweetVertexValueMap->capacity - 1);
	UserTweetVertexValueEntry* candidate = userTweetVertexValueMap->userTweetVertexValueEntryArray[h];
	UserTweetVertexValueEntry* lastP = NULL;
	while(candidate) {
		if(
		  candidate->userIdTweetUserId == (userIdTweetUserId)
	      ) {
			return candidate;
		} else {
			lastP = candidate;
			candidate = candidate->next;
		}
	}
	UserTweetVertexValueEntry* p = new UserTweetVertexValueEntry;
	p->userIdTweetUserId = userIdTweetUserId;
	if(lastP)
		lastP->next = p;
	else
		userTweetVertexValueMap->userTweetVertexValueEntryArray[h] = p;
	userTweetVertexValueMap->size++;
	ensureSize(userTweetVertexValueMap);
	return p;
}
开发者ID:gauravsaxena81,项目名称:GraphIVM,代码行数:26,代码来源:UserTweetVertexValueMapManager.cpp


示例6: sync

		/* Sum contributions from all threads, save to _force&_torque.
		 * Locks globalMutex, since one thread modifies common data (_force&_torque).
		 * Must be called before get* methods are used. Exception is thrown otherwise, since data are not consistent. */
		inline void sync(){
			for(int i=0; i<nThreads; i++){
				if (_maxId[i] > 0) { synced = false;}
			}
			if(synced) return;
			boost::mutex::scoped_lock lock(globalMutex);
			if(synced) return; // if synced meanwhile
			
			for(int i=0; i<nThreads; i++){
				if (_maxId[i] > 0) { ensureSize(_maxId[i],i);}
			}
			
			syncSizesOfContainers();

			for(long id=0; id<(long)size; id++){
				Vector3r sumF(Vector3r::Zero()), sumT(Vector3r::Zero());
				for(int thread=0; thread<nThreads; thread++){ sumF+=_forceData[thread][id]; sumT+=_torqueData[thread][id];}
				_force[id]=sumF; _torque[id]=sumT;
				if (permForceUsed) {_force[id]+=_permForce[id]; _torque[id]+=_permTorque[id];}
			}
			if(moveRotUsed){
				for(long id=0; id<(long)size; id++){
					Vector3r sumM(Vector3r::Zero()), sumR(Vector3r::Zero());
					for(int thread=0; thread<nThreads; thread++){ sumM+=_moveData[thread][id]; sumR+=_rotData[thread][id];}
					_move[id]=sumM; _rot[id]=sumR;
				}
			}
			synced=true; syncCount++;
		}
开发者ID:NauticalMile64,项目名称:trunk,代码行数:32,代码来源:ForceContainer.hpp


示例7: putTweetProjectedTuple

//%3 - projected attributes
TweetProjectedTupleEntry* putTweetProjectedTuple(TweetProjectedTupleMap* tweetProjectedTupleMap, int& tweetId ) {
	int h = 31;
	hashCode(h, tweetId ); 
	h = h & (tweetProjectedTupleMap->capacity - 1);
	TweetProjectedTupleEntry* candidate = tweetProjectedTupleMap->tweetProjectedTupleEntryArray[h];
	TweetProjectedTupleEntry* lastP = NULL;
	while(candidate) {
		if(
		  //%1 - projected attributes
				candidate->tweetId == (tweetId)
		) {
			candidate->count++;
			return candidate;
		} else {
			lastP = candidate;
			candidate = candidate->next;
		}
	}
	TweetProjectedTupleEntry* p = new TweetProjectedTupleEntry;
	//%1 - projected attributes
	p->tweetId = tweetId;
	if(!lastP)
		tweetProjectedTupleMap->tweetProjectedTupleEntryArray[h] = p;
	else
		lastP->next = p;
	tweetProjectedTupleMap->size++;
	ensureSize(tweetProjectedTupleMap);
	return p;
}
开发者ID:gauravsaxena81,项目名称:GraphIVM,代码行数:30,代码来源:TweetProjectedTupleMapManager.cpp


示例8: ensureSize

prettyTable& prettyTable::addTitle(std::string title) {
    colRowTitles_++;
    maxColRowTitles_ = std::max(maxColRowTitles_, colRowTitles_);
    ensureSize();
    rowTitles_[rowRowTitles_][colRowTitles_] = title;

    return *this;
}
开发者ID:paulkoerbitz,项目名称:uncert,代码行数:8,代码来源:prettytable.cpp


示例9: getTorqueSingle

		const Vector3r getTorqueSingle(Body::id_t id){ 
			ensureSize(id); 
			if (permForceUsed) {
				return _torque[id] + _permTorque[id];
			} else {
				return _torque[id];
			}
		}
开发者ID:NauticalMile64,项目名称:trunk,代码行数:8,代码来源:ForceContainer.hpp


示例10: ensureSize

void IOBuffer::storeDoubleLE(double data) {
	ensureSize(8);
	rx_uint64 val = 0;
	memcpy(&val, &data, 8);
	val = ToLE64(data);
	memcpy(buffer+published, &val, 8);
	published += 8;
}
开发者ID:basseyndon,项目名称:roxlu_experimental,代码行数:8,代码来源:IOBuffer.cpp


示例11: storeBytes

bool IOBuffer::storeBytes(const char* someData, const rx_uint32 numBytes) {
	if(!ensureSize(numBytes)) {
		return false;
	}
	memcpy(buffer+published, someData, numBytes);
	published += numBytes;
	return true;
}
开发者ID:basseyndon,项目名称:roxlu_experimental,代码行数:8,代码来源:IOBuffer.cpp


示例12: databases

Tablespace::Tablespace(ConfigParser& cfg, IndexType defaultTablespaceSize)
        : databases(defaultTablespaceSize), cfg(cfg) {
    ensureSize(defaultTablespaceSize);
    //Use malloc here to allow usage of realloc
    //Initialize all pointers to zero
    for (size_t i = 0; i < databases.size(); i++) {
        databases[i] = nullptr;
    }
}
开发者ID:QuantScientist3,项目名称:YakDB,代码行数:9,代码来源:Tablespace.cpp


示例13: pushBump

			void pushBump(element_type const & entry)
			{
				if ( expect_false(full()) )
				{
					ensureSize(std::max(2*f,static_cast<size_t>(1)));
					assert ( ! full() );
				}
				push(entry);
			}
开发者ID:gt1,项目名称:libmaus2,代码行数:9,代码来源:FiniteSizeHeap.hpp


示例14: append

static void append(buffer_t* buf, char* str)
{
    int needed;
    int len;

    len = strlen(str);
    needed = buf->pos + len + 1;
    ensureSize(buf, needed);
    strcpy(buf->block + buf->pos, str);
    buf->pos += len;
}
开发者ID:kmizu,项目名称:spnuts,代码行数:11,代码来源:pnuts.c


示例15: write

    void write (const MinMaxValue* const values, const int startIndex, const int numValues)
    {
        resetPeak();

        if (startIndex + numValues > data.size())
            ensureSize (startIndex + numValues);

        MinMaxValue* const dest = getData (startIndex);

        for (int i = 0; i < numValues; ++i)
            dest[i] = values[i];
    }
开发者ID:Krewn,项目名称:LIOS,代码行数:12,代码来源:juce_AudioThumbnail.cpp


示例16: ensureSize

void QWaylandShmBackingStore::beginPaint(const QRegion &)
{
    mPainting = true;
    ensureSize();

    if (waylandWindow()->attached() && mBackBuffer == waylandWindow()->attached() && mFrameCallback) {
        QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle());
        Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
        waylandWindow->waitForFrameSync();
    }

}
开发者ID:stskeeps,项目名称:qtwayland,代码行数:12,代码来源:qwaylandshmbackingstore.cpp


示例17: printf

void IOBuffer::setup(rx_uint32 expectedSize) {
	if( (buffer != NULL)
		|| (size != 0)
		|| (published != 0)
		|| (consumed != 0)
	)
	{
		printf("iobuffer error: buffer has been setup already\n");
		return;
	}
	
	ensureSize(expectedSize);
	//memset(buffer, 0, expectedSize);
}
开发者ID:basseyndon,项目名称:roxlu_experimental,代码行数:14,代码来源:IOBuffer.cpp


示例18: ensureSize

void Being::setSprite(unsigned int slot, int id, const std::string &color,
                      bool isWeapon)
{
    if (slot >= size())
        ensureSize(slot + 1);

    if (slot >= mSpriteIDs.size())
        mSpriteIDs.resize(slot + 1);

    if (slot >= mSpriteColors.size())
        mSpriteColors.resize(slot + 1);

    // id = 0 means unequip
    if (id == 0)
    {
        removeSprite(slot);

        if (isWeapon)
            mEquippedWeapon = 0;
    }
    else
    {
        std::string filename = itemDb->get(id).getSprite(mGender);
        AnimatedSprite *equipmentSprite = 0;

        if (!filename.empty())
        {
            if (!color.empty())
                filename += "|" + color;

            equipmentSprite = AnimatedSprite::load(
                                    paths.getStringValue("sprites") + filename);
        }

        if (equipmentSprite)
            equipmentSprite->setDirection(getSpriteDirection());

        CompoundSprite::setSprite(slot, equipmentSprite);

        if (isWeapon)
            mEquippedWeapon = &itemDb->get(id);

        setAction(mAction);
    }

    mSpriteIDs[slot] = id;
    mSpriteColors[slot] = color;
}
开发者ID:Ablu,项目名称:mana,代码行数:48,代码来源:being.cpp


示例19: ASSERT

void BitVector::mergeSlow(const BitVector& other)
{
    if (other.isInline()) {
        ASSERT(!isInline());
        *bits() |= cleanseInlineBits(other.m_bitsOrPointer);
        return;
    }
    
    ensureSize(other.size());
    ASSERT(!isInline());
    ASSERT(!other.isInline());
    
    OutOfLineBits* a = outOfLineBits();
    const OutOfLineBits* b = other.outOfLineBits();
    for (unsigned i = a->numWords(); i--;)
        a->bits()[i] |= b->bits()[i];
}
开发者ID:RobotsAndPencils,项目名称:JavaScriptCore-iOS,代码行数:17,代码来源:BitVector.cpp


示例20: refillCache

    bool refillCache (const int numSamples, double startTime, const double endTime,
                      const double rate, const int numChans, const int sampsPerThumbSample,
                      LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
    {
        const double timePerPixel = (endTime - startTime) / numSamples;

        if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0)
        {
            invalidate();
            return false;
        }

        if (numSamples == numSamplesCached
             && numChannelsCached == numChans
             && startTime == cachedStart
             && timePerPixel == cachedTimePerPixel
             && ! cacheNeedsRefilling)
        {
            return ! cacheNeedsRefilling;
        }

        numSamplesCached = numSamples;
        numChannelsCached = numChans;
        cachedStart = startTime;
        cachedTimePerPixel = timePerPixel;
        cacheNeedsRefilling = false;

        ensureSize (numSamples);

        if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr)
        {
            int sample = roundToInt (startTime * rate);
            Array<float> levels;

            int i;
            for (i = 0; i < numSamples; ++i)
            {
                const int nextSample = roundToInt ((startTime + timePerPixel) * rate);

                if (sample >= 0)
                {
                    if (sample >= levelData->lengthInSamples)
                        break;

                    levelData->getLevels (sample, jmax (1, nextSample - sample), levels);

                    const int totalChans = jmin (levels.size() / 2, numChannelsCached);

                    for (int chan = 0; chan < totalChans; ++chan)
                        getData (chan, i)->setFloat (levels.getUnchecked (chan * 2),
                                                     levels.getUnchecked (chan * 2 + 1));
                }

                startTime += timePerPixel;
                sample = nextSample;
            }

            numSamplesCached = i;
        }
        else
        {
            jassert (chans.size() == numChannelsCached);

            for (int channelNum = 0; channelNum < numChannelsCached; ++channelNum)
            {
                ThumbData* channelData = chans.getUnchecked (channelNum);
                MinMaxValue* cacheData = getData (channelNum, 0);

                const double timeToThumbSampleFactor = rate / (double) sampsPerThumbSample;

                startTime = cachedStart;
                int sample = roundToInt (startTime * timeToThumbSampleFactor);

                for (int i = numSamples; --i >= 0;)
                {
                    const int nextSample = roundToInt ((startTime + timePerPixel) * timeToThumbSampleFactor);

                    channelData->getMinMax (sample, nextSample, *cacheData);

                    ++cacheData;
                    startTime += timePerPixel;
                    sample = nextSample;
                }
            }
        }

        return true;
    }
开发者ID:Krewn,项目名称:LIOS,代码行数:88,代码来源:juce_AudioThumbnail.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ensureVisible函数代码示例发布时间:2022-05-30
下一篇:
C++ ensurePolished函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap