| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: C++ |
From: Mike N.
On Fri, 12 Nov 2004 21:50:34 -0500, "Geo" wrote:
>> This allocates only 2 elements instead of allocating a complete linear
>> array from [0..1832873].
>
>very efficient, so what happens if you then set
>
>counts[555]=0
>
>does it give back the space?
Here's where the simple syntax ends and you need an iterator to remove
the element.
map :: interator countsFind;
....
countsFind = counts.find(555);
if (countsFind != counts.end()) {
// Remove element pointed to by countsFind
countsFind.erase();
}
------------------
>I'm not sure I fully understand how this works but it looks pretty slick, is
>it actually setting up 2 arrays to do this because the map function looks
>like what I've always thought of as an array in a language where you have a
>string$ type variable.
It ends up implemented as a binary tree to keep the keys sorted.
Behind the scenes, the template creates a class that contains both the key and value.
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.