本文整理汇总了C++中std::list::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ list::rend方法的具体用法?C++ list::rend怎么用?C++ list::rend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::rend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: top_tags
bool top_tags(const char* str1, const char* str2)
{
std::list<std::string>::reverse_iterator i = tag_stack.rbegin();
if (i == tag_stack.rend()) return false;
if (!string_equal_nocase(i->c_str(), str2)) return false;
++i;
if (i == tag_stack.rend()) return false;
if (!string_equal_nocase(i->c_str(), str1)) return false;
return true;
}
示例2: noise
gfx::Color PerlinCity::noise(const std::list<gfx::VolumeGray8Sptr> &op,
const math::vec3d &tt)
{
float ns = 0.0f,
wt = 1.0f;
for(std::list<gfx::VolumeGray8Sptr>::const_reverse_iterator ii = op.rbegin(), ee = op.rend();
(ii != ee); ++ii)
{
gfx::VolumeGray8 *vv = ii->get();
ns += wt * math::abs((vv->getAveragePixel(tt.x(), tt.y(), tt.z()) - 0.5f));
wt *= 0.5f;
}
//ns = ns*ns;
//ns = ns + 0.5f;
if(ns < 0.0f)
{
ns = -ns;
}
else if(ns > 1.0f)
{
ns = 2.0f - ns;
}
return gfx::Color(ns, ns, ns);
//return m_gradient.getColor(ns);
}
示例3: leaveScope
void Variables::leaveScope(bool insideLoop)
{
if (insideLoop) {
// read variables are read again in subsequent run through loop
std::set<unsigned int> const & currentVarReadInScope = _varReadInScope.back();
for (std::set<unsigned int>::const_iterator readIter = currentVarReadInScope.begin();
readIter != currentVarReadInScope.end();
++readIter) {
read(*readIter, nullptr);
}
}
std::list<std::set<unsigned int> >::reverse_iterator reverseReadIter = _varReadInScope.rbegin();
++reverseReadIter;
if (reverseReadIter != _varReadInScope.rend()) {
// Transfer read variables into previous scope
std::set<unsigned int> const & currentVarAddedInScope = _varAddedInScope.back();
std::set<unsigned int> & currentVarReadInScope = _varReadInScope.back();
for (std::set<unsigned int>::const_iterator addedIter = currentVarAddedInScope.begin();
addedIter != currentVarAddedInScope.end();
++addedIter) {
currentVarReadInScope.erase(*addedIter);
}
std::set<unsigned int> & previousVarReadInScope = *reverseReadIter;
previousVarReadInScope.insert(currentVarReadInScope.begin(),
currentVarReadInScope.end());
}
_varReadInScope.pop_back();
_varAddedInScope.pop_back();
}
示例4: freeBlocks
void HeapPage::freeBlocks(std::list<HeapBlock>& newBlocks, std::list<HeapBlock>& newReleasedBlocks) {
// Copy new blocks.
blocks = newBlocks;
// Check if we can join some values.
IntPtr pageHighAddress = reinterpret_cast<IntPtr>(&memory[pagepointer]);
std::list<HeapBlock>::reverse_iterator current = newBlocks.rbegin();
// Start looking from the end of new blocks.
// Use the new blocks listing, not the instance list.
while (current != newBlocks.rend() && current->isReleased()) {
const IntPtr blockHighAddress = reinterpret_cast<IntPtr>(current->getHandle()) + current->getSize();
// If both are pointing to the same memory location,
// we can join this block with the free memory region
// of the page.
if (blockHighAddress == pageHighAddress) {
// Compute new high address and move page
// pointer back.
pageHighAddress -= current->getSize();
pagepointer -= current->getSize();
// Remove from new released block listing.
newReleasedBlocks.remove(*current);
blocks.remove(*current);
current++;
} else {
// If we can't join the first block to the free memory region,
// there is no point going trough other blocks.
break;
}
}
}
示例5: sortRegions
void Preprocessor::sortRegions (std::list<RegionIterator>& regions)
{
for ( std::list<RegionIterator>::iterator i = regions.begin(); i != regions.end(); ++i )
{
if ( i == regions.begin() )
continue;
// Get current element
RegionIterator value = *i;
// Get previous element
std::list<RegionIterator>::reverse_iterator j = regions.rbegin();
advance(j, distance(i, regions.end()));
// Shift elements until finding final position
while ( j != regions.rend() && *value < *(*j) )
{
std::list<RegionIterator>::reverse_iterator k = j;
--k;
*k = *j;
++j;
}
// Insert current element into its final position
std::list<RegionIterator>::reverse_iterator k = j;
--k;
*k = value;
}
};
示例6:
void
test_ns::matrix::
find_one_puddle_and_update(int entry_h, const entry_pos_t& entry_pos,
entry_pos_set_t& puddle_pos, entry_pos_set_t& leaks_pos,
std::list<puddle>& puddles,
size_t& yet_not_found_positions) const {
entry_pos_set_t searched_entries;
entry_pos_set_t below_level_entries;
bool is_puddle = find_one_puddle(entry_h, entry_pos, leaks_pos,
searched_entries, below_level_entries);
yet_not_found_positions -= searched_entries.size();
if (is_puddle) {
for (const auto & e : searched_entries) {
puddle_pos.insert(e);
}
if (!below_level_entries.empty()) {
for (auto const & below_entry : below_level_entries) {
for (auto i = puddles.rbegin(); i != puddles.rend(); ++i) {
const auto & puddle = *i;
auto & entries = puddle.entries_;
if (entries.find(below_entry) != entries.end()) {
puddles.erase(std::prev (i.base()));
break;
}
}
}
}
puddle a_puddle{searched_entries, entry_h};
puddles.push_back(std::move(a_puddle));
} else {
for (const auto & e : searched_entries) {
leaks_pos.insert(e);
}
}
}
示例7: cumulativeDelta
std::vector< double > guessLambdaModifiers(
double initialAdjustmentParameter,
const std::vector< double > &targetBitrateVector,
const std::list< MetaLogEntry< std::vector< double > > >& metaLogEntryList )
{
assert( !targetBitrateVector.empty( ) );
assert( !metaLogEntryList.empty( ) );
double cumulativeDelta( 0.0 );
std::vector< double > resultVector;
for( unsigned char i( 0 ); i < targetBitrateVector.size( ); ++i )
{
// Populate pointList with up to two of the previous points
std::list< Point > pointList;
std::list< MetaLogEntry< std::vector< double > > >::const_reverse_iterator j( metaLogEntryList.rbegin( ) );
pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
++j;
if( j != metaLogEntryList.rend( ) ) pointList.push_front( pointFromFullMetaLogEntry( i, *j ) );
// Calculate the new Lambda-modifier guess and add it to the result vector
const double newLambdaModifier( guessLambdaModifier(
initialAdjustmentParameter,
targetBitrateVector[ i ], // target bitrate
pointList,
interDampeningFactor( 50.0, cumulativeDelta ) ) );
resultVector.push_back( newLambdaModifier );
// Increment the cumulativeDelta
const double oldLambdaModifier( pointList.back( ).lambdaModifier );
cumulativeDelta += std::abs( newLambdaModifier - oldLambdaModifier ) / oldLambdaModifier;
}
return resultVector;
}
示例8: RenderChatText
void RenderChatText()
{
// View transformation
gGraphicsDevice->SetTransform(D3DTS_VIEW, &gOrthoViewMatrix);
// Perspective transformation
gGraphicsDevice->SetTransform(D3DTS_PROJECTION, &gScreenProjectionMatrix);
// Render the texture
gGraphicsDevice->BeginScene();
{
// render the user list
size_t index = 0;
int y = kFontSize / 4;
for (auto iter=gChatUsers.rbegin(); iter != gChatUsers.rend() && index < gMaxChatLines; ++iter)
{
std::shared_ptr<ChatUser> user = *iter;
RenderString(gWindowWidth-kUserListWidth, y, user->nameColorARGB, *user->font, user->username);
y += user->font->pixelHeight + kLineSpacing;
index++;
}
y = kFontSize / 4;
// render the input text if showing
if (gInputText != nullptr)
{
int x = RenderChatLine(kMessagesLeft, y, gInputText, KWhiteColor) + 2;
RenderString(x, y, KWhiteColor, gNormalFont, "_");
y += gInputText->font->pixelHeight + kLineSpacing;
}
// render the history
for (auto iter=gChatLines.rbegin(); iter != gChatLines.rend(); ++iter)
{
std::shared_ptr<ChatLine> line = *iter;
RenderChatLine(kMessagesLeft, y, line, KBlackColor);
y += line->font->pixelHeight + kLineSpacing;
}
gGraphicsDevice->SetTexture(0, nullptr);
}
gGraphicsDevice->EndScene();
}
示例9: callvote_CheckForFlooding
//*****************************************************************************
//
static bool callvote_CheckForFlooding( FString &Command, FString &Parameters, ULONG ulPlayer )
{
NETADDRESS_s Address = SERVER_GetClient( ulPlayer )->Address;
ULONG ulVoteType = callvote_GetVoteType( Command );
time_t tNow;
time( &tNow );
// Remove old votes that no longer affect flooding.
while ( g_PreviousVotes.size( ) > 0 && (( tNow - g_PreviousVotes.front( ).tTimeCalled ) > VOTE_LONGEST_INTERVAL * MINUTE ))
g_PreviousVotes.pop_front( );
// [BB] If the server doesn't want to limit the number of votes, there is no check anything.
// [TP] sv_limitcommands == false also implies limitless voting.
if ( sv_limitnumvotes == false || sv_limitcommands == false )
return true;
// Run through the vote cache (backwards, from recent to old) and search for grounds on which to reject the vote.
for( std::list<VOTE_s>::reverse_iterator i = g_PreviousVotes.rbegin(); i != g_PreviousVotes.rend(); ++i )
{
// One *type* of vote per voter per ## minutes (excluding kick votes if they passed).
if ( !( callvote_IsKickVote ( i->ulVoteType ) && i->bPassed ) && NETWORK_CompareAddress( i->Address, Address, true ) && ( ulVoteType == i->ulVoteType ) && (( tNow - i->tTimeCalled ) < VOTER_VOTETYPE_INTERVAL * MINUTE ))
{
int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTER_VOTETYPE_INTERVAL * MINUTE - tNow ) / MINUTE );
SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another %s vote.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ), Command.GetChars() );
return false;
}
// One vote per voter per ## minutes.
if ( NETWORK_CompareAddress( i->Address, Address, true ) && (( tNow - i->tTimeCalled ) < VOTER_NEWVOTE_INTERVAL * MINUTE ))
{
int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTER_NEWVOTE_INTERVAL * MINUTE - tNow ) / MINUTE );
SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "You must wait %d minute%s to call another vote.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
return false;
}
// Specific votes ("map map30") that fail can't be re-proposed for ## minutes.
if (( ulVoteType == i->ulVoteType ) && ( !i->bPassed ) && (( tNow - i->tTimeCalled ) < VOTE_LITERALREVOTE_INTERVAL * MINUTE ))
{
int iMinutesLeft = static_cast<int>( 1 + ( i->tTimeCalled + VOTE_LITERALREVOTE_INTERVAL * MINUTE - tNow ) / MINUTE );
// Kickvotes (can't give the IP to clients!).
if ( callvote_IsKickVote ( i->ulVoteType ) && ( !i->bPassed ) && NETWORK_CompareAddress( i->KickAddress, g_KickVoteVictimAddress, true ))
{
SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific player was recently on voted to be kicked or forced to spectate, but the vote failed. You must wait %d minute%s to call it again.\n", iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
return false;
}
// Other votes.
if ( ( callvote_IsKickVote ( i->ulVoteType ) == false ) && ( stricmp( i->fsParameter.GetChars(), Parameters.GetChars() ) == 0 ))
{
SERVER_PrintfPlayer( PRINT_HIGH, ulPlayer, "That specific vote (\"%s %s\") was recently called, and failed. You must wait %d minute%s to call it again.\n", Command.GetChars(), Parameters.GetChars(), iMinutesLeft, ( iMinutesLeft == 1 ? "" : "s" ));
return false;
}
}
}
return true;
}
示例10: searchBackToken
static std::list<TokenRec>::reverse_iterator searchBackToken(int id){
std::list<TokenRec>::reverse_iterator iii=TokenList.rbegin();
for ( ; iii!=TokenList.rend();iii++){
if (id==iii->id){
break;
}
}
return iii;
}
示例11: PopTag
void CRealTextParser::PopTag(std::list<Tag>& p_rlistTags, const std::wstring& p_crszTagName)
{
for (std::list<Tag>::reverse_iterator riter = p_rlistTags.rbegin(); riter != p_rlistTags.rend(); ++riter) {
if (riter->m_szName == p_crszTagName) {
p_rlistTags.erase((++riter).base());
return;
}
}
}
示例12: DrawScreenSpace
void DrawScreenSpace (sf::RenderWindow& rwin) {
for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
itState != stateList.rend(); ++itState) {
if (!(*itState)->off) {
(*itState)->DrawScreenSpace(rwin);
break;
}
}
}
示例13: HandleSFEvents
virtual void HandleSFEvents (std::list<sf::Event>& sfEvents) {
for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
itState != stateList.rend(); ++itState) {
if (!(*itState)->off) {
(*itState)->HandleSFEvents(sfEvents);
break;
}
}
}
示例14: erase_last
/*
* Erases the last inactive element in the cache.
*/
bool erase_last() {
for (auto rit = elements.rbegin(); rit != elements.rend(); ++rit) {
if (rit->active_readers == 0) {
erase(rit->key);
return true;
}
}
return false;
}
示例15: Pop
void Pop (int cntToPop) {
int i = 0;
for (typename std::list<T*>::reverse_iterator itState = stateList.rbegin();
itState != stateList.rend(); itState++) {
(*itState)->pop = true;
if (++i == cntToPop)
break;
}
}