#### map two into one with special iterator

Cheers!

Following scenario: I have a nested list of vectors of Foos[1]. I want to
have an iterator with which I can access all Foos as a sequence. What I'd
like to confirm is that I didn't miss anything in my solution, because I'm
not sure if I really need the third iterator (but I can't seem to find a
way to do without it ...).

Up to now, I have basically the following:

class foo_iterator:
methods:
operator++();
data:
list::iterator lit;
list::iterator lit_end;
vector::iterator vit;

'lit_end' points to the end of the list while 'lit' and 'vit' are normal
iterators to the current position. The method for incrementing an iterator
looks like this:

foo_iterator::operator++():
++vit;
if(vit == lit->end)
++lit;
if(lit!=lit_end)
vit=lit->begin;

Here was the first time I needed 'lit_end' because I must not dereference
'lit' when it reaches the end but need to set 'vit' to the beginning of the
next element otherwise.

The function for comparing iterators looks like this:

bool operator=(foo_iterator it1, foo_iterator it2):
// if the two iterators are not from the same sequence they
// are different [2]
if(it1.lit_end != it2.lit_end)
return false;
// if the current position in the list differs they are different
if(it1.lit != it2.lit)
return false;
// if both positions in the list are at the end (and we know that
// either both or none of them are) they are equal
if(it1.lit == it1.lit_end)
return true;
// the only possible difference is in the position inside the vector
return (it1.vit == it2.vit);

Here again, I had to add a special case for the end-iterator because it has
an undefined 'vit'.

The only other way to solve this problem that I could think of was to have a
flag whether 'vit' is valid and only evaluate it in comparisons if that
flag is set and set 'vit' to 'lit->begin' on demand when the foo_iterator
is dereferenced. That solution however requires a test on each
dereferenciation and mutable 'vit' and valid-flag.

Does anyone have a better solution to this problem ?

thank you,
Ulrich Eckhardt

[1] the exact container-types should not matter

[2] writing this, I started wondering how iterators of the stdlib compare
when they come from different containers. Undefined? Container-specific?
Unequal?

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Ulrich
8/5/2003 7:28:06 AM
comp.lang.c++.moderated 10706 articles. 11 followers. allnor (8507) is leader.

5 Replies
219 Views

Similar Articles

[PageSpeed] 5
"Ulrich Eckhardt" <doomster@knuut.de> wrote in message
news:bgm2ck$q09i1$1@ID-178288.news.uni-berlin.de...
| Following scenario: I have a nested list of vectors of Foos[1]. I
want to
| have an iterator with which I can access all Foos as a sequence. What
I'd
| like to confirm is that I didn't miss anything in my solution,
because I'm
| not sure if I really need the third iterator (but I can't seem to
find a
| way to do without it ...).
|
| Up to now, I have basically the following:
|
| class foo_iterator:
|    methods:
|      operator++();
|    data:
|      list::iterator lit;
|      list::iterator lit_end;
|      vector::iterator vit;

Let me try to discard lit_end...

| 'lit_end' points to the end of the list while 'lit' and 'vit' are
normal
| iterators to the current position. The method for incrementing an
iterator
| looks like this:
|
| foo_iterator::operator++():
|      ++vit;
|      if(vit == lit->end)
|          ++lit;
|          if(lit!=lit_end)
|              vit=lit->begin;

Note that there is a potential bug here: this code seems to
assume that none of the vectors in the list is empty.

| Here was the first time I needed 'lit_end' because I must not
dereference
| 'lit' when it reaches the end but need to set 'vit' to the beginning
of
the
| next element otherwise.

What about postponing the testing of vit==lit->end() until
the iterator is actually dereferenced ?

foo_iterator::operator++():
if( vit == lit->end() ) // use a 'while()' if a vector may be empty
vit = (++lit)->begin();
++vit;
return *this;

foo_iterator::operator*():
if( vit == lit->end() ) // same thing, small overhead...
vit = (++lit)->begin();
return *vit;

But now the tricky iterator comparison:

The following would be a nice trick, but leads to
undefined behavior if either a or b is the end iterator:
return &*a == &*b;

Here's an alternative approach that should work
if the list does not contain any empty vectors:

I will rely on this small utility:
lit_t successor( lit_t it ) { return ++it; }

bool operator==(a,b):
if( a.lit == b.lit )
return a.vit == b.vit;

if(         a.vit==a.lit->begin()  )
return    b.vit==b.lit->end()
&& successor(b.lit)==a.lit;

