ctietze,
@ctietze@mastodon.social avatar

@lorentey I read your 2021 forum post that a mutable SortedArray would be impractical after ~2000 items
https://forums.swift.org/t/add-sortedarray-sortedset-and-sorteddictionary-with-binary-search/47303/2

Is that because of resizing the array or the search that is required to look for a fitting index, or both?

Do you have benchmark code lying around by chance?

lorentey,
@lorentey@mastodon.social avatar

@ctietze This is primarily because insertions and removals have complexity that’s linear in the size of the array — they have to slide existing items to make room for a new one or to close gaps after a removal.

Arrays have benefits on small sizes because they are compact. Beyond a couple thousands or so items, this advantage is entirely eclipsed by all these movement costs: they become unbearably slow.
[1/2]

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • DreamBathrooms
  • khanakhh
  • magazineikmin
  • InstantRegret
  • ethstaker
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • osvaldo12
  • everett
  • kavyap
  • Durango
  • megavids
  • cubers
  • tester
  • GTA5RPClips
  • modclub
  • mdbf
  • cisconetworking
  • tacticalgear
  • Leos
  • normalnudes
  • anitta
  • provamag3
  • JUstTest
  • lostlight
  • All magazines