Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » container.At(not_existed_item_index)
container.At(not_existed_item_index) [message #3527] Wed, 31 May 2006 10:46 Go to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
...what is "default constructed" value for item inside container, where I getting value w/ .At and there is not such a value / that index ?

I guess, its constructor like thong, but generic types(int, double...)?

parsed through code(in rush), not found...

thanx
Re: container.At(not_existed_item_index) [message #3528 is a reply to message #3527] Wed, 31 May 2006 11:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
qwerty wrote on Wed, 31 May 2006 04:46

...what is "default constructed" value for item inside container, where I getting value w/ .At and there is not such a value / that index ?

I guess, its constructor like thong, but generic types(int, double...)?

parsed through code(in rush), not found...

thanx


A good question. I guess this needs discussion / better documentation.

Right now, int, double etc... are left uninitialized, whereas for types with constructor default constructor is used. I guess this is faster and you can always specify "init".

It is true that this is unsimiliar to STL, where quite often fundamental types are zeroed using the T() "constructor". Frankly, this C++ feature is something I never really liked...

Mirek

Re: container.At(not_existed_item_index) [message #3529 is a reply to message #3527] Wed, 31 May 2006 11:32 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
It would be nice if there can be:

Array<int> my_array(default_value)
or
Array<int> my_array(default_function(default_args))

or something_like_that...
Re: container.At(not_existed_item_index) [message #3530 is a reply to message #3527] Wed, 31 May 2006 12:02 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
...and there's a items with argumented constructor only too...



maybee use of callbacks come in handy for all mentioned
Re: container.At(not_existed_item_index) [message #3531 is a reply to message #3527] Wed, 31 May 2006 12:28 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
yes, callback could be fine if .At(non_existet_item)
Re: container.At(not_existed_item_index) [message #3532 is a reply to message #3529] Wed, 31 May 2006 13:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
qwerty wrote on Wed, 31 May 2006 05:32

It would be nice if there can be:

Array<int> my_array(default_value)
or
Array<int> my_array(default_function(default_args))

or something_like_that...


I do not believe so. It would make containers too heavy and is not really needed in practice.

Adding another parameter to At is really very easy and in fact, does it matter whether the default_value is specified in constructor, or in At call? What is the point of storing value inside container just because of this?

Mirek
Re: container.At(not_existed_item_index) [message #3538 is a reply to message #3532] Wed, 31 May 2006 16:49 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
I like flowing throught my mind and there is so many ideas and so low knowledge of upp Neutral
Re: container.At(not_existed_item_index) [message #3539 is a reply to message #3538] Wed, 31 May 2006 17:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
qwerty wrote on Wed, 31 May 2006 10:49

I like flowing throught my mind and there is so many ideas and so low knowledge of upp Neutral



That is OK.

Actually, the real thing to perhaps reconsider here is "zero" vs "initialized" for fundamentals... But I believe that additional "init" parameter makes that OK...

Mirek
Re: container.At(not_existed_item_index) [message #3540 is a reply to message #3527] Wed, 31 May 2006 17:36 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
so do I, thank you for your response...

...to be complete, is there any other way, than for(...) to traverze throught container in conjunction with possibility of modifying container during traversing ?

it's something like foreach, I guess, but there's nothing too much to add...

[Updated on: Wed, 31 May 2006 17:40]

Report message to a moderator

Re: container.At(not_existed_item_index) [message #3541 is a reply to message #3540] Wed, 31 May 2006 18:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
qwerty wrote on Wed, 31 May 2006 11:36

so do I, thank you for your response...

...to be complete, is there any other way, than for(...) to traverze throught container in conjunction with possibility of modifying container during traversing ?

it's something like foreach, I guess, but there's nothing too much to add...



No, I even consider iterators deprecated now...

Last 5 years, we were almost exclusively using simple index based iteration. It has quite a lot of advantages:

- cheap range checking
- no problems with invalidated iterators
- possibility of coupling containers with other structures

That is why NTL is so index-centric now..

Mirek
Re: container.At(not_existed_item_index) [message #3542 is a reply to message #3541] Wed, 31 May 2006 18:19 Go to previous message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
after reading one special article, it seems that much clearer to me Wink
Previous Topic: user 'Value' [FEATURE REQUEST]
Next Topic: .AsValue() ??
Goto Forum:
  


Current Time: Sun May 05 10:36:00 CEST 2024

Total time taken to generate the page: 0.03096 seconds