本文整理汇总了C++中std::list::end方法的典型用法代码示例。如果您正苦于以下问题:C++ list::end方法的具体用法?C++ list::end怎么用?C++ list::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cancelCB
void cancelCB(GoalHandle& gh)
{
boost::mutex::scoped_lock l(goals_mutex_);
ROS_DEBUG("GoalHandle canceled");
// search for goal handle and remove it from active_goals_ list
for(std::list<boost::shared_ptr<ClientGoalInfo> >::iterator it = active_goals_.begin(); it != active_goals_.end();)
{
ClientGoalInfo& info = **it;
if(info.handle == gh)
{
it = active_goals_.erase(it);
info.timer_.stop();
info.handle.setCanceled();
return;
}
else
++it;
}
}
示例2: init_Vnet
extern "C" int tic_tac_toe_test2()
{
extern void init_Vnet(void);
extern void load_Vnet(void);
extern void save_Vnet(char *);
extern double get_V(int x[9]);
extern void train_V(int x[9], double v);
extern void learn_V(int x[9], int y[9]);
extern void beep();
// Build states for RL player 1
cout << "Loading player 1's V values...\n";
states1.clear();
int totalStates1 = loadVFromFile("ttt1.dat", states1, V1);
cout << "Total read: " << to_string(totalStates1) << "\n";
//*** Train player1's V network
cout << "[i] = init new net and train with end state values\n";
cout << "[o] = train with old V\n";
cout << "[t] = train with end state values\n";
cout << "[r] = init new net with random weights\n";
cout << "[-] = just load net\n";
char key;
do
key = getchar();
while (key == '\n');
if (key == 'i' || key == 'r')
init_Vnet();
else
load_Vnet();
if (key == 'o')
{
for (int t = 0; t < 10000; ++t)
{
// For all states
for (std::list<State>::iterator itr = states1.begin(); itr != states1.end(); ++itr)
{
State s = *itr;
double v = V1.at(s);
train_V(s.x, v);
}
double absError = 0.0; // sum of abs(error)
// Calculate error
for (std::list<State>::iterator itr = states1.begin(); itr != states1.end(); ++itr)
{
State s = *itr;
double v = V1.at(s);
//cout << "v = " << to_string(v) << "\t";
double v2 = get_V(s.x);
//cout << "v2 = " << to_string(v2) << "\t";
double error = v - v2; // ideal - actual
//cout << "err = " << to_string(error) << "\n";
absError += fabs(error);
}
printf("(%05d) ", t);
printf("∑ abs err = %.1f (avg = %.3f)\r", absError, absError / 8533.0);
if (isnan(absError))
{
init_Vnet();
t = 0;
}
}
cout << "\n\n";
save_Vnet("v.net");
}
else if (key == 't' || key == 'i')
{
for (int t = 0; t < 500; ++t)
{
// For all states
for (std::list<State>::iterator itr = states1.begin(); itr != states1.end(); ++itr)
{
State s = *itr;
board = s;
int result = hasWinner();
double v;
if (result == -2)
v = 0.5;
else if (result == -1)
v = 0.0;
else if (result == 1)
v = 1.0;
if (result != 0)
train_V(s.x, v);
}
double absError = 0.0; // sum of abs(error)
//.........这里部分代码省略.........
示例3: smoothPath
/**
* @function smoothPath
*/
void PathPlanner::smoothPath( int _robotId,
const Eigen::VectorXi &_links,
std::list<Eigen::VectorXd> &_path ) {
// =========== YOUR CODE HERE ==================
// HINT: Use whatever technique you like better, first try to shorten a path and then you can try to make it smoother
std::cout << "Starting path shortening with simple search..." << _links.size() << std::endl;
std::cout << "start path length: " << _path.size() << std::endl;
std::list<Eigen::VectorXd>::iterator start_point=_path.begin(),end_point=_path.end();
end_point--;
// loop while start has not reached the end of the path
while (start_point != _path.end())
{
if (start_point == end_point)
{
//std::cout << "End iteration\n";
++start_point;
end_point = _path.end();
end_point--;
}
else
{
//Eigen::VectorXd start_node=*start_point, end_node=*end_point;
std::list<Eigen::VectorXd> segment = createPath(_robotId,_links,*start_point, *end_point);
double curDist = countDist(start_point, end_point) * stepSize;
double shortcutDist = segment.size() * stepSize;
if (segment.size()>0 && shortcutDist < curDist)
{
std::cout << "Shortcut length: " << shortcutDist << std::endl;
std::cout << "Current distance: " << curDist << std::endl;
std::cout << "Found shortcut!" << std::endl;
// reconstruct path
// first segment
std::list<Eigen::VectorXd> new_path(_path.begin(), start_point);
// middle segment
new_path.insert(new_path.end(), segment.begin(), segment.end());
// last segment
new_path.insert(new_path.end(), end_point, _path.end());
std::cout << "New path length: " << new_path.size() << std::endl;
// replace optimized
_path = new_path;
start_point = _path.begin();
end_point = _path.end();
end_point--;
}
else
{
--end_point;
}
}
}
std::cout << "Finished Optimizing! Final path length: " << _path.size() << std::endl;
return;
return;
// ========================================
}
示例4: findPluginToolButtonOrCreateInternal
PluginGroupNodePtr
GuiApplicationManagerPrivate::findPluginToolButtonOrCreateInternal(const std::list<PluginGroupNodePtr>& children,
const PluginGroupNodePtr& parent,
const PluginPtr& plugin,
const QStringList& grouping,
const QStringList& groupingIcon)
{
assert(plugin);
assert(groupingIcon.size() == grouping.size() || groupingIcon.isEmpty() );
// On first call of this function, children are top-level toolbuttons
// Otherwise this tree node has children
// We ensure that the path in the tree leading to the plugin in parameter is created by recursing on the children
// If there are no children that means we reached the wanted PluginGroupNode
QString nodeIDToFind;
if (grouping.empty()) {
// Look for plugin ID
nodeIDToFind = QString::fromUtf8(plugin->getPluginID().c_str());
} else {
// Look for grouping menu item
nodeIDToFind = grouping[0];
}
for (std::list<PluginGroupNodePtr>::const_iterator it = children.begin(); it != children.end(); ++it) {
// If we find a node with the same ID, then we found it already.
if ( (*it)->getTreeNodeID() == nodeIDToFind ) {
if (grouping.empty()) {
// This is a leaf (plug-in), return it
return *it;
} else {
// This is an intermidiate menu item, recurse
QStringList newGrouping, newIconsGrouping;
for (int i = 1; i < grouping.size(); ++i) {
newGrouping.push_back(grouping[i]);
}
for (int i = 1; i < groupingIcon.size(); ++i) {
newIconsGrouping.push_back(groupingIcon[i]);
}
return findPluginToolButtonOrCreateInternal( (*it)->getChildren(), *it, plugin, newGrouping, newIconsGrouping);
}
}
}
// Ok the PluginGroupNode does not exist yet, create it
QString treeNodeName, iconFilePath;
if (grouping.empty()) {
// This is a leaf (plug-in), take the plug-in label and icon
treeNodeName = QString::fromUtf8(plugin->getLabelWithoutSuffix().c_str());
iconFilePath = QString::fromUtf8(plugin->getProperty<std::string>(kNatronPluginPropIconFilePath).c_str());
} else {
// For menu items, take from grouping
treeNodeName = grouping[0];
iconFilePath = groupingIcon.isEmpty() ? QString() : groupingIcon[0];
}
PluginGroupNodePtr ret(new PluginGroupNode(grouping.empty() ? plugin : PluginPtr(), treeNodeName, iconFilePath));
// If there is a parent, add it as a child
if (parent) {
parent->tryAddChild(ret);
ret->setParent(parent);
} else {
// No parent, this is a top-level toolbutton
_topLevelToolButtons.push_back(ret);
}
// If we still did not reach the desired tree node, find it, advancing (removing the first item) in the grouping
if (!grouping.empty()) {
QStringList newGrouping, newIconsGrouping;
for (int i = 1; i < grouping.size(); ++i) {
newGrouping.push_back(grouping[i]);
}
for (int i = 1; i < groupingIcon.size(); ++i) {
newIconsGrouping.push_back(groupingIcon[i]);
}
return findPluginToolButtonOrCreateInternal(ret->getChildren(), ret, plugin, newGrouping, newIconsGrouping);
}
return ret;
} // GuiApplicationManagerPrivate::findPluginToolButtonOrCreateInternal
示例5: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if (TreeForm_Timer <= diff)
{
Talk(SAY_TREE);
if (me->IsNonMeleeSpellCast(false))
me->InterruptNonMeleeSpells(true);
me->RemoveAllAuras();
DoCast(me, SPELL_SUMMON_FRAYER, true);
DoCast(me, SPELL_TRANQUILITY, true);
DoCast(me, SPELL_TREE_FORM, true);
me->GetMotionMaster()->MoveIdle();
MoveFree = false;
TreeForm_Timer = 75000;
}
else
TreeForm_Timer -= diff;
if (!MoveFree)
{
if (MoveCheck_Timer <= diff)
{
if (!Adds_List.empty())
{
for (std::list<uint64>::iterator itr = Adds_List.begin(); itr != Adds_List.end(); ++itr)
{
if (Unit* temp = Unit::GetUnit(*me, *itr))
{
if (!temp->IsAlive())
{
Adds_List.erase(itr);
++DeadAddsCount;
break;
}
}
}
}
if (DeadAddsCount < 3 && TreeForm_Timer-30000 <= diff)
DeadAddsCount = 3;
if (DeadAddsCount >= 3)
{
Adds_List.clear();
DeadAddsCount = 0;
me->InterruptNonMeleeSpells(true);
me->RemoveAllAuras();
me->GetMotionMaster()->MoveChase(me->GetVictim());
MoveFree = true;
}
MoveCheck_Timer = 500;
}
else
MoveCheck_Timer -= diff;
return;
}
/*if (me->HasAura(SPELL_TREE_FORM, 0) || me->HasAura(SPELL_TRANQUILITY, 0))
return;*/
//one random seedling every 5 secs, but not in tree form
if (SummonSeedling_Timer <= diff)
{
DoSummonSeedling();
SummonSeedling_Timer = 6000;
}
else
SummonSeedling_Timer -= diff;
DoMeleeAttackIfReady();
}
示例6: main_RCONDialogCallback
BOOL CALLBACK main_RCONDialogCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
char szBuffer[128];
switch ( Message )
{
case WM_CTLCOLORSTATIC:
switch ( GetDlgCtrlID( (HWND) lParam ))
{
// Paint these two labels (and the disconnct button's background) white.
case IDCANCEL:
case IDC_STATUS:
case IDC_SERVERSUBINFO:
return (LRESULT) g_hWhiteBrush;
// Ignore everything else.
default:
return NULL;
}
break;
case WM_PAINT:
{
// Paint the top of the form white.
PAINTSTRUCT Ps;
RECT r;
r.left = 0;
r.top = 0;
r.bottom = 48;
r.right = 800;
main_PaintRectangle( BeginPaint(hDlg, &Ps), &r, RGB(255, 255, 255));
}
break;
case WM_INITDIALOG:
// Hide the old dialog, and take its place.
ShowWindow( g_hDlg, SW_HIDE );
g_hDlg = hDlg;
SendDlgItemMessage( hDlg, IDC_CONSOLEBOX, EM_SETLIMITTEXT, 4096, 0 );
SendDlgItemMessage( hDlg, IDC_INPUTBOX, EM_SETLIMITTEXT, 256, 0 );
SetWindowText( hDlg, g_szHostname );
main_SetState( STATE_CONNECTED );
Printf( "\nMap: %s\n", g_szMapname );
// Fill the console with the received history.
sprintf( szBuffer, "Connected to \"%s\".", g_szHostname );
SetDlgItemText( hDlg, IDC_CONSOLEBOX, szBuffer );
SetDlgItemText( hDlg, IDC_STATUS, szBuffer );
main_UpdateTrayTooltip( szBuffer );
Printf_NoTimestamp( "\n" );
for( std::list<FString>::iterator i = g_RecentConsoleHistory.begin(); i != g_RecentConsoleHistory.end(); ++i )
Printf_NoTimestamp( "%s", *i );
g_RecentConsoleHistory.clear();
// Set up the top, white section.
SendMessage( GetDlgItem( g_hDlg, IDC_STATUS ), WM_SETFONT, (WPARAM) CreateFont( 13, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1 );
LOGBRUSH LogBrush;
LogBrush.lbStyle = BS_SOLID;
LogBrush.lbColor = RGB( 255, 255, 255 );
g_hWhiteBrush = CreateBrushIndirect( &LogBrush );
main_UpdateServerStatus( );
// Set up the player list
LVCOLUMN ColumnData;
ColumnData.mask = LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;
ColumnData.fmt = LVCFMT_LEFT;
ColumnData.cx = 192;
ColumnData.pszText = "Name";
ColumnData.cchTextMax = 64;
ColumnData.iSubItem = 0;
SendDlgItemMessage( hDlg, IDC_PLAYERLIST, LVM_INSERTCOLUMN, COLUMN_NAME, (LPARAM)&ColumnData );
// Add the cached list of players.
LVITEM Item;
Item.mask = LVIF_TEXT;
Item.iSubItem = COLUMN_NAME;
Item.iItem = MAXPLAYERS;
while ( g_InitialPlayers.size( ) )
{
Item.pszText = (LPSTR) g_InitialPlayers.front( ).GetChars( );
g_InitialPlayers.pop_front( );
SendDlgItemMessage( g_hDlg, IDC_PLAYERLIST, LVM_INSERTITEM, 0, (LPARAM)&Item ) ;
}
// Load the icon.
SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) (HICON) LoadImage( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED ));
SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)LoadIcon( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON )));
// Set up the status bar.
g_hDlgStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE, (LPCTSTR)NULL, hDlg, IDC_STATIC);
g_bRCONDialogVisible = true;
break;
case WM_COMMAND:
switch ( LOWORD( wParam ))
{
//.........这里部分代码省略.........
示例7: extract_peers_from_bootstrap_nodes_dat
void extract_peers_from_bootstrap_nodes_dat(const unsigned char *buffer, std::list<Contact *>& bootstrap_list)
{
/*
The header is so composed:
uint32_t reserved0 set to zero
uint32_t reserved1 set to 0x00000003
uint32_t bootstrap_edition nodes.dat bootstrap version
uint32_t num_entries number of entries in the file
*/
if(!bootstrap_list.empty())
return;
uint32_t reserved0 = *(uint32_t *)&(buffer[0]);
uint32_t reserved1 = *(uint32_t *)&(buffer[4]);
uint32_t num_entries = *(uint32_t *)&(buffer[12]);
if(reserved0 != 0 || reserved1 != 3)
// wow: this bootstrap nodes.dat is invalid
return;
unsigned char *peer = (unsigned char *)&(buffer[16]);
/*
The peer is so composed:
uint64_t low_peer_id 128-bit peer identifier (MD4 of node ID)
uint64_t high_peer_id
uint32_t peer_ip IP address of the peer
uint16_t udp_port peer UDP port number
uint16_t tcp_port peer TCP port number
unsigned char version peer contact version
*/
for(unsigned int i = 0; i < num_entries; i++, peer += 25)
{
uint32_t peer_ip = ntohl(*(uint32_t *)&(peer[16]));
uint16_t udp_port = *(uint16_t *)&(peer[20]);
uint16_t tcp_port = *(uint16_t *)&(peer[22]);
unsigned char version = peer[24];
if(version > 7)
{
// Only the 50 closest nodes, please
uint128_t distance(Kad::get_instance().get_client_id());
uint128_t peer_id = uint128_t::get_from_buffer(peer);
distance ^= peer_id;
if(bootstrap_list.size() < 50 || bootstrap_list.back()->get_distance() > distance)
{
Contact *new_peer = new Contact(uint128_t::get_from_buffer(peer),
peer_ip,
udp_port,
tcp_port,
version,
0,
false);
bool peer_added = false;
for(std::list<Contact *>::iterator peerIt = bootstrap_list.begin();
peerIt != bootstrap_list.end();
peerIt++)
{
if((*peerIt)->get_distance() > distance)
{
bootstrap_list.insert(peerIt, new_peer);
peer_added = true;
break;
}
}
if(!peer_added)
{
bootstrap_list.push_back(new_peer);
}
else if(bootstrap_list.size() > 50)
{
delete bootstrap_list.back();
bootstrap_list.pop_back();
}
}
}
}
}
示例8: show
void show() {
std::list<Component*>::iterator i;
for(i = list.begin(); i != list.end(); i++)
(*i)->show();
}
示例9: check_for_bacteria
// This function checks for bacteria to attach to the food nugget.
// This is done here because the bacteria attaches to the food through
// pointers in this class.
void food::check_for_bacteria(std::list<bacteria> & bacteria_list)
{
std::list<bacteria>::iterator bacteria_iterator;
vector food_location = vector(0, 0, x + food_image->get_width() / 2,
y + food_image->get_height() / 2);
// Iterate through the bacteria list:
for(bacteria_iterator = bacteria_list.begin(); bacteria_iterator != bacteria_list.end();
bacteria_iterator++)
{
bacteria & temp = *bacteria_iterator;
vector temp_center = vector(temp.get_vector());
coordinate_pair_t bacteria_dest = temp.get_destination();
float distance = vector::distance_between(temp_center, food_location);
temp_center.set_xy(temp_center.get_x() + bacteria_image->get_width() / 2,
temp_center.get_y() + bacteria_image->get_height() / 2);
// Check if the bacteria is within "smelling distance" of the food:
if(distance <= config_db::get().get_float_value("FoodSmellingDistance")
&& !temp.is_heading_for_food())
{
coordinate_pair_t anchor_temp = this->closest_anchor(temp_center);
if(!(anchor_temp.x == 0 && anchor_temp.y == 0))
temp.set_destination(anchor_temp);
} else if(temp.is_heading_for_food())
{
if(CMP_PAIR(bacteria_dest, ANCHOR_1)
|| CMP_PAIR(bacteria_dest, ANCHOR_2)
|| CMP_PAIR(bacteria_dest, ANCHOR_3)
|| CMP_PAIR(bacteria_dest, ANCHOR_4))
{
if(AT_DESTINATION(temp_center.get_position(), ANCHOR_1))
{
if(anchor_1 != 0 && anchor_1 != &temp)
temp.release();
else {
anchor_1 = &temp;
anchor_1->stop();
}
}
if(AT_DESTINATION(temp_center.get_position(), ANCHOR_2))
{
if(anchor_2 != 0 && anchor_2 != &temp)
temp.release();
else {
anchor_2 = &temp;
anchor_2->stop();
}
}
if(AT_DESTINATION(temp_center.get_position(), ANCHOR_3))
{
if(anchor_3 != 0 && anchor_3 != &temp)
temp.release();
else {
anchor_3 = &temp;
anchor_3->stop();
}
}
if(AT_DESTINATION(temp_center.get_position(), ANCHOR_4))
{
if(anchor_4 != 0 && anchor_4 != &temp)
temp.release();
else {
anchor_4 = &temp;
anchor_4->stop();
}
}
}
}
}
}
示例10: FilterTargets
void FilterTargets(std::list<Unit*>& unitList)
{
if (!GetCaster()->ToPlayer()->GetGroup())
{
unitList.clear();
unitList.push_back(GetCaster());
}
else
{
unitList.remove(GetTargetUnit());
std::list<Unit*> tempTargets;
for (std::list<Unit*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith(*itr))
tempTargets.push_back(*itr);
if (tempTargets.empty())
{
unitList.clear();
FinishCast(SPELL_FAILED_DONT_REPORT);
return;
}
std::list<Unit*>::const_iterator it2 = tempTargets.begin();
std::advance(it2, urand(0, tempTargets.size() - 1));
unitList.clear();
unitList.push_back(*it2);
}
}
示例11: contains
bool contains(OnlineFileRequest* request) const {
return (std::find(queue.begin(), queue.end(), request) != queue.end());
}
示例12: FilterTargets
void FilterTargets(std::list<WorldObject*>& targets)
{
if (Unit* caster = GetCaster())
{
std::list<GameObject*> blockList;
caster->GetGameObjectListWithEntryInGrid(blockList, GO_SARONITE_ROCK, 100.0f);
if (!blockList.empty())
{
for (std::list<WorldObject*>::iterator itrU = targets.begin(); itrU != targets.end(); ++itrU)
if (WorldObject* target = (*itrU))
{
bool valid = true;
if (!caster->IsWithinMeleeRange(target->ToUnit()))
for (std::list<GameObject*>::const_iterator itr = blockList.begin(); itr != blockList.end(); ++itr)
if (!(*itr)->IsInvisibleDueToDespawn())
if ((*itr)->IsInBetween(caster, target, 4.0f))
{
valid = false;
break;
}
if (valid)
{
if (Aura* aur = target->ToUnit()->GetAura(70336))
if (aur->GetStackAmount() >= 10 && caster->GetTypeId() == TYPEID_UNIT)
caster->ToCreature()->AI()->SetData(1, aur->GetStackAmount());
targetList.push_back(*itrU);
}
}
}
else
{
targetList = targets;
return;
}
}
targets = targetList;
}
示例13: BuildListAuctionItems
void WorldSession::BuildListAuctionItems(std::list<AuctionEntry*> &auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin,
uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull)
{
int loc_idx = _player->GetSession()->GetSessionDbLocaleIndex();
for (std::list<AuctionEntry*>::const_iterator itr = auctions.begin(); itr != auctions.end();++itr)
{
AuctionEntry *Aentry = *itr;
if (Aentry->moneyDeliveryTime)
continue;
Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
if (!item)
continue;
if (isFull)
{
++count;
Aentry->BuildAuctionInfo(data);
}
else
{
ItemPrototype const *proto = item->GetProto();
if (itemClass != 0xffffffff && proto->Class != itemClass)
continue;
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
continue;
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
continue;
if (quality != 0xffffffff && proto->Quality < quality)
continue;
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
continue;
if (usable != 0x00 && _player->CanUseItem(item) != EQUIP_ERR_OK)
continue;
std::string name = proto->Name1;
if (name.empty())
continue;
// local name
if (loc_idx >= 0)
{
ItemLocale const *il = sObjectMgr.GetItemLocale(proto->ItemId);
if (il)
{
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx];
}
}
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
continue;
if (count < 50 && totalcount >= listfrom)
{
++count;
Aentry->BuildAuctionInfo(data);
}
}
++totalcount;
}
}
示例14: setRealizeViewList
void ViewCache::setRealizeViewList(std::list <ViewSpec> realizeViewList)
{
LOG4CXX_TRACE(mLogger, "setRealizeViewList");
list <ViewSpec> mReallyUnrealizeViewList;
list <ViewSpec> mReallyRealizeViewList;
// search all views that like to unrealize if maybe one of them is in the next
// realize list and then don't unrealize it
for (std::list <ViewSpec>::iterator v_it = mUnrealizeViewList.begin();
v_it != mUnrealizeViewList.end();
++v_it)
{
ViewSpec &unrealizeViewSpec = *v_it;
//View *unrealizeView = viewSpec.view;
list <ViewSpec>::iterator found_view_it = find(realizeViewList.begin(), realizeViewList.end(), unrealizeViewSpec);
// if view isn't longer in active list mark it to unrealize
if (found_view_it == realizeViewList.end())
{
LOG4CXX_TRACE(mLogger, "push back unrealize view");
mReallyUnrealizeViewList.push_back(unrealizeViewSpec);
}
}
// search all views that like to realize which one are really new and add those to a realize list
for (std::list <ViewSpec>::iterator v_it = realizeViewList.begin();
v_it != realizeViewList.end();
++v_it)
{
ViewSpec &realizeViewSpec = *v_it;
//View *realizeView = viewSpec.view;
list <ViewSpec>::iterator found_view_it = find(mUnrealizeViewList.begin(), mUnrealizeViewList.end(), realizeViewSpec);
// if view isn't in old list mark it to realize
if (found_view_it == mUnrealizeViewList.end())
{
LOG4CXX_TRACE(mLogger, "push back realize view");
mReallyRealizeViewList.push_back(realizeViewSpec);
}
}
// unrealize all before really marked views
for (std::list <ViewSpec>::iterator v_it = mReallyUnrealizeViewList.begin();
v_it != mReallyUnrealizeViewList.end();
++v_it)
{
ViewSpec &reallyUnrealizeViewSpec = *v_it;
View *reallyUnrealizeView = reallyUnrealizeViewSpec.view;
LOG4CXX_TRACE(mLogger, "reallyUnrealizeView->unrealize ()");
reallyUnrealizeView->unrealize();
}
// unrealize all before really marked views
for (std::list <ViewSpec>::iterator v_it = mReallyRealizeViewList.begin();
v_it != mReallyRealizeViewList.end();
++v_it)
{
ViewSpec &reallyRealizeViewSpec = *v_it;
View *reallyRealizeView = reallyRealizeViewSpec.view;
LOG4CXX_TRACE(mLogger, "reallyRealizeView->realize ()");
reallyRealizeView->setLayer(reallyRealizeViewSpec.layer);
reallyRealizeView->realize();
}
}
示例15: strings_to_direction_type
/*-----------------------------------------------------------------*/
bool NOMAD::strings_to_direction_type ( const std::list<std::string> & ls ,
NOMAD::direction_type & dt )
{
dt = NOMAD::UNDEFINED_DIRECTION;
if ( ls.empty() || ls.size() > 4 )
return false;
std::list<std::string>::const_iterator it = ls.begin() , end = ls.end();
std::string s = *it;
NOMAD::toupper ( s );
// no direction:
if ( s == "NONE" )
{
dt = NOMAD::NO_DIRECTION;
return true;
}
// Ortho-MADS with 1, 2, n+1 (plus QUAD or NEG), or 2n directions:
if ( s == "ORTHO" )
{
++it;
if ( it == end )
{
dt = NOMAD::ORTHO_NP1_QUAD; // Default for ORTHO
return true;
}
if ( *it == "1" )
{
dt = NOMAD::ORTHO_1;
return true;
}
if ( *it == "2" )
{
dt = NOMAD::ORTHO_2;
return true;
}
s = *it;
NOMAD::toupper ( s );
if ( s == "2N" )
{
dt = NOMAD::ORTHO_2N;
return true;
}
if ( s == "N+1" )
{
++it;
if (it==end)
{
dt = NOMAD::ORTHO_NP1_QUAD; // Default for ORTHO N+1
return true;
}
s = *it;
NOMAD::toupper ( s );
if ( s=="QUAD" )
{
dt= NOMAD::ORTHO_NP1_QUAD;
return true;
}
if ( s=="NEG" )
{
dt=NOMAD::ORTHO_NP1_NEG;
return true;
}
if ( s=="UNI" )
{
dt=NOMAD::ORTHO_NP1_UNI;
return true;
}
}
return false;
}
// LT-MADS with 1, 2 or 2n directions:
if ( s == "LT" )
{
++it;
if ( it == end )
{
dt = NOMAD::LT_2N;
return true;
}
if ( *it == "1" )
{
dt = NOMAD::LT_1;
return true;
}
if ( *it == "2" )
{
dt = NOMAD::LT_2;
return true;
}
s = *it;
NOMAD::toupper ( s );
if ( s == "N+1" )
//.........这里部分代码省略.........