I use a Chrome plugin that creates a new account each time I post a comment. I use a proxy that means HN can't track the number of accounts I've created. Keeps my privacy.
That's nice little demonstration of superior vector performance for a certain set of (very common) conditions:
# The value type (int in this case) is very small, in fact it's pointer-sized.
# This entire benchmark easily fits into L2 cache. The benchmark only goes up to 100000 elements, which for an int is only 390K. This can be an advantage of vector, but it's not necessarily such a slam-dunk in real-world programs where there are multiple data structures and other threads contending for the use of the cache.
# The value type has 'trivial' copy/move constructors and assignment operators. It's POD and outright memmove()-able.
# The benchmark code is only able to use list nodes one time. It doesn't take advantage of a list's ability to move items from one container to another without reallocation.
# The benchamark is thoroughly randomized. If it were more typical real-world data (such as supplied by another algorithm or even a malicious attacker) then you would want to consider the possibility of pathological access patterns arising.
So if you meet all of these conditions, definitely use a vector. If not, life is back to being complicated again.
That blog post doesn't address the worst-case running time argument, and doesn't measure worst-case running time costs, since it measures batches of 5000 operations at a time. And hey, it's about a workload that totally obviates worst-case running time considerations by requiring a linear scan for every operation.
If you responded by pointing out that even when the vector consumes half of physical memory, the worst case running time isn't going to be any worse than iterating through all of physical memory, which isn't really so bad, and that for the vast majority of vectors it's going to cost less than a page fault, maybe take a couple of microseconds, to copy those values, you might have an argument that actually addressed spinlocked's point.
Of course, std::vectors are only good for copyable types, and copyable types are the devil.
Presbyterian. Well no, but see http://google-styleguide.googlecode.com/svn/trunk/cppguide.x... for some rationale in that direction. Generally speaking you might note that in Java and C#, if you want to copy a data structure, you have to do so explicitly.
Yeah I agree that one should intentionally enable or disable copy and assignment for a type. It might even make sense to disable implicit copying and make an explicit method for it instead.
The C++11 move constructor and move assignment operator seem to me to be a wonderful middle ground.
Not at all. Thanks for posting OP. Any technical discussion is welcome here. Ignore the haters who think STL vectors are a drop in replacement for lists.
"insertions to the end of a variable-length array are very fast"
really tptacek? its O(1) ammortized over time, and when N grows it becomes really slow because it involves reallocation and a linear copy of all elements.
It would be lovely if HN could be a place where people could rise above their petty self interests and help the community move forward. Thomas is at the wrong end of this spectrum.
TheAmazingIdiot is correct BTW. Its hard to imagine Thomas posting his ridiculous views unless he is a paid shill. Probably on your team.
Your views are consistent with a paid or otherwise incentivized "shill" with vested interests in taking the opposite view of any positive legislative action regarding the Swartz case. You knocked the earlier legislative proposal, now you are knocking this.
Lets just sit back and revel in the irony of programmers discussing broad fixes to federal laws, based on insights from reddit comments.
To all the armchair legal experts of HN, here's a challenge: draft legislation that fixes what you propose and post it here.If you can't do that, you are not qualified to comment on the matter.
The EFF has addressed the technology aspects of this. You have ascended into general purpose prosecutorial reform. The legal profession has a vast number of incredibly intelligent people and the legal process has vast nuances, and to think you are an expert in the subject is downright arrogant.
You solve this problem by momentum and visibility, not tossing out arbitrary criticisms.
In the meanwhile, vote up the comment that urges readers to help get this passed.
It's quite disturbing that people expert in technology (such as HN visitors are) should not comment on the matter because they have no 'law' qualification.
Is this 'law' thinghy you are talking about something that only applies to people with 'law' qualifications?
Oh no you say? it applies to everyone ? OMG!
Here's my draft legislation: get rid of the laws used to incriminate Aaron as they are crazy, overreaching and unjust.
No need to polish a turd and I'm sure real crimes are already covered by non computer laws.