f

#### 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 10738 articles. 1 followers. allnor (8506) is leader.

5 Replies
380 Views

Similar Articles

[PageSpeed] 9

```"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:

One - Two, One
It's the Gizmondo crew! Yo! Check out this software on tha Gizmondo stand at a recent Cebit exhibition. http://video.google.com/videoplay?docid=-2239941528715060334 Different ta wizzy i was jizzle a boi. PCW 1986 it ain't. The booty-slapp'n hos is doggy stylin' tha attention. The Gizmondo was designed by tha poser of tha ZX Spectrum but this software is bustin' hizzy changed. http://www.theproductdesigners.com/ Noth'n is tha same so show some love. Playas is mackin' this kind of clockin'. http://video.google.com/videoplay?docid=-6775033602778495998 ...

map that maps to iterators in the same map ?
Hi, I wonder if it's possible to implement something like typedef map<string, T::iterator> T; i.e. to have a map that will resolve keys to iterators in the map of the same type. In my situation, I'll have only one such map and can guarantee that all iterators will remain valid (I'll only add stuff). Do such recursive constructions known to cause problems? I can use pointers instead of iterators, but it will be much uglier. Thanks, Vladimir ...

one to one mapping between two sets of 256 values
I have two sets of 256 values sorted in ascending order.Now i need to do a mapping between these two sets in one to one manner and then to reorder the mappings according to the indices of first set. can anyone give me a solution for the same.Is there any matlab function available in R2010a version? ...

C++0x two Unicode proposals. A correction one and a different one
Based on a discussion about Unicode in clc++ inside a discussion thread with subject "next ISO C++ standard", and the data provided in http://en.wikipedia.org/wiki/C%2B%2B0x , and with the design ideals: 1. To provide Unicode support in C++0x always and explicitly. 2. To provide support to all Unicode sets out there. I think the implementation of these as: a) char, char16_t and char32_t types. b) built-in Unicode literals. should become: I) Library, implementation defined types like utf8_char, utf16_char, and utf32_char, leaving alone and not polluting the existing built in typ...

C++0x two Unicode proposals. A correction one and a different one
Based on a discussion about Unicode in clc++ inside a discussion thread with subject "next ISO C++ standard", and the data provided in http://en.wikipedia.org/wiki/C%2B%2B0x , and with the design ideals: 1. To provide Unicode support in C++0x always and explicitly. 2. To provide support to all Unicode sets out there. I think the implementation of these as: a) char, char16_t and char32_t types. b) built-in Unicode literals. should become: I) Library, implementation defined types like utf8_char, utf16_char, and utf32_char, leaving alone and not polluting the existing built in typ...

Special map iterator
Hello, all. I have just wrote the following little class, and I'd like you to give me your opinion about it. I compiles with VC6 but I'm not sure if it is totally right. I'm trying to explain the problem I try to solve: I had a class with a private vector<T> member variable, and some public functions that use iterators to the vector (with the apropiate public typedef for the iterator type). But now I need to change the vector to a map. That's easy. But the iterator iterates now with a std::pair<I,T> type. And of course I want to maintain the public interface. temp...

Two..... Two...... Two Desktops in One...
I use an external Firewire drive (Mercury Elite 911 chip) to back up our iBook which is running OS 9.2. As we have not set up a network yet, I unmount the Mercury and then shut it down and disconnect the FW cable. Then I plug in the USB cable to the Mercury and then the iBook and then power on the Mercury. The desktop from the Mercury is then plastered all over the iBook desktop, sort of merging to two together. What am I doing wrong and what should I be doing to avoid this please? In article <madwen-7A453D.19253013012004@news-east.ash.giganews.com>, Madwen <madwen@onomat...

A look at the C-One (Commodore One) reconfigurable c...
I've followed this project with interest for a couple of years. It is clearly a superb technical achievement, and I'll probably buy one after it is a released product. But I do have a difficult time understanding how the C-One is functionally anything other than another emulator? Is there something that it can do that well-executed emulator(s) can't do on a PC platform? Perhaps I'm missing something here (and I'm sure someone can enlighten me. :-)? -Larry The FPGA's on the motherboard are loaded with a core file that describes an actual hardware configuration that t...

One to one mapping
hi all, I have following functions on netinet/in.h on my Linux Box. But man pages are not present for these APIs on my Linux Box. inet6_option_space inet6_option_init inet6_option_alloc inet6_option_next inet6_option_find. By leafing through the header files i came to know that these are Hop-by-Hop and Destination Options Processing APIs. I just want to know whether these APIs are equivalent for inet6_opt_* APIs on HP-UX. Can i achieve one to one mapping to inet6_opt* on HP-UX using these functions on Linux?? thanks in advance seema_coma In comp.sys.hp.hpux seema_coma@yahoo.co.in wrote: [ w...

distance between two iterators in map
In STL's map implementation, the distance between two iterators it1, it2 takes O(K) to compute where K is the actual distance between the two iterators. In theory, a red black tree can do this in O(log K) time. Anyone knows if there is a way to do this in map<> or if map<> can be inherited/modified to do this? Thanks, --j [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] John wrote: > In STL's map implementation, the distance between two > iterators it1, it2 takes O(K) to compute...

Two C-FIND in one association
Hello, I have a question about multiple C-FIND in one association. Because the C-FIND protocol is some kind of restricted, we (modality) do send two C-FIND in one association for getting needed data. Normally this works like this (for no matches): - AE1: A-ASSOCIATE-RQ - AE2: A-ASSOCIATE-AC - AE1: C_FIND_RQ[Command] - AE1: C_FIND_RQ[Data] - AE2: C_FIND_RSP[Command] - AE1: C_FIND_RQ[Command] - AE1: C_FIND_RQ[Data] - AE2: C_FIND_RSP[Command] - AE1: A-RELEASE-RQ - AE2: A-RELEASE-RP No we have a dicussion with a RIS vendor which claims, that two C-FIND in one association are not DICOM compliant. Do you think the above mentioned DICOM implementation is compliant? Can you say, where I may find more about it? In DICOM part 6 (message exchange) I do neither find, that wto C-FIND are forbidden, nor it is alowed. Thank you Matt Hi Matt Once an association has been established, you can send as many operations that are supported by the successfully negotiated SOP Classes as you want, as long as the previous operation has completed before you send another one (unless asynchronous operations have been negotiated). So after one C-FIND request has been sent, and a final response received, you can send another one. Saying that you can't send two C-FINDs would be like saying that you can send two C-STOREs, i.e., that each image transmitted would needs its own association established, which would obviously be ridiculous. So the RIS ven...

C-One Mailing List
So, we can get spam by the buckets in the C-One mailing list, but I post = a message about Chuck Peddle and it's moderated as off-topic? <http://blog.paytonbyrd.com/?p=3D74> --=20 Payton Byrd Homepage - <http://www.paytonbyrd.com> Blog - <http://blogs.ittoolbox.com/visualbasic/dotnet/> >>>>> "PB" == Payton Byrd <plbyrd@bellsouth.no.spam.net> writes: PB> So, we can get spam by the buckets in the C-One mailing list, but PB> I post a message about Chuck Peddle and it's moderated as PB> off-topic? This has nothing to do with c...

In map iterator is there a difference between (*iter).second and iter->second?
I see that a lot of former in the code, and wonder if there is a technical reason for that "puzzlecracker" <ironsel2000@gmail.com> wrote in message news:8114115f-8075-4f7b-891d-298b48b9a383@56g2000hsm.googlegroups.com... >I see that a lot of former in the code, and wonder if there is a > technical reason for that You're asking about language syntax, this is not specific to map or iterators. Given a pointer to a class or struct: struct T { int member; }; and a pointer to one of these structs: T obj; T *p(&obj); The two expressions: (*p).member and p-...

One if by shell, two if by "C"?
I have been developing a Common Lisp GUI as a thin layer to Tcl/Tk by talking to wish over a socket. Now I want to use tcl3dTogl or maybe Togl. I am a little leery of trying to get high OpenGL frame rates over a socket. OpenGL display lists can be used to minimize traffic, but I am starting to wonder if it is time to look at losing the socket. It seems to me there are two approaches. One is to simply start an interpreter from Lisp (we use a C interface to call C functions, so you can think of the Lisp app as a C app) and then mostly tcl_eval the same stuff I was sending over the socke...

problem with iterator (map iterator)
I'm writing a small program that will use a map (i.e. map<string,int>). it has been a while since I have written in c++, so I found an example on the internet and modified it for my own use. But when I try to compile my program, I get a compile error. The code looks ok to me, so I did a search on the internet to see if others had the same problem. I found 3 or 4 examples, but the solutions were all related to using an iterator, when infact a const_iterator should be used. That is not the cause of my problem, as near as I can tell. I have reduced my code to a simple e...

[Map]modifying a map through an iteration
I have built a map like this : private Map<String,ArrayList<Indi>> allNamePartitionsMap=new HashMap<String,ArrayList<Indi>>(); where basically to a string key I associate in my map a list of objects of type Indi Now I want to iterate through this map but with the possibility to modify it dynamically ; for this I use this loop where I search for indi0 in map values to remove it from keys (only one key can have such indi0): for (Map.Entry<String, ArrayList<Indi>> entry : allNamePartitionsMap .entrySet()) { if (entry.getValue().contains(indi0)) { /* I...

[C++0x] Concept maps and template specialization
Suppose I have a non-auto concept and a template that generates classes that satisfy the concept: concept Mungible<typename T> { void T::Mung(); } template<typename T> class Widget { public: void Mung(); }; Am I permitted to have a templatized concept map, like this? template<typename T> // all Widget instantiations are concept_map Mungible<Widget<T>> {} // Mungible If not, how do I express that all Widget instantiations are a model of Mungible? Suppose that not quite all of the classes generated ...

maps maps maps????
Argh!!!! What happened to transparency maps, reflection maps blah blah blah????? (I'm talking about viz renderer / autocad2004 adt). If you can't use transparency maps, then HTF do you create mesh objects (like a grill, railing, mesh with holes)? or even trees? Or 2D people? Billboard and stuff like that? Use the Cutout map under Special Effects. --- stefkeB --- "Henry" <abshhkc@bath.ac.uk> wrote in message news:Xns942BB07D85A90abshhkcbathacuk@138.38.32.81... > Argh!!!! What happened to transparency maps, reflection maps blah blah > blah????? (I'm talking about viz renderer / autocad2004 adt). > > If you can't use transparency maps, then HTF do you create mesh objects > (like a grill, railing, mesh with holes)? or even trees? Or 2D people? > Billboard and stuff like that? > "stefkeB" <stefkeB@hotmail.com> wrote in news:1068214235.60416 @seven.kulnet.kuleuven.ac.be: > Use the Cutout map under Special Effects. > > --- stefkeB --- > > "Henry" <abshhkc@bath.ac.uk> wrote in message > news:Xns942BB07D85A90abshhkcbathacuk@138.38.32.81... >> Argh!!!! What happened to transparency maps, reflection maps blah blah >> blah????? (I'm talking about viz renderer / autocad2004 adt). >> >> If you can't use transparency maps, then HTF do you create mesh objects >> (like a grill, railing, mesh with holes)?...

Map C++ feature to C
Dear friends Is there a way to embulate C++'s virtual destructors in pure C. IE just using function pointers. Many Thanks. On 06/24/12 08:23 PM, zgene wrote: > Dear friends Why is the question completely different form the subject? > Is there a way to embulate C++'s virtual destructors in pure C. IE just > using function pointers. No, because there isn't a way to fully emulate destructors. -- Ian Collins On Jun 24, 9:23=A0am, zgene <nos...@nospam.com> wrote: > Dear friends > > Is there a way to embulate C++'s virtual destructors in pure C. IE just > using function pointers. > > Many Thanks. Why would you want to do that? If you want to write C++ code, there is an excellent language for that - it is called C++. Much better than some half-arsed attempt to simulate it in C. On 6/24/2012 4:25 AM, Ian Collins wrote: > On 06/24/12 08:23 PM, zgene wrote: >> Dear friends > > Why is the question completely different form the subject? > >> Is there a way to embulate C++'s virtual destructors in pure C. IE just >> using function pointers. > > No, because there isn't a way to fully emulate destructors. > strictly speaking, yes. but if one allows for the case where the destructor is called via the object being manually destroyed/"deleted", then it becomes a little easier: just have it as a method/function-pointer which is ca...

Open two files at one time in C?
Can C open (and keep open) two files at any given time? so, FILE *a, *b; a = fopen(argv[1], "r"); b = fopen(argv[2], "r"); ? padh.ayo@gmail.com wrote: > Can C open (and keep open) two files at any given time? > > so, > > FILE *a, *b; > > a = fopen(argv[1], "r"); > b = fopen(argv[2], "r"); > > ? > I don't know that it is defined in the C standard, however I've yet to find an operating system that doesn't allow at least two files to be open concurrently. Yes you can. This is why you have FILE *a,...

make a map out of two maps
Hi. VC++ 7.0 issues this error when i try to make a container out of two std::map, i want this container to provide me with o(log(n)) searches in both types: key_type and mapped_type, and some further features. The code and the error are like follows. Any workaround will be very helpful. Thank you very much in advance. David. -------- mapa.h --------- #include<map> namespace David{ using namespace std; template<class T1, class T2, class Cmp1 = less<T1>, class Cmp2 = less<T2>, class A1 = allocator<pair<const T1, T2> >, class A2 = allocator<...

Two Separate Networks In One Office.. One Internal / One External
Question about a proposed office network.... All Windows XP systems Network 1: Cable Modem ---> Router / Firewall ---> 3Com Hub ---> NIC #1 In Machine (TCP/IP & DHCP) Network 2: 3Com Switch ---> NIC #2 In Machine (IPX/SPX & Set IP Address) I was told running a different protocol such as IPX/SPX on the second network would make it more secure, is this true? I understand that the PC's still are connected to the internet on network 1 but wouldn't it be more secure since network 2 isn't directly connected to the internet and in order to access network 2 a ha...

Better C/C++ Than C/C++?
I am looking for a good systems programming language that can be used instead of C/C++. My qualifications for the language are: * mature compiler(s) that produce native-code binaries (for Windows) * open source - preferable, but not 100% necessary Thanks, Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) Ocaml, D, cyclone, Eiffel, Beta > * open source - preferable, but not 100% necessary what's wrong with using C? Friedrich > what's wrong with using C? Too low level, no built-in garbage collection. -- Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: >> what's wrong with using C? > > Too low level, Well the Smalltalk people say, have a small language and a big library. I assume C's library status beyond that of Smalltalk. > no built-in garbage collection. Use the Boehm Weisser GC. Friedrich "Kevin Albrecht" <kevin@albrecht.net> wrote in message news:<2TiYb.237892\$rj7.1641209@twister.tampabay.rr.com>... > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) > ...

C-s C-w selects forward word for search, how to select forward one character instead of one word for search
Hi, I use very often C-s C-w to select forward a "word" for search. Is it possible to select forward one character at a time instead of one word at a time. This is necessary since the definition of "word" is not necessarily always appropriate and more characters than expected are selected. I would have liked to know if it is possible to i-search and then go forward character by character. I was expecting something like C-s C-f (C-s to begin i-search then C-f to go forward one word) to work but it just does not. Would appreciate your help! Thanks asafinia@...

Web resources about - map two into one with special iterator - comp.lang.c++.moderated

Iterator - Wikipedia, the free encyclopedia
Various types of iterators are often provided via a container's interface. Though the interface and semantics of a given iterator are fixed, ...

Price Drop: iterator
iterator 1.0.1 Device: iOS iPad Only Category: Music Price: Free, Version: 1.0.1 ( iTunes ) Description: iterator is an inspiring sample based ...

How C++ Reverse Iterators Represent Boundaries
... pointers can be used to represent boundaries. Let's continue by looking more closely at how these representations interact with reverse iterators. ...

<?php class IteratorTest implements Iterator { private \$_items = array(1,2,3 - Pastebin.com
<?php class IteratorTest implements Iterator { private \$_items = array(1,2,3 - Pastebin.com

Hiding iterator boilerplate behind a Boost facade
Contents Filling in missing methods. Python Filling in missing methods. C++ Enter Boost iterators Using boost::iterator_facade Templates ...

A Classic Example That Off-The-End Iterators Can Simplify
Let's examine a programming problem that Edsger Dijkstra calls "the problem of the Dutch national flag."

How To Use Reverse Iterators Without Getting Confused
This week we'll look at a concrete example of how to use reverse iterators.

Iterators and iostreams
In a previous post, I bemoaned the fact that the C++ iterators that perform stream I/O use the insertion and extraction operators, making them ...

Resources last updated: 3/5/2016 6:51:56 AM