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  |
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);
|
|
|
Goto Forum:
Current Time: Sun Apr 27 21:22:52 CEST 2025
Total time taken to generate the page: 0.03523 seconds
|