|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I've been looking into vector, deque and list documentation. None of
these have the nifty little feature that a VB collection has, and which comes in very handy for code readability as soon as you are developing a GUI. I'm thinking along the lines of mywindow("lblLastChanged")->caption = "2008-01-18 14:13h"; Before I create my own template for this, based on list or vector class, is there something that does this in any c++ libraries? I must have missed it then. And if there is an implementation, is it speed-optimized (with indexing maybe)? Just so that it doesn't end up similar to the following? element *collection::getElementByName (const char *name) { element *e = this->first; do { if (!strcmp (name, e->name)) return e; e = e->next; } while (e != this->first); return NULL; } Thanks for any input! Lars |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Lars Uffmann wrote:
> I've been looking into vector, deque and list documentation. None of > these have the nifty little feature that a VB collection has, and which > comes in very handy for code readability as soon as you are developing a > GUI. I'm thinking along the lines of > mywindow("lblLastChanged")->caption = "2008-01-18 14:13h"; > > Before I create my own template for this, based on list or vector class, > is there something that does this in any c++ libraries? I must have > missed it then. > > And if there is an implementation, is it speed-optimized (with indexing > maybe)? Just so that it doesn't end up similar to the following? > > element *collection::getElementByName (const char *name) > { > element *e = this->first; > > do { > if (!strcmp (name, e->name)) > return e; > e = e->next; > } while (e != this->first); > > return NULL; > } What about std::map< std::string, whatever > mywindow; Best Kai-Uwe Bux |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Hi Kai,
jkherciueh@gmx.net wrote: > What about > std::map< std::string, whatever > mywindow; map - of course... doh! Thanks a lot - that's what I was looking for! ![]() Lars |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 2008-01-18 14:45, Lars Uffmann wrote:
> Hi Kai, > > jkherciueh@gmx.net wrote: >> What about >> std::map< std::string, whatever > mywindow; > > map - of course... doh! Thanks a lot - that's what I was looking for! ![]() Just a few comments: std::map is what you would call "speed optimised" so that a lookup takes O(log n) (usually implemented by a red-black tree). Unlike a VB collection you can not access elements both by key and index. Though you can get an iterator to the first element and advance it to the desired element. -- Erik Wikström |
|
![]() |
| Outils de la discussion | |
|
|