zandaqo / structurae

Data structures for high-performance JavaScript applications.
MIT License
701 stars 21 forks source link

Sorted ObjectView? #14

Closed delaneyj closed 4 years ago

delaneyj commented 4 years ago

I have a situation where I need basically a sliding window buffer used between web workers. I was hoping the SortedMixin would work on an ArrayView of ObjectViews.

zandaqo commented 4 years ago

SortedMixin extends an Array or a given TypedArray interface (e.g. Int8Array, Uint32Array, etc.) whereas ArrayView and ObjectView are based on the DataView interface, so they cannot be used with SortedMixin.

I'm not sure I understand the problem, but if the idea is to sort an ArrayView, I'd recommend creating a separate array of indexes of the ArrayView and sort them. It adds an extra lookup, but depending on how often you're going to sort, it will be better than rewriting all the data inside the ArrayView.