From -8835041625125781364
X-Google-Thread: f78e5,27c2a088314ec0a9
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news4.google.com!news.glorb.com!news2.telebyte.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: dhruvbird@gmx.net ("Dhruv Matani")
Newsgroups: comp.std.c++
Subject: Re: should std::vector<> exponential growth rate be followed	strictly in times of low availabe memory.
Date: Fri,  5 Nov 2004 06:18:04 GMT
Lines: 52
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <pan.2004.11.05.03.41.18.655290@gmx.net>
References: <pan.2004.10.21.16.46.37.514542@gmx.net>	<417E434E.5000209@bubblescope.net> <pan.2004.10.27.02.38.48.35649@gmx.net>	<4fvjo0t07isfber4rblifh56jmiq2glrnj@4ax.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.demon.co.uk 1099635494 25439 158.152.254.254 (5 Nov 2004 06:18:14 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Fri, 5 Nov 2004 06:18:14 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Pan/0.13.3 (That cat's something I can't explain)
X-Orig-X-Trace: news.uni-berlin.de oAaHzw+KLfyWiAOs8yS5lwHibMpNiUwTxK1m+FZBzdCIR2P3Ql
X-Virus-Scanned: by amavisd-new at cs.mu.OZ.AU
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id iA56I4rM004265;
	Fri, 5 Nov 2004 17:18:04 +1100 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:3289

On Thu, 04 Nov 2004 22:29:30 +0000, Tom Widmer wrote:

> On Wed, 27 Oct 2004 03:43:46 GMT, dhruvbird@gmx.net ("Dhruv Matani")
> wrote:
> 
>>Yes, but it would obviously be a nonsense implementation as you have
>>mentioned. I'm looking more at making it allowable by the standard in
>>such low memory situations to deviate from the exponential growth
>>policy.
> 
> And the standard already allows that, since it doesn't specify
> "exponential growth", but rather amortized constant time push_back.
> 
> However, I don't think a 1GB+ std::vector is a very good idea in any
> case. If you use malloc, then you get access to realloc, or you should
> perhaps be using a custom allocator, or redesigning your algorithm,
> perhaps to allow a segmented container of some kind, or to use less
> RAM.

Yes, but in certain cases, it becomes necessary for using such big
vectors. Like in my case, I want to use it as a replacement for
std::multimap<>, because:
1. The locality of the nodes is destroyed by the re-balancing algorithm,
and
2. Every insertion involves touching a lot of data, so places where data
is coming in at a very fast rate, this is unacceptable.

So, I would rather use a vector and then sort it after all the insertions
are over.(because the application/use happens to be ammenable to that
change).

Here, I know in advance the maximum size of the vector, but in other cases
I might not. Now, given that fact that I have say 2GB of Phy. mem. I
should not be consrtained by the exponential growth policy.

Also, as others have mentioned, the underlying implementation could use
1.5 as the factor, but then, again that would cause a lot of copies
unnecessarily. Esp. for a heavy copying object.

But, then again looking at Dave Harris' reply, I'm not quite convinced
about the way I'm using vector?
Maybe?

Reards,
-Dhruv.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



