map two into one with special iterator

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply Ulrich 8/5/2003 7:28:06 AM

See related articles to this posting


"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.
Can this assumption be made?

| 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
the object addresses instead can be a useful alternative.


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
Reply 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.

And answering on your final point [2]: The requirements on comparisons 
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
advantage of
your knowledge concerning the general container types your foo iterator 
is
acting on, because a
container provides much more information concerning the actual sequence 
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
your example or you use
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
Reply 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
Reply 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
Reply rmaddox 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
Reply Ulrich 8/8/2003 10:15:05 PM
comp.lang.c++.moderated 10649 articles. 9 followers. Post

5 Replies
176 Views

Similar Articles

[PageSpeed] 58


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

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...

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...

NAT port mapping between one inside server and two outside dhcp interfaces
Hi, Here is my problem, I have a cisco 1720 router with 2 external Ethernet(0/1) interfaces with dhcp and one internal FastEthernet0, my goal is to have the 2 external Ethernet(0/1) interfaces nat map tcp port 80 to one single server on the inside FastEthernet0 network. Inside server IP is 192.168.10.1 FastEthernet0 interface IP is 192.168.10.254 (ip nat inside) Ethernet0 interface IP is dynamic (ip address dhcp) (ip nat outside) Ethernet1 interface IP is dynamic (ip address dhcp) (ip nat outside) This one works: ip nat inside source static tcp 192.168.10.1 80 interface Ethernet0 80 But I...

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 ...

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...

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...

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-...

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<...

[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...

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...

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...

Two ISP, two IP, is it possible two sendmail daemos listening one each IP?
Hello everybody. I'm trying to configure my RedHat 9.0 Linux box with two network cards connected each to a DSL router with its own IP in the mail server of each IP. I've done the routing and the traffic is redirected to the right gateway so I can do ssh to both IPs and gain access to the machine through the right ethernet card. The problem is that when I try to gain access to port 25 in one of the IPs I do not obtain response, but thetereal shows me trafic on port 25 of the eth0 (!?) (the one that is not responding). I have response from the other IP when accesing port 25. Any idea w...

one-to-one mapping using IPTABLES
Hello, I want to implement one-to-one mapping of ip addresses using iptables with logging. Network is as follows: -----192.168.1.0/24-----FIREWALL(IPTABLES)-----192.168.4.0/24 (Net-I)[eth0] (Net-II)[eth1] I want each ip in Net-I when goes out through the firewall takes a IP from Net-II. I think for it the following rule is sufficient. Rule -I ###iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.1/32 -SNAT -to 192.168.4.1 Note: I want it to be static mapping. Now, I also want to enable logging for the net-I(192.168.1.0/24)i.e. keep track of who is...

How to Set Up Two One-to-One Tables?
I have a requirement to create two tables that have a one-to-(zero or one) relationship. That is, for every record in table A, there can be zero or one record in table B. I understand that I could put everything in one table, and then create two views. But for purposes of this discussion, let's assume that we need to physical tables. What is the best way to do this? How can I prevent table B from having more than one record? You just need a common primary key: CREATE TABLE A (x INTEGER NOT NULL PRIMARY KEY, ...) CREATE TABLE B (x INTEGER NOT NULL PRIMARY KEY REFERENCES A (x), ...)...

Virtual Physical one to one mapping.
Hi, My requirement is that certain piece of code should be link in such a way that it's virtual address and physical address should be same. That piece of code is part of vmlinux and use to disable the MMU. Can anyone tell me how to achieve this flat memory mapping for the specific piece of code? Thanks, Sachin sachin <sbillore@rediffmail.com> writes: > Hi, > > My requirement is that certain piece of code should be link in such a > way that it's virtual address and physical address should be same. > That piece of code is part of vmlinux and use ...

One Form, Two Targets, Two Actions
I have created a form which has two submit buttons. The first is a preview button to view the data they have entered into a formated page. The second actually submits the data for saving. The two submit buttons have onclick events defined for both the targets and actions. These are both working OK. However, I have an onsubmit event in the form tag which validates the data which is also triggered when the preview button is clicked. I want to block this behavior. Is there a way to determine which button is clicked in the validation function, or bypass it altogether? Perhaps there is a be...

one-to-one mapping using IPTABLES with LOG.
Hello, I want to implement one-to-one mapping of ip addresses using iptables with logging. Network is as follows: -----192.168.1.0/24-----FIREWALL(IPTABLES)-----192.168.4.0/24 (Net-I)[eth0] (Net-II)[eth1] I want each ip in Net-I when goes out through the firewall takes a IP from Net-II. I think for it the following rule is sufficient. Rule -I ###iptables -t nat -A POSTROUTING -o eth1 -s 192.168.1.1/32 -SNAT -to 192.168.4.1 Note: I want it to be static mapping. Now, I also want to enable logging for the net-I(192.168.1.0/24)i.e. keep track of who is doing...

Two questions. one vector and one printer.
Questione one - vector I have a vector named 'ex' of lets say 500 values, I dont know on forehand that they are 500 values. But I want to use the last value in another function. Now how I usually would do this is this: for ex = 1:1:500; CODE EXAMPLE START b = 1; i = length(ex); a = b +ex(i); CODE EXAMPLE END this gives that a = 501; Is there any way to directly tell matlab that i want the last number in the vector? or is the 'i = length(ex);' a so called must have? Question two - printer I am generating figures in a for loop and saving them to my harddrive. Up untill now I...

mesh-how two have two planes in one graphic?
Hi, I have a plane generated by mesh(X,Y,Z) and want two see how it changes if I vary a parameter. I want to plot the second plane in the same graphic. But the way I can do it in 2-D (plot(X,Y1,X,Y2)) does not work with mesh ? Thanks for your help. Marianne ...

My two questions. One legit, one silly...
First off, sorry for posting from Google Groups. I am not at my own machine right now. Question 1: I'm not very far into K&R2 just yet, but I notice that Chapter 8 is "The UNIX System Interface". Is this chapter (and the following sections therein) still applicable to current UNIX-like operating systems? My ridiculous problem: I know that these days "UNIX" is somewhat vague. It may help me settle a personal hangup I have about BSD vs. Linux. Both are alright OSes but for some reason I feel that learning C on a FreeBSD or (especially) NetBSD system is "c...

Two servers, one client : one problem
Hi ! I have some problems about the configuration of ntp servers and client. You'll find the configurations used for the test and some outputs (of "ntpq -p" for example). First of all, the both servers are standalone and are not synchronized with an external ntp server. Later, they'll be connected to external ntp server. Later... The servers and client don't use iptable. My problem is the following : I don't understand why the client can't be synchronized with one of the servers. The servers are seen as a "falsetickers"... The "ntpq associations...

I have two iPhones, One for day, and one for night
Path CEO Dave Morin: <http://www.vanityfair.com/culture/my-phone/2013/03/dave-morin-path-fac ebook-apple?currentPage=all> "I have two iPhones, one for day and one for the night. When the day phone runs out, the night phone takes over. I never have to worry." Haha, what an idiot. -- Sandman[.net] On 2013-04-09 06:32:58 +0000, Sandman said: > Path CEO Dave Morin: > > <http://www.vanityfair.com/culture/my-phone/2013/03/dave-morin-path-fac > ebook-apple?currentPage=all> > > "I have two iPhones, one for d...

Two DNS Two Networks in One Office
I am trying to connect two routers on the following IPs ranges. One have statics IPs base on 68.153.197.X and the other is base on a DHCP server on 192.168.2.X. Can anybody advice how to do this? Note: I have no hardware knowledge about routers. Thanks. AHDI wrote: > I am trying to connect two routers on the following IPs ranges. One > have statics IPs base on 68.153.197.X and the other is base on a DHCP > server on 192.168.2.X. Can anybody advice how to do this? Note: I have > no hardware knowledge about routers. Thanks. are they on the same physical lan? you can multi...