As a C++ newbie, I am just discovering iterators. I realize that one can use either an int or an iterators for loop through any container. Consider for example  #include &lt;iostream&gt; #include &lt;vector&gt;  int main() {     std::vector&lt;int&gt; v;     v.push_back(1);     v.push_back(4);     v.push_back(8);      std::cout &lt;&lt; "i is an int: ";      for (int i = 0; i&lt;v.size();i++)     {        std::cout &lt;&lt; v[i] &lt;&lt; " ";     }     std::cout &lt;&lt; std::endl;      std::cout &lt;&lt; "i is an iterator: ";     for (std::vector&lt;int&gt;::iterator i = v.begin(); i!=v.end();i++)     {        std::cout &lt;&lt; *i &lt;&lt; " ";     }     std::cout &lt;&lt; std::endl; }   which outputs  i is an int: 1 4 8                                                                                                                                    i is an iterator: 1 4 8     Generally speaking,   is there any advantage of using one or the other method? Is one faster than the other one? When should I use an int and when should I use an iterator?
Take the following two lines of code:  for (int i = 0; i &lt; some_vector.size(); i++) {     //do stuff }   And this:  for (some_iterator = some_vector.begin(); some_iterator != some_vector.end();     some_iterator++) {     //do stuff }   I'm told that the second way is preferred. Why exactly is this?
Database design help. many-to-many relationship For all $a, m, n \in \mathbb{Z}^+$,   $$\gcd(a^n - 1, a^m - 1) = a^{\gcd(n, m)} - 1$$ Finding an expression for $\tan (a+ b + y)$ which involves only $\tan a, \tan b,$ and $\tan y$. I love making our own bread - we rarely buy shop bought, but it tends to go off very quickly. Part of the appeal is that it doesn't have any "junk" in it - artificial preservatives - which I'm sure contributes to the lovely flavor. Is there anything natural I can add to it to stop it going moldy so fast? Dual Canadian and British citizen - healthcare coverage in the UK? How are answers with the same vote score sorted? How to find historical stock price for a de-listed or defunct company? If refraction slows down light, isn't it possible to hold light still? I have a quick question about the refraction of light, and I'm sorry if it seems a bit simplistic or even stupid, but I'm still learning.  We know that when light passes through a denser medium, it slows down. However, is there a limit to that slowing down? If no, wouldn't it be possible, with some type of medium we make ourselves (like a crystal), to decrease the light's speed down to a point where we would be able to "see the photons moving forwards"?  I know it is way more complicated than that and that you can't see light unless some other light bounces off it, what I mean is slowing down light to an extreme and unusual speed). That sounds completely absurd but I can't seem to find what is wrong. Can anyone can explain it to me? :) In the movies, the pack of Uruk-Hai capture Merry and Pippin, and are bringing them back to Saruman as quickly as possible.  Why didn't they use Wargs to carry the Hobbits instead of packing them on their backs?    Or, better yet, why didn't the Nazgul fly down and take them on their Fell Beasts? Forcing smoothness of regression coefficients Which Jedi have served in the Rebellion? Besides Luke Skywalker, Kanan Jarrus, Ezra Bridger and Ahsoka Tano, which other Jedi, regardless of whether they were survivors of Order 66 or became one at a later point, served within the Rebellion's ranks during the Galactic Civil War?  Looking for both canon and Legends versions.  Edit: ok, just to clarify what would qualify as a Jedi for the answer. Loosely speaking, anyone who follow the ideals of the Jedi philosophy - a practitioner in the ways of the Force, a protector of the galaxy, and an opposer to the dark side - would count.   Only trained Force users, not aligned with the dark side, would count. They need to be able to consciously control their use of the Force to aid the Rebellion. This excludes Leia Members of the Jedi Order of the late Republic would obviously count. However, they need to have survived Order 66 (duh), did not renounce the Jedi ways nor succumbed to the dark side, and become a member of the Rebellion. This excludes the Grand Inquisitor nor Darth Vader, but includes Kanan Jarrus and, in Legends, Rahm Kota. Those who are killed in action after joining the Rebellion also count. However, you don't need to be an official member of the order to be counted. You could be opposed to what was wrong with the late order, but as long as you follow the ideals defined above, and identify with them, you are a Jedi at heart by the count of this question. This counts Ahsoka Tano, Luke Skywalker and Ezra Bridger among its number. They aren't in the old Jedi Order's roster, but they believe in what the Jedi are meant to be, and follow its ways in that regard. Galen Marek in Legends, when he genuinely turned to the ways of the light, even though he was still a user of dark side powers, would be one. It's the thought that counts.   So loosely speaking, that means members of the Rebellion who are trained Force sensitives and genuine good guys. Intuitive explanation for formula of maximum length of a pipe moving around a corner? For one of my homework problems, we had to try and find the maximum possible length $L$ of a pipe (indicated in red) such that it can be moved around a corner with corridor lengths $A$ and $B$ (assuming everything is 2d, not 3d):    My professor walked us through how to derive a formula for the maximum possible length of the pipe, ultimately arriving at the equation $L = (A^{2/3} + B^{2/3})^{3/2}$.  The issue I have is understanding intuitively why this formula works, and exactly what it's doing. I understand the steps taken to get to this point, but there's an odd symmetry to the end result -- for example, is the fact that $\frac{2}{3}$ and its inverse are the only constants used just a coincidence, or indicative of some deeper relationship?  I also don't quite understand how the formula relates, geometrically, to the diagram. If I hadn't traced the steps myself, I would have never guessed that the formula was in any way related to the original problem.  If possible, can somebody give an intuitive explanation as to why this formula works, and how to interpret it geometrically?    Here's how he found the formula, if it's useful:  The formula is found by finding the maximum possible length of the pipe by expressing the length in terms of the angle $\theta$ formed between the pipe and the wall, and by taking the derivative to find when $\frac{dL}{d\theta} = 0$, which is the minimum of $\frac{dL}{d\theta}$ and is therefore when $L$ is the smallest:  $$ L = \min_{0 \leq \theta \leq \frac{\pi}{2}} \frac{A}{\cos{\theta}} + \frac{B}{\sin{\theta}} \\ 0 = \frac{dL}{d\theta} = \frac{A\sin{\theta}}{\cos^2{\theta}} - \frac{B\cos{\theta}}{\sin^2{\theta}} \\ 0 = \frac{A\sin^3{\theta} - B\cos^3{\theta}}{\sin^2{\theta}\cos^2{\theta}} \\ 0 = A\sin^3{\theta} - B\cos^3{\theta} \\ \frac{B}{A} = \tan^3{\theta} \\ \theta = \arctan{\left( \frac{B}{A} \right)^{\frac{1}{3}}} \\ $$  At this point, we can substitute $\theta$ back into the original equation for $L$ by interpreting $A^{1/3}$ and $B^{1/3}$ as sides of a triangle with angle $\theta$ and hypotenuse $\sqrt{A^{2/3} + B^{2/3} }$:  $$ \cos{\theta} = \frac{A^{1/3}}{ \sqrt{A^{2/3} + B^{2/3} }} \\ \sin{\theta} = \frac{B^{1/3}}{ \sqrt{A^{2/3} + B^{2/3} }} \\ \therefore L = A^{2/3} \sqrt{A^{2/3} + B^{2/3} } + B^{2/3} \sqrt{A^{2/3} + B^{2/3} } \\ L = (A^{2/3} + B^{2/3}) \sqrt{A^{2/3} + B^{2/3} } \\ L = (A^{2/3} + B^{2/3})^{3/2} \\ $$  The equation for the formula for the maximum length of the pipe is therefore $L = (A^{2/3} + B^{2/3})^{3/2}$. How do I find out a name of class that created an instance of an object in Python if the function I am doing this from is the base class of which the class of the instance has been derived?  Was thinking maybe  might have helped me out here, but it doesn't seem to give me what I want. And short of parsing the __class__ member, I'm not sure how to get at this information. How to make a pattern follow a stroke, path or line? Here is my MS Paint job on a real bad attempt at what I'm trying to achieve:    I have access to Photoshop and Illustrator CS6, and I want to be able to draw a thick line (that is not straight) and have a pattern within the line show arrowheads within the line to indicate the direction of the line. A week ago I  people on this site what mathematical background was needed for understanding Quantum Physics, and most of you mentioned Linear Algebra, so I decided to conduct a self-study of Linear Algebra. Of course, I'm just 1 week in, but I have some questions.    How is this going to be applicable to quantum physics? I have learned about matrices (addition, subtraction, multiplication and inversion) and about how to solve multiple equations with 3 unknowns using matrices, and now I am starting to learn about vectors. I am just 1 week in, so this is probably not even the tip of the iceberg, but I want to know how this is going to help me.  Also, say I master Linear Algebra in general in half a year (I'm in high school but I'm extremely fast with maths), what other 'types' of math would I need to self-study before being able to understand rudimentary quantum physics mathematically? Turning off "Update page numbers only" in Word When I update the fields document-wide (Ctrl + A, then F9) in a Word document that has a table of contents, a dialog appears asking if I want to update page numbers only, or update the entire table. I never want to update page numbers only if the document headings have changed, nor will I ever.  (Apparently this is given as an option in case someone has manually changed an automatically generated ToC, which is almost always a really bad idea.)   Unfortunately, "Update page numbers only" is the default selection in the dialog, which means that I have to select the other option every time. I update the fields all the time when I'm working in a document that has figures and cross-references, so this is an annoying extra step I'd really like to get rid of.   Is there any way to tell Word to stop asking me this stupid unnecessary question? Killing thread after some specified time limit in Java Two question on harmonic function "wait more than" vs. "wait FOR more than" What is a meta for? A guest at my house over the weekend stood puzzled next to my driveway. &quot;What is that for?&quot; she asked, pointing to a framework of 2x4s and hardware cloth perched on an old tire amid piles of sand. &quot;Sifter.&quot; I said. &quot;For what?&quot; &quot;For sifting gravel.&quot; &quot;Why?&quot; &quot;To line walking paths, such as the one you're standing on...&quot; Spend enough time working with something, and it's easy to forget how strange and unnatural your makeshift tooling can appear to those unfamiliar with it.  Such is the nature of these meta sites. For 5 years, we've been directing folks to them for discussion and feedback, to commune with their community, hash out misunderstandings, propose changes and document the current state of things. And... We haven't always been good about helping them get past the initial shock and confusion of dealing with this system. This has manifested in several unfortunate behaviors:  Downvoting of legitimate support questions - those that are not duplicates and reflect an actual bug or honest misunderstanding of how the system operates. Folks who are acting in good faith should be treated as such - , not shutting them down.  Closing questions that seek input and discussion from the community - in hindsight, adding &quot;primarily opinion based&quot; as a close reason on meta sites was... a terrible idea. The old &quot;not constructive&quot; close reason made some sense for rants and so on, but for a discussion site closing down questions that solicit opinions is just silly. Here on MSE, we prefer the following off-topic reason instead:  This question does not appear to seek input and discussion from the community. If you have encountered a problem on one of our sites, please describe it in detail. See also:    The perception that Stack Exchange is disrupting the normal operation of the site by talking about future plans - even when those plans involve the community. I talked about this a bit more on , but seeing this kind of backlash toward folks at the company who were trying to be open and receptive to discussion about what they were doing was kinda disheartening - we need to be doing more of that, not less.  A reluctance to ask questions about asking questions - which is about as meta as you can get, and yet we probably get more of these via email than we see on meta, while being the least-qualified to answer them well.   After an increasing number of complaints from both core users and moderators on a number of sites, we're taking a hard look at how we can improve this situation... Starting with a change to :  Meta is for...  ...$SiteName users to communicate with each other about $SiteName (asking questions about how the websites work, or about policies and community decisions) ...$SiteName  users to communicate with Stack Exchange the company (posting bugs, suggesting improvements, or proposing new features), and ...Stack Exchange to communicate with the community (soliciting feedback on new ideas or features, or discussing policies that affect the whole network)  Lots of topics are fair game, as long as they are about the Stack Exchange family of Q&amp;A sites in some way. Any issue that concerns the core Stack Exchange engine that runs all Stack Exchange websites is welcome here.  This replaces the previous bullet list of specific topics, and aims to outline broad purposes with examples for clarification rather than constraining the scope to those examples. So... that's a start. But a documentation change isn't going to change misconceptions that've already built up among newer users. So I'm asking y'all for help: What do you think meta should be used for, and how can we better communicate this intent to new users?