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 » Error in "NTL - moveable" documentation?
Error in "NTL - moveable" documentation? [message #4249] Sun, 30 July 2006 11:00 Go to previous message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Unless I'm very much mistaken the SimpleVector template in "Browse topics - srcdoc - Core" cannot work:

When you instantiate the class the constructor sets capacity and items = 0.
When you add an item items is >= 0 and Expand is called.
Expand doubles capacity, but 2 * 0 still yields 0.
So capacity can never grow.

Although the example demonstrates what it is supposed to demonstrate, in my personal opinion it should be faultless - be it just for didactic reasons.

One possible solution might be:

void Expand()
{
    if (capacity == 0)
        ++capacity;
    else
        capacity *= 2;
    ...


Werner

[Updated on: Sun, 30 July 2006 11:04]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: More String Functions [FEATURE REQUEST]
Next Topic: running programs from upp program
Goto Forum:
  


Current Time: Sun Apr 28 03:01:02 CEST 2024

Total time taken to generate the page: 0.04530 seconds