Quaver.API icon indicating copy to clipboard operation
Quaver.API copied to clipboard

Optimize search algorithms

Open Emik03 opened this issue 1 year ago • 0 comments

The Qua has an invariance relating to its collections: It is always sorted by StartTime. Knowing this, we can use this property to use a binary search implementation instead for its various functions, which is much faster given that hit objects and scroll velocites tends to be in the thousands, if not tens of thousands. ~~We also implement IComparable<T> for these instances which allows us to use the default List<T>.Sort instead of having to do .OrderBy().ToList(). This additionally increases performance by doing in-memory sorting.~~ A .HybridSort() function exists to pick the best strategy for any List<T> that implements IStartTime for T, which is a hybrid sorting algorithm between insertion sort and quick sort.

Emik03 avatar Jul 26 '24 17:07 Emik03