Subject: [Dev] Josuttis vs Musser

From: "M. Mueller (bhu5nji)" <[email-masked]>
Date: Thu, 14 Feb 2002 05:34:49 -0500

I think I have some solid evidence to rank two STL books and it hinges on 
example variety.

The Josuttis book examples (downloaded from the web) often show that sequence 
container (vector, deque, list) elements can be directly accessed in a manner 
similar to arrays:

list<string> a;

if (a[3] == "blah") doSomething();

I have a very simple language to parse.  I am told 4 position sensitive 
things in a string.  I parse the string into a list, a,  of strings.  If 
a.size() != 4 then I ignore the statement.  Otherwise, I start analysing 
a[0]..a[3].

A quick scan of Josuttis examples suggests this approach will work.  The 
Musser et al book was not so helpful. The Musser et al book does use this 
technique and the book's formal definition of the technique is still hiding 
from me. 

These books are nearly $50 each.

---

From: Tanner Lovelace <[email-masked]>
Date: 14 Feb 2002 13:17:50 -0500

Replace list with vector and I think it should work.  I don't
think the operator[] is overloaded for list, because of the fact
that it's not random access.  Everything else should work, though.

Tanner

On Thu, 2002-02-14 at 05:34, M. Mueller (bhu5nji) wrote:
> _______________________________________________
> Dev mailing list
> [email-masked]
> http://www.trilug.org/mailman/listinfo/dev
-- 
Tanner Lovelace | [email-masked] | http://wtl.wayfarer.org/
--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--
GPG Fingerprint = A66C 8660 924F 5F8C 71DA  BDD0 CE09 4F8E DE76 39D4
GPG Key can be found at http://wtl.wayfarer.org/lovelace.gpg.asc
--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--
 Those who are willing to sacrifice essential liberties for a little 
 order, will lose both and deserve neither.  --  Benjamin Franklin 

 History teaches that grave threats to liberty often come in times
 of urgency, when constitutional rights seem too extravagant to 
 endure.  --  Justice Thurgood Marshall, 1989

---

From: "M. Mueller (bhu5nji)" <[email-masked]>
Date: Thu, 14 Feb 2002 13:46:32 -0500

OK. Now I see the definition in the Container Ref. Guide in Musser et al, 
Section 21.3.8 Vector Element Access Member Functions:

reference operator[](size_type n);
const_reference operator[](size_type n) const;

  Returns the nth element from the begining of the vector in constant time.

operator[] defined for vector, deque, map.

[] is not defined for set (index is key, entry is key, [] is somewhat 
pointlesshere ), list (I would not have guessed that it doesn't exist because 
it's not RA), multiset (key is index, but multiple key values allowed, so [] 
is not determinate).

I was just getting to the point today of learning that lists are not RA.  
Thanks for saving me the headache.  I'll just use an iterator.

I'll be referring to my TODO list as my TODO vector from now on :-).

Mike

On Thursday 14 February 2002 01:17 pm, you wrote:
> > The Josuttis book examples (downloaded from the web) often show that
> > sequence container (vector, deque, list) elements can be directly
> > accessed in a manner similar to arrays:
> >
> > list<string> a;
> >
> > technique and the book's formal definition of the technique is still
> > hiding from me.
> >