Talk:Vector (C++)

message: Why isn't there a template with a box on the right linking this to all the other STL pages? (or C++ Standard Library pages, for that matter?) This should be worked on. Figs 21:35, 4 March 2007 (UTC)
thread_title: Side Box

message: Hi, I am currently considering renaming this article to conform to a common convention for C++ Standard Library components. The full discussion can be found here. decltype 09:46, 6 March 2009 (UTC)
thread_title:  Renaming this article to follow a consistent convention 

message: In the Pros and cons section, one can read the two following statements:
# One major benefit of vectors is that they also allow random access; that is, an element of a vector may be referenced in the same manner as elements of arrays are by array indices whereas linked-lists and sets do not support random access or pointer arithmetic.
# Vectors allow random access; that is, an element of a vector may be referenced in the same manner as elements of arrays (by array indices). Linked-lists and sets, on the other hand, do not support random access or pointer arithmetic.
The second paragraph was contributed later on, did the author forget to remove the first one?
Erebadan (talk) 04:29, 27 May 2009 (UTC)
replies: text: Removed duplicate entry. Nice find. decltype (talk) 05:23, 27 May 2009 (UTC)
thread_title:  Paraphrasing 

message: There shouldn't be any argument that vector is part of the standard template library.  If you think that it isn't, go argue that point with the sidebar people.  —Preceding unsigned comment added by 141.189.251.1 (talk) 15:15, 1 September 2009 (UTC)
replies: text: I suppose I should. This article describes the vector class template of the C++ Standard Library. While this template is largely based on the vector class template in the original 1995 STL, ISO C++ as described in ISO/IEC 14882:2003 has no notion of the Standard Template Library. decltype (talk) 15:29, 1 September 2009 (UTC)
replies: text: I'm going to go ahead and change this page to say Standard Template Library to keep it in aligned with the side bar.  If you have the sidebar changed, you can change this as well.  That way there won't be a confusing discrepancy. 141.189.251.1 (talk) 12:46, 4 September 2009 (UTC)
replies: text: Well, two wrongs does not make a right :) I'll see what I can do about the sidebar. Regards, decltype (talk) 12:50, 4 September 2009 (UTC)
thread_title:  vector is in the template library 

message: I know this is written as a C++ article, but should some mention be made about the existence of the Vector data structure in other languages?  I know for sure that Java has them, and I'm sure there are others as well.  Perhaps this should be given a more generic name, such as "Vector (programming)" or "Vector (data structure)" (to distinguish it from programming geometrical vectors).  And maybe some code samples from other languages could be added.  Much of the rest of the article would be true for any language, so it seems redundant to create a new article for each language (e.g. "Vector (Java)", etc.) Lurlock (talk) 21:33, 26 December 2009 (UTC)
thread_title:  Other languages 

message: well, maybe I'm slow but from the example, "It is located at index 6 (implementation-dependent)" makes no sense to me, it's going to be 7, right? I've tried it in sev'l compilers.--Billymac00 (talk) 18:31, 29 March 2010 (UTC)
replies: text: The numbers have been randomly shuffled using the random_shuffle algorithm. The position of the largest number depends upon the underlying implementation of that algorithm, and the rand function used internally. The result is 6 on VC9. decltype (talk) 18:41, 29 March 2010 (UTC)
replies: text:  yes, obvious now, thanks--Billymac00 (talk) 14:19, 30 March 2010 (UTC)
thread_title:  Useage example 

message: Erasing elements from a vector or even clearing the vector entirely does not necessarily free any of the memory associated with that element. This is because the maximum size of a vector since its creation is a good estimate of the future size of the vector. -- shouldn't the second sentence begin with "Thus" instead of "This is because"?  —Preceding unsigned comment added by 79.160.125.105 (talk) 10:04, 16 May 2011 (UTC)
replies: text: I think the point is that if the current number of elements in the vector is n, then there will probably be about n elements in the vector at some time in the future too.  So when clearing the vector, it's probably not worth freeing up the memory, because it'll probably be needed again soon.  Freeing it up would just then necessitate some expensive reallocation as it grows back to its previous size. Thrapper (talk) 15:07, 25 November 2011 (UTC)

text: You can always use vector::resize to manually shrink the vector if you know that the vector will not grow. 1exec1 (talk) 17:22, 29 November 2011 (UTC)
replies: text: However, that would be equivalent to calling erase, and would not affect memory usage of the vector (capacity is unchanged). decltype (talk) 07:21, 2 December 2011 (UTC)
replies: text: Ah, yes, you correct and I'm totally wrong. Resize never touches the capacity. Having said that, a solution to the problem still exists, even though only in C++11:  vector::shrink_to_fit. 1exec1 (talk) 15:42, 2 December 2011 (UTC)
thread_title:  erasing elements does not deallocate memory _because_(?) initial max size estimates future size 

message: After accidentally stumbling on wctype.h, I've got an idea that it would be a good addition to link the names of the member functions to some external reference. I think we could link to this third-party wiki. It uses the same wiki engine and content licensing terms as the Wikipedia, so as a bonus it could serve as a good place to dump any material that fails WP:NOT#MANUAL. What do others think about this?
P.S. I use that website personally, so there's slight conflict of interest :). Anyways, I think this shouldn't be a problem.1exec1 (talk) 20:39, 1 October 2011 (UTC)
thread_title:  Inline links to an external reference? 

message: There's an ongoing  discussion about an reorganization of the articles about the C++ containers. This page is one of the subjects of that discussion. Please express your opinion. 1exec1 (talk) 20:15, 2 December 2011 (UTC)
thread_title:  Reorganization