I am trying to delete some elements from an std::map. In particular the elements that have      value = 100   should be deleted. However after running the following piece of code a bug occurs. An element with value 100 appears in the remaining map, after the erase(it) method. Where is the bug?   Code:  #include &lt;iostream&gt; #include &lt;map&gt;  int main() {     std::map&lt;int, int&gt; outcomes;     outcomes.clear();      if ( !outcomes.insert( std::make_pair( 10, 1 ) ).second )          return 0;     if ( !outcomes.insert( std::make_pair( 11, 100 ) ).second )          return 0;     if ( !outcomes.insert( std::make_pair( 12, 100 ) ).second )          return 0;     if ( !outcomes.insert( std::make_pair( 13, 100 ) ).second )          return 0;     if ( !outcomes.insert( std::make_pair( 14, 100 ) ).second )          return 0;     if ( !outcomes.insert( std::make_pair( 15, 101 ) ).second )          return 0;     if ( !outcomes.insert( std::make_pair( 16, 101 ) ).second )         return 0;     if ( !outcomes.insert( std::make_pair( 17, 100 ) ).second )         return 0;      std::map&lt;int, int&gt;::iterator it = outcomes.begin();     while(it != outcomes.end())     {         std::cout&lt;&lt;it-&gt;first&lt;&lt;" :: "&lt;&lt;it-&gt;second&lt;&lt;std::endl;         it++;     }      it = outcomes.begin();     while(it != outcomes.end())     {         if( it-&gt;second == 100 )             outcomes.erase(it);         it++;     }     std::cout &lt;&lt; "after delete" &lt;&lt; std::endl;     it = outcomes.begin();     while(it != outcomes.end())     {         std::cout&lt;&lt;it-&gt;first&lt;&lt;" :: "&lt;&lt;it-&gt;second&lt;&lt;std::endl;         it++;     }     return 0; }     Result is the following:  10 :: 1 11 :: 100 12 :: 100 13 :: 100 14 :: 100 15 :: 101 16 :: 101 17 :: 100 after delete 10 :: 1 14 :: 100 15 :: 101 16 :: 101
In the following code I loop through a map and test if an element needs to be erased.  Is it safe to erase the element and keep iterating or do I need to collect the keys in another container and do a second loop to call the erase()?  map&lt;string, SerialdMsg::SerialFunction_t&gt;::iterator pm_it; for (pm_it = port_map.begin(); pm_it != port_map.end(); pm_it++) {     if (pm_it-&gt;second == delete_this_id) {         port_map.erase(pm_it-&gt;first);     } }   UPDATE: Of course, I then  which I didn't think would be related but answers my question.
what does ∇ (upside down triangle) symbol mean in this problem Given $f(x) = \frac{1}{2}x^TAx + b^Tx + \alpha $   where A is an nxn symmetric matrix, b is an n-dimensional vector, and alpha a scalar. Show that  $\bigtriangledown _{x}f(x) = Ax + b$   and  $H = \bigtriangledown ^{2}_{x}f(x) = A$   Is this simply a matter of taking a derivative with respect to X, how would you attack this one? How can I reuse existing materials, objects, etc from an existing .blend? How to make a table from two lists? If APS-C and similar crop-sensor digital cameras have a focal length multiplying effect such that a 50mm lens has an apparent focal length closer to the field of view of an 80mm on a full frame camera, and yet at the same time the depth of field for the smaller sensor camera is more like the depth of field a 50mm lens would produce on a full frame camera (using the same aperture), then this would seem to suggest the concept of an "aperture dividing effect."  In other words, a 50mm f/1.8 lens on an APS-C camera would act more like a 80mm f/2.8 (approx. 1.8 * 1.6x) lens in 35mm equivalent — for depth of field, not considering exposure.  Can someone with a better understanding of the physics involved clarify this for me.  I've never seen this concept explicitly mentioned anywhere, so I am a bit suspect of it. Cursor hitting "border" between differently sized monitors I'm not sure if I'll be to explain this right. I have a dual monitor display on Windows 7 and my left monitor (laptop) has a lower vertical resolution than the right monitor (regular LCD monitor). So obviously, if I stick these monitors together, there's a part in the upper-left corner of my LCD monitor where cursor cannot go to the other monitor. I remember there was a trick to make this gap disappear, and make it seem like the monitors are of equal height.  Any suggestions?  By the way, I am also using UltraMon. I want to do an , then cross-validate model prediction accuracy with 80% data for training and 20% for validation, and calculate  for predictions.  Consider this dataset:    X     Y ----------  2.3    1  3.1    2  3.5    2  10.0   5  6.8    4  5.0    3  5.4    2  3.2    1   I did this:  x=c(2.3,3.1,3.5,10.0,6.8,5.0,5.4,3.2) y=c(1,2,2,5,4,3,2,1) myData=data.frame(cbind(x,y))  library("MASS") reg=polr(as.factor(myData$y)~myData$x,data=myData,method="probit")   I saw , but I couldn't fully understand. Suppose myValidationData contains 20% of data which I want to use for validation. So, I would do:  fit=predict(reg,type="probs") x=c(5.6, 5.1) y=c(3,3) myValidationData=data.frame(cbind(x,y))   This is how I tried to predict, but is it correct, when I want to cross-validate?  fit=predict(reg,data=myValidationData,type="probs")   How should I measure RMSE? And, how can I plot the prediction? In Avengers: Age of Ultron movie,      Ultron infected tech of Avengers Tower just after his birth. It means he is capable of infecting tech. Also, if this wasn't the case, he could never be able to create his drones.   Just after its birth,      He escaped using the Internet and infected digital devices across the entire planet. Again, awesome capability (think Skynet).   We also saw that      Iron Man's armor was connected to the Internet. He googled for the keyword "Hulk" during flight just before he deployed Veronica.   Then, why did Ultron let Iron Man win the fight? Why didn't he simply hack Iron Man's armor to use him as own drone? I want to monitor private message and want to check and store at admin side. so admin can see who doing message to whom and make the policy for to sending the message. Do Israeli security agents interview all those flying to Israel or is it restricted to El Al flights? The one thing I hate about flying to Israel are the security checks at the origin airports. I don't mind X-rays and deep luggage searches, but there's also an annoying interview you have to "pass". The security folks can't really turn you down (especially since I'm a citizen), but they always make it a pain in the butt, because for some reason I fit their profile of a suspicious person.  Can I avoid the personal interviews if I book on a non-Israeli airline? Or perhaps a low-cost airline? When I use any variation of English, US international (with dead keys,altGr dead keys or alternative) on my Linux Mint machine I always encounter this behaviour. When I press one of these keys: ' " and then follow them with a 'non-accentable' character like a [ or a b no output comes out at all.    Whereas in Windows US-International it would print [ or b. If I wanted to type this I would have to escape each dead key with a space instead of with any 'non-accentable' character. This is annoying when programming (not really, but I trained with the Windows 'Qwerty International' on typing.io and switching back and forth between the systems is irritating).    Is there any way to change that so it works like in Windows? Links to the Wayback Machine are broken in chat transcript is an example of the bug. It looks like this in regular chat:  That link points to: http://web.archive.org/web/20080409050311/http://personalpages.manchester.ac.uk/staff/daryn.lehoux/Tropes.pdf  In the transcript, it looks like this:  That link points to: http://web.archive.org/web/20080409050311/%3Ca%20href=  ... which doesn't work so well! Could this be fixed? I'm not sure if this impacts links to elsewhere. Limits of sequences of sets I am starting to learn about the liminf and limsup of a sequence of sets. However, I do not understand the very basics, such as why $\lim\sup A_n=\bigcap_{n\in N}\bigcup_{k&gt;n} A_k,$ and why $\lim\sup A_n=\bigcup_{n\in N}\bigcap_{k&gt;n}A_k.$ Can someone break these definitions down for me?  Also, why is $\lim\inf\subseteq\lim\sup$? MikTeX 2.9, install packages on the fly? Create custom fields with apex Anybody knows how to create custom text fields on salesforce.com objects using apex? Deleting comment removes "Add comment" link on Mobile If I delete a comment on the mobile version of the site (at least if it's the only comment on an answer), the "Add comment" link will vanish along with the comment, so I have to reload to leave another comment.     but got declined as , which is why I'm reposting this (as it may well be a new bug with the same symptoms).  I'm using Firefox 32.0.3 on Android. How to start git-gui? Using pgfplots, why do I get "undefined control sequence" when trying to use a foreach variable as a parameter to addplot? Since I have multiple plots with error bars, I would like to shift the error bars slightly to make the overall plot more readable. However, when I try to do this using the variable of a \foreach as the amount to shift, I get an "undefined control sequence" error.  \documentclass{article}  \usepackage{tikz} \usepackage{pgfplots}  \begin{document}  \begin{tikzpicture} \begin{axis} \foreach \x/\y in {a/-1cm, b/0cm, c/1cm} {     \addplot+ [         %every error bar/.append style={xshift=\y},         %every node/.style={xshift=\y},         error bars/y dir=both,         error bars/y explicit,     ] coordinates {         (0, 0) +- (0, 1)         (1, 0) +- (0, 1)         (2, 0) +- (0, 1)     }; } \end{axis} \end{tikzpicture}  \end{document}   (The document does not compile when I uncomment either one of the two comments.)  What's wrong here?  EDIT: Added another variable to the \foreach. In my actual use-case it would contain the filename to plot data from or the label to use for the curve. Understanding the parameters inside the Negative Binomial Distribution I was trying to fit my data into various models and figured out that the fitdistr function from library MASS of R gives me Negative Binomial as the best-fit. Now from the  page, the definition is given as:     NegBin(r,p) distribution describes the probability of k failures and r   successes in k+r Bernoulli(p) trials   with success on the last trial.   Using R to perform model fitting gives me two parameters mean and dispersion parameter. I am not understanding how to interpret these because I cannot see these parameters on the wiki page. All I can see is the following formula:    where k is the number of observations and r=0...n. Now how do I relate these with the parameters given by R? The help file does not provide much information either.   Also, just to say a few words about my experiment: In a social experiment that I was conducting, I was trying to count the number of people each user contacted in a period of 10 days. The population size was 100 for the experiment.   Now, if the model fits the Negative Binomial, I can blindly say that it follows that distribution but I really want to understand the intuitive meaning behind this. What does it mean to say that the number of people contacted by my test subjects follows a negative binomial distribution? Can someone please help clarify this? This is a follow up question to . My reference database contains some DOI codes, but mainly normal URLs and some ISBN/ISSN codes. What I would like to achieve is extending the code from Herbert and hyperlink the title of the entry with the following priority: 1. DOI, 2. URL, 3. ISBN/ISSN. What I mean is, if both DOI and URL is available, use DOI. If URL and ISBN is available use URL. If only ISBN is available use that.  There are two further isses:    The URL field might contain several URLs, which are just seperated by a white space. In that case just the first URL should be used.  Herbert's code just extends to articles. I would like to extend this to all entry types.   The code from Herbert to Hyperlink the Title with DOIs is:   \newbibmacro{string+doi}[1]{%   \iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}} \DeclareFieldFormat{title}{\usebibmacro{string+doi}{\mkbibemph{#1}}} \DeclareFieldFormat[article]{title}{\usebibmacro{string+doi}{\mkbibquote{#1}}}   This far surpasses my skill, so it would be great if someone could give me some guidance how to achieve that. I can't see my background image in the 3D view I try to set up an image as background for a basic blender tutorial, but it isn't visible.  This is the image I try to have as background: