D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] STL / API ?Que? (was gcc)



Neil Williams wrote:

Have you tried writing in GridLayout()?

Yes, done a big project in GridLayout, but we only had to use
GridLayout once to lay the default screen settings, then it
fades into the background.

It is a VERY high price to pay for platform independence.

It is exactly the same price you pay in HTML isn't it? 

Not assuming screen dimensions or resolutions in HTML, means it
reads okay on my 1.5" high by 4" wide Nokia phone display. Java
has similar design goals. GridLayout isn't so different from
using tables or frames to layout HTML as far as I know - but
your the HTML guru.

As Paul point out, you can write code in Java that will display
poorly on some displays, you just have to do a little more work.
Can't believe Nokia would revert to C++ just to do this, you can
extend the layout manager class to commit most sins.


As opposed to the API which lets you apply common functions and constructors?

No an API is an interface to another piece of code that you
call.

A template is a way of doing something generically in C++.

A list has a beginning, and end, you can cross an item off, add
it to the end, add it to the middle, compare lists, copy lists,
cut sequences out reverse them, sort them etc. Doesn't matter if
it is a list of shopping items or a list of friends.

Also you might want to know how big your list is, reserve some
space in case it grows, and much more. The C++ standard library
does all this.

I really ought to get a Linux programming text didn't I!

Probably, but the STL is part of C++, it is the standard classes
and templates you can rely on being there (alledgedly).

// here:
 node () {}
 node (char c, int i, double d) : c(c), i(i), d(d) {} 
};

Yes that's just a "constructor" for the structure.

If you are using a constructor and a destructor, wouldn't it be easier to use
a class?

I could have used a "class node". Probably should have used a
class, but I was just experimenting.

list<node> top;
?Que? 
I can't find a reference to list<> - what does this line do?

That is the magic. The template says how to generically handle
items in a list.

list<node> applies this template to type "node", so now I have a
"list of nodes".

Here is a template example for a simple "swap" template
function. How many times have you written this piece of code? In
C++ you need only ever write it once, you could have written it
ONCE in C, but it would probably not be type safe.

http://www.infosys.tuwien.ac.at/Research/Component/tutorial/prw231.htm

Perhaps it is easier if you look up the various STL's and see
them in action.

STL provides 'Containers' - vector, list, double ended queue,
queue, stack, map (associative array), set, and bitset (array of
booleans). It also provides algorithmns, iterators (I gave an
example), adaptors, and other stuff.

The STL library is not the last word on any of these, but the
language philosophy says, if you invent your own container,
where possible use a template, and adhere to the same approach,
interfaces, and iterators, and people will be able to use your
template easily, or even transparently.

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly