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 » Proposal: BinFindIndex should return 0 for empty container
Proposal: BinFindIndex should return 0 for empty container [message #5061] Fri, 01 September 2006 19:41 Go to previous message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Currently BinFindIndex returns -1 if container is empty.

As the returned value is the slot where the element could be inserted with correct sorting, it would be possible to return 0
for empty container.
The returned value can always be out of valid range index, so I see no point for special case for empty container.

This would avoid some test code in client:

 Vector<String> v;
 v.Add(L"alf");
 v.Add(L"berta");
 v.Add(L"caesar");

 ..
 // some func getting v (possibly empty)
 String s= L"x";
 int n= BinFindIndex(v, s); // returns 3. 
 if (n<0) n= 0; // currently client must cope with empty container case
 v.Insert(n, s);

 
Read Message
Read Message
Read Message
Previous Topic: bug: AtomicXAdd for non win32, non-posix returns wrong value
Next Topic: what technique does U++ use to reduce code bloat from too many template instantiations?
Goto Forum:
  


Current Time: Thu May 09 06:04:50 CEST 2024

Total time taken to generate the page: 0.02457 seconds