return      b.vit==b.lit->begin()
&& a.vit==a.lit->end()
&& successor(a.lit)==b.lit;

The 'lit' stored in an iterator is never the end(),
so calls to 'successor' will not lead to undefined behavior.

There is a limitation with this last function though:
If the list can contain empty vectors, the 'successor'
function needs to test if a vector is empty and increment
again -- but this is an illegal operation if the end
of the list has been reached.
AFAICT, it cannot be made to support this situation...

| Does anyone have a better solution to this problem ?

Let me know if the above seems suitable...
Of course, storing the additional list iterator probably
isn't less efficient.

| [2] writing this, I started wondering how iterators of the stdlib
compare
| when they come from different containers. Undefined?
Container-specific?
| Unequal?

For iterator ordering ( <, <=, >, >= ), the behavior is definitely
undefined, as it is with pointers that do not point within the same
array.

For equality ( == , != ), I would still say undefined. For example,
an iterator to end() may be common to all containers (e.g. a NULL
pointer, or a default-initialized iterator such as istream_iterator),
while other iterators will not.
If the iterators are known to point to valid objects, comparing

Well, I hope this helps,
Ivan

--
Ivan Vecerina           <>  http://www.post1.com/~ivec
Brainbench MVP for C++  <>  http://www.brainbench.com

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Ivan
8/6/2003 1:32:25 PM
Hello, Ulrich Eckhardt!

Ulrich Eckhardt schrieb:

> Cheers!
>
> Following scenario: I have a nested list of vectors of Foos[1]. I want
> to
> have an iterator with which I can access all Foos as a sequence. What
> I'd
> like to confirm is that I didn't miss anything in my solution, because
> I'm
> not sure if I really need the third iterator (but I can't seem to find
> a
> way to do without it ...).

Question: I am not sure concerning the "nested" list of vectors: Do you
mean a
std::list<std::vector<Foo> > ??
The following discussion depends on this assumption.

among
iterators of
containers are just a specific case of those on comparisons among
general
iterators, which are
explained in Chapter 24. One specific requirement is the fact, that two
iterators must be
reachable. This is generally not guaranteed for two independent
containers:
24.1/p. 6:
"An iterator j is called reachable from an iterator i if and only if
there is a
finite sequence of applications of
the expression ++i that makes i == j. If j is reachable from i, they
refer to
the same container."
So, the corresponding behaviour is undefined.

And my general advice for your specific problem is: You could consider
to take
is
acting on, because a
than the
iterators
themselves. Since you are traversing on an iterator of iterators, and a
single
iterator is not selfdescribing
the sequence it is acting on, you have to store the end iterator of the
list in
other member functions of the referenced list to get the same
information.

> Up to now, I have basically the following:
>
> class foo_iterator:
>    methods:
>      operator++();
>    data:
>      list::iterator lit;
>      list::iterator lit_end;
>      vector::iterator vit;
>
> 'lit_end' points to the end of the list while 'lit' and 'vit' are
> normal
> iterators to the current position. The method for incrementing an
> iterator
> looks like this:
>
> foo_iterator::operator++():

>
>      ++vit;
>      if(vit == lit->end)
>          ++lit;
>          if(lit!=lit_end)
>              vit=lit->begin;
>
> Here was the first time I needed 'lit_end' because I must not
> dereference
> 'lit' when it reaches the end but need to set 'vit' to the beginning
> of the
> next element otherwise.
>

Probably you mean:

++vit;
while(vit == lit->end() && ++lit != lit_end) { // This ensures,
that you
skip all empty vectors
vit=lit->begin();
}

>
> The function for comparing iterators looks like this:
>
> bool operator=(foo_iterator it1, foo_iterator it2):

bool operator==(foo_iterator it1, foo_iterator it2) ;-))

>
>      // if the two iterators are not from the same sequence they
>      // are different [2]
>      if(it1.lit_end != it2.lit_end)
>          return false;

This test is unnecessary since it is UB to compare non-reachable
iterators.

>
>      // if the current position in the list differs they are different
>      if(it1.lit != it2.lit)
>          return false;
>      // if both positions in the list are at the end (and we know that
>      // either both or none of them are) they are equal
>      if(it1.lit == it1.lit_end)
>          return true;

This test is unnecessary since the position of vit should be defined.
It is
either equal to the last vector<Foo>::end() or has its initial value
(whatever
it is)

>
>      // the only possible difference is in the position inside the
> vector
>      return (it1.vit == it2.vit);
>
> Here again, I had to add a special case for the end-iterator because
> it has
> an undefined 'vit'.
>
> The only other way to solve this problem that I could think of was to
> have a
> flag whether 'vit' is valid and only evaluate it in comparisons if that
> flag is set and set 'vit' to 'lit->begin' on demand when the
> foo_iterator
> is dereferenced. That solution however requires a test on each
> dereferenciation and mutable 'vit' and valid-flag.
>

You don't need this test for validity. You just have to ensure, that
vit is
always initialized
with a defined value. You can at least use the default-constructed
iterator,
which should
be done like:

vit = std::vector<Foo>::iterator();

during assignement or

vit(std::vector<Foo>::iterator())

during initialization.

This calls the default constructor and works even in case of pointer
iterators
implementations
of std::vector (quite often found), since it evaluates to the null
pointer
constant in this case.

Hope that helps,

Daniel

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Daniel
8/6/2003 1:32:57 PM
"Daniel Spangenberg" <dsp@bdal.de> wrote in message
news:3F2FC258.F8C7C27A@bdal.de...
.....
> You don't need this test for validity. You just have to ensure, that
> vit is
> always initialized
> with a defined value. You can at least use the default-constructed
> iterator, which should be done like:
>
> vit = std::vector<Foo>::iterator();
>
> during assignement or
>
> vit(std::vector<Foo>::iterator())
>
> during initialization.
>
> This calls the default constructor and works even in case of pointer
> iterators implementations
> of std::vector (quite often found), since it evaluates to the null
> pointer constant in this case.

Question: are default-constructed iterators guaranteed
to compare equal ?

..... or could a default constructor chose to not care,
and leave fields uninitialized even though they may
be involved in a comparison ?

Regards,
Ivan
--
http://www.post1.com/~ivec

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Ivan
8/7/2003 2:40:36 AM
"Ivan Vecerina" <ivecATmyrealboxDOTcom@swissonline.ch> wrote in message
news:<3f31593b@news.swissonline.ch>...

{unnecessary quote snipped -mod/fwg}

>
> Question: are default-constructed iterators guaranteed
>           to compare equal ?

No.  See 24.1/5.  All we are allowed to do with an uninitialized
iterator is to assign a value to it.

>
> .... or could a default constructor chose to not care,
>     and leave fields uninitialized even though they may
>     be involved in a comparison ?

Yes, this could certainly be the case since such a comparison is not
allowed.

Randy.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
8/8/2003 10:47:31 AM
Daniel Spangenberg wrote:
> Ulrich Eckhardt schrieb:
>> Following scenario: I have a nested list of vectors of Foos[1]. I want
>> to have an iterator with which I can access all Foos as a sequence. What
>> I'd like to confirm is that I didn't miss anything in my solution,
>> because I'm not sure if I really need the third iterator (but I can't
>> seem to find a way to do without it ...).
>
> Question: I am not sure concerning the "nested" list of vectors: Do you
> mean a std::list<std::vector<Foo> > ??
> The following discussion depends on this assumption.

Your assumption was right, I meant basically container<container<foo> >, any
ones from the stdlib.

>> foo_iterator::operator++():
>>
>>      ++vit;
>>      if(vit == lit->end)
>>          ++lit;
>>          if(lit!=lit_end)
>>              vit=lit->begin;
>>
>> Here was the first time I needed 'lit_end' because I must not
>> dereference 'lit' when it reaches the end but need to set 'vit' to the
>> beginning of the next element otherwise.
>>
>
> Probably you mean:
>
>       ++vit;
>       while(vit == lit->end() && ++lit != lit_end) { // This ensures,
> that you
> skip all empty vectors
>           vit=lit->begin();
>      }

*slaps himself*
Yes, thanks for pointing it out. I do not have empty vectors usually, but
just last week we had some nice bughunting just because an empty one
slipped by ....

> bool operator==(foo_iterator it1, foo_iterator it2) ;-))
>
>>
>>      // if the two iterators are not from the same sequence they
>>      // are different [2]
>>      if(it1.lit_end != it2.lit_end)
>>          return false;
>
> This test is unnecessary since it is UB to compare non-reachable
> iterators.

OK. It possibly merits an assert.

>>
>>      // if the current position in the list differs they are different
>>      if(it1.lit != it2.lit)
>>          return false;
>>      // if both positions in the list are at the end (and we know that
>>      // either both or none of them are) they are equal
>>      if(it1.lit == it1.lit_end)
>>          return true;
>
> This test is unnecessary since the position of vit should be defined.
> It is either equal to the last vector<Foo>::end() or has its initial
> value (whatever it is)

Setting it to the last vector's end() wont work if there is no such thing
(i.e. the list is empty).

The only way to 'create' a value for it would be to set it like 'vit =
vector::iterator()'. However, I'm not sure that that wont lead to UB again.
Can I 'assert(iterator()==iterator())' ?

Uli

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated.    First time posters: Do this! ]

 0
Ulrich
8/8/2003 10:15:05 PM
Similar Artilces:

Re: Problem with iteration
Erik Naggum wrote: > * Raffael Cavallaro > | (defun my-reverse (a-list) > | (do ((n (- 1) (incf n)) (result '() (cons (nth n a-list) result))) > | ((= n (- (length a-list) 1)) result ))) > > yikes. > > (defun my-reverse (list) > (do ((reversed (list (pop list)) > (cons (pop list) reversed))) > ((endp list) reversed))) Buggy: * (my-reverse '()) (NIL) And POP won't work on immutable lists. Let's do it the right way using Racket: (define (my-reverse alist) (do ((accum '() (cons (car...

Re: Mapping the middle mouse button in the Display Manager
Phil, No guarantee, of course, but I'd suggest downloading and installing Microsoft Intellipoint. It's free and offers a number of choices for the behavior of the wheel button. If you don't like it you simply uninstall it. And, better yet, it works with logitech mice as well. You can find it at: http://www.microsoft.com/hardware/download/DownloadResult.aspx? category=MK&type=Mouse&name=KEY-00023&os=XP_32&lang=en or, in short form: http://xrl.us/bgth9x HTH, Art ------- On Sat, 23 Jan 2010 17:09:05 -0500, Philip Rack <PhilRack@MINEQUEST.COM...

FAQ 4.43 How do I compute the difference of two arrays? How do I compute the intersection of two arrays? #2 327066
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 4.43: How do I compute the difference of two arrays? How do I compute the intersection of two arrays? Use a hash. Here's code to do both and more. It assumes that each element is unique in a given array: @union = @intersection = @difference = (); %cou...

Hello I want to replace a windows bitmap load function through an equivalent SDL function. I should extract the img height etc. and assign it to the terreinTex array. Concerning that array why is texID used? terrainTex[0] doesn't state the first element? The declaration is: CTexture terrainTex[5]; and the CTextureclass: class CTexture { private: long int scaledWidth; long int scaledHeight; unsigned char *palette; public: texTypes_t textureType; unsigned char tgaImageCode; // 0 = not TGA image, 2 = color, 3 = greyscale int width; int height; int bitDepth; unsigned int texI...

How does one export address book from Eudora 6.1?
I'd like to export the address book from Eudora and import it into Apple Mail, but I find no export command for that purpose in Eudora, and no automated way to accomplish this in Mail. After making the mistake of "upgrading" to 6.1 and losing all my settings - attempting to navigate to older versions to import settings from produces grayed-out icons - and my address book, I think the time has come to change clients. Thanks. Yours truly, John Mayer John Mayer <mayer@hiredhand.org> wrote: > I'd like to export the address book from Eudora and import it ...

keyboard language mapping
Hello, We have ultrasparcs running solaris 2.6 and solaris 8 with keyboards mapped for US layout. We want to map them for UK layout. Can someone please tell which files to edit. I can google hundreds of similar question but not a single concise answer how to do it. Cannot find the solution at docs.sun either. Many thanks. ...

Two Way Replicaiton
Is it possbile to replicate two ways to keep two tables in sync, where inserts, updates and deltes may applied to each table by different applicaiton programs? Or would this cause a continous loop? Do you mean if you defined table A in db-a, and table B in db-b, then any change to table A will be synced to table B, at the same time, any update of table B is also copied to table A? "Mark" <m0002a@yahoo.com> wrote in message news:a5ebcc65.0410131258.5f355bf2@posting.google.com... > Is it possbile to replicate two ways to keep two tables in sync, where > inserts,...

HD seems OK, but impossible to boot with two partitions overlapping
After having come across with some good utilities (diskpatch one of them) and a good experience of a recovered HD I put under scrutiny another HD: 160GB formatted only 130GB with FAT32: 20 Primary (from a clone old HD); 110 Logical. Diskpatch detects 6 partitions! The first 3 are relevant. The third is the logical and seems ok. The other two are showed as primary both of 20 GB, both starting from the beginning of the hard disk and ending at 43038134 and 43038126 respectively. The first gives me Partition Table found at 0, but BootSector and BackupBootsector not found (DiskPatch says ...

Re: how to iteratively run a macro? #3
You can do a macro loop in open space. So you have to make another macro and inside it you can loop through and call the first macro. Something like: %macro loop; %let value=1; %do %until(%sysevalf(&value < 0.00001)); %mymacro; %end; %mend loop; Assume mymacro set the macro var value each time it is called. On Mon, 6 Jul 2009 22:08:09 -0700, guaiguaizhu <starfish11111@GMAIL.COM> wrote: >On Jul 6, 9:44 pm, snoopy...@GMAIL.COM (Joe Matise) wrote: >> More information please... there are many different answers to your >> question, depending on how you're using ...

Map a string
Factor: "HAL" [ 1 + ] map . "IBM" On Mar 12, 7:19=A0pm, "WJ" <w_a_x_...@yahoo.com> wrote: > Factor: > > "HAL" [ 1 + ] map . > "IBM" For persistent OT posting I think you deserve a "JOLLY" [ 7 - ] map . "CHEER" Alex McDonald <blog@rivadpm.com> writes: >On Mar 12, 7:19=A0pm, "WJ" <w_a_x_...@yahoo.com> wrote: >> Factor: >> >> "HAL" [ 1 + ] map . >> "IBM" > >For persistent OT posting I think you deserve a > ...

Blinking text with immutable color maps
We want to port a legacy application that depends on using writable color maps in 8-bit Pseudocolor visual for blinking text. Our target is to use 24-bit TrueColor - the legacy app also runs in 24-bit DirectColor but we want to get away from requiring a writable color map. The writable colormap trick was a fast way to flash many items on the screen all at once, without having to loop through each item. The only suggestions I've seen with non-writable color maps are to use XmNforeground & background; I'm assuming this would mean looping through each widget to blink? R...

Comparing two lists
Dear List To find where a list of 100 words occurs in a dataset of 40,000 obs I ran a cartesian join then sub-setted the results with if index(desc,word)>0 However, this obviously would be a bad idea on a large couple of datasets. What is the more sophisticated way to do this, or would embedding the index in the sql join have yielded a reasonable performance result? Any comments much appreciated Rgds proc sql; create table c2 as select codes.*, med.word from codes, med; quit; data c3; set c2; if index(upcase(ccodedesc),word)>0; run; ...

selecting from two tables
Hi I have one table called 'foobar_items' ID desc ________ ________________ foo1 very good foo foo2 average foo foo3 bad foo bar1 great bar bar2 average bar And another table called 'foobar_searches' Type Keyword Color ________ ___________________ ________________ foo foo foos Blue bar bar bars Red I need to search for a match in either table.. How do I write the syntax? For ...

I have two machines, one running Red Hat Fedora Core 2, the other running Windows XP Pro. I happened to have some extra ethernet cards lying about, and decided to play around with link aggregation (a.k.a. channel bonding, port trunking, etc.). On the Linux side, I am using the bonding module in mode 4 (802.3ad), and on the Windows side I have NIC Express 4.0 installed and set for 802.3ad mode. The hosts are connected via two crossover cables. I've played around quite a bit, but haven't had much luck; at one point, I could ping from either host to the other with either or both c...

Display of topo map in MAP routines.
Hello, I'm sure this question has come up before (I did a quick search of David Fanning's tips but didn't immediately see anything). Apologies in advance for being a bit lazy.... Can someone outline (real quick) the steps needed to display a topo map in the background of a map projection? Other point data will be overplotted over this background. Does a DEM file come with IDL, or do I need to visit the USGS? Thanks for any info/help. cheers, paulv Paul van Delst writes: > Can someone outline (real quick) the steps needed to display a topo map in the background > of a ...

[PATCH] new map switch -B returns multiple BEST results for dns and bestmx map types
While trying to write some rules to accomplish bogus mx (as listed in access db) checking on recipients to cut down on double bounces, I wrote these experimental patches that allow the return of the multiple best results from the dns map or from the bestmx map. Currently the -z switch returns them all and without the -z you get just one of the possible multiple best ones. Whether that is actually a problem may vary. With these patches, specifying the -z and -B flags means you will get multiple results for MX and SRV records from the dns (bestmx) map type that are of equal lowest (most prefer...

China-India IT cooperation: One 'pagoda' short
http://www.atimes.com/atimes/China_Business/HC23Cb01.html China Business Mar 23, 2006 It is a sight that would warm the hearts of believers in the long-talked-about potential for Sino-Indian collaboration in information technology (IT), which if realized would make the neighbors a formidable high-tech global force. When Chinese Prime Minister Wen Jiabao visited India last April he poetically described bilateral cooperation as "two pagodas: one hardware and one software". ..... Role model for Chinese IT industry TCS is, however, gearing up to take its role in China beyond merely ...

VPN for C++ application. cannot map folders on my computer.
VPN connected but cannot map folders on my computer. I am trying to connect to our headquarters server using VPN (windows XP). I am able to successfully connect to the server (passes authentication) but am not able to map network drive on my computer. I was able to map the network drive on my colleague's computer and I successfully installed the application and his computer is working flawlessly. Also I have to uncheck (use default gateway on remote network) option under TCP/IP -> advanced settings for me to surf the web/ check email while I am connected to the VPN. My colleagues I...

Bump Map
Hi, when a Bump Map filter is used with a rather dark background layer, it's hardly visible. Therefore I'd like to lighten up the bumpded text (in my case) a bit. Of course that's possible by selecting all the bumped parts but that's very tedious. Is there something easier? Many thanks for your help, Helmut Jarausch. In <459255e1$0$31460\$ba620e4c@news.skynet.be>, Helmut Jarausch wrote: > when a Bump Map filter is used with a rather dark background layer, it's hardly > visible. Therefore I'd like to lighten up the bumpded text (in my case) a bit. > ...

[OT] One click, one (buggy) life..
Hi everyone, I would like to share a youtube clip...one click costs nothing while can save lives sometimes (especially mine). http://www.youtube.com/watch?v=PiCeqtGHpJI Thanks a lot and cheers. DavCori http://www.ar4tro.com ...

Epson , Canon ink Cartridge Special Offer
special offer suitable for all Epson Canon inkjet printer , welcome to visit http://www.xibase.net/products.php or tel 2683 2829 , email to sales@xibase.net free delivery. ...

Two different versions of Wine? #2
Is it possible to install 2 different versions of Wine on one machine? Can one version be installed into /usr/local/wine and one into a users homedir? -- \ / ,_, GPG/PGP key available: \/\/olfgang Klein (o,o) send e-mail with subject Paderborn / Germany {' '} "Please send PGP key" =============================#=#====================================== Two types of people laugh at the law: those that break it and those that make it. (Terry Pratchett) Wolfgang Klein <klein.wolfg@web.de> wrote: >...

Changing map keys (no reordering of keys)
Hello world, I currently have implemented a sparse array needed by a class as a map<int, boost::shared_ptr<my_type> >. However, one of the derived classes needs to periodically "tighten" the sparse array (i.e. make it non-sparse). For example: a[0] = 1 a[4] = 2 a[42] = 54 => a[0] = 1 a[1] = 2 a[2] = 54 I'm currently somewhat puzzled at how I would rearrange the keys. One possible solution I thought would be: /*where inv is the member containing the map*/ int lim = inv.size(); map<int, boost::shared_ptr<my_type> >::iterator it = inv.begin(); for(...

GMail-to-IMAP mapping puzzles
I could use some ideas from people on how to map some of these things: - Google's "unique identifiers" for messages are 64-bit integers. Right now I'm just using the bottom 32 bits; probably the best I can do is hash the top and bottom into 32 bits, but there's still a remote chance of collision. - Google's UIDs aren't monotonic; they're random. Any ideas on what UIDNEXT should mean in this context? I'm out-of-spec on this issue right now, and although it works with most clients, I don't want to leave things this way. ...

Format one column of tabular using one command
Hello: How can I format only one column of specific column, for example, italize it only using one commnad instead of brute force technique since my table is too long to copy and paste. Thanks. Z. Du duzhidian@gmail.com wrote: > How can I format only one column of specific column, for example, > italize it only using one commnad instead of brute force technique > since my table is too long to copy and paste. Use the array package's ">" feature: \begin{tabular}{ll>{\itshape}ll} -- Scott In article <1180750782.033616.125180@p77g2000hsh.googlegroups.co...