View Issue Details

IDProjectCategoryView StatusLast Update
0002065NoesisGUIC++ SDKpublic2021-07-28 11:38
Reportersteveh Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status assignedResolutionopen 
Product Version3.0.9 
Summary0002065: CollectionSortBehaviour::RemSortedItem uses incorrect logic
Description

Hi guys,

Just wanted to let you know that CollectionSortBehaviour::RemSortedItem breaks if there are multiple elements with the same priority. The current implementation tries to find the index of the element to remove by binary searching. This works fine if everything has a unique priority, but if there are multiple elements with the same priority then this might attempt to remove any elements matching the input priority.

For now we've just changed the implementation to a linear search:

void CollectionSortBehaviour::RemSortedItem(SortComparer comparer, SortedCollection list, Noesis:::BaseComponent* item)
{
list->Remove(item);
}

Obviously this changes the O(log n) -> O(n), but that's fine for us as n is trivially small.

Steps To Reproduce
  1. Create an observable collection, fill with some elements
  2. Create a sort behaviour
  3. Create a custom SortComparer, make the compare function return 0 for more than 1 element in your collection (i.e. multiple elements have the same priority)
  4. Attempt to remove that element from your list
  5. Notice that it can remove an incorrect item.
PlatformAny

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2021-07-27 11:52 steveh New Issue
2021-07-28 11:38 jsantos Assigned To => sfernandez
2021-07-28 11:38 jsantos Status new => assigned
2021-07-28 11:38 jsantos Target Version => 3.0.13