# \[Treap\] Fast random insertions/deletions collection

**URL:** <https://forums.swift.org/t/treap-fast-random-insertions-deletions-collection/53468>\
**Category:** Collections\
**Created:** [November 13, 2021, 7:07pm UTC](https://forums.swift.org/t/treap-fast-random-insertions-deletions-collection/53468 "2021-11-13T19:07:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexRoar](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alexroar/32/20441_2.png) [@AlexRoar](https://forums.swift.org/u/AlexRoar)\
**Post date:** [November 13, 2021, 7:07pm UTC](https://forums.swift.org/t/treap-fast-random-insertions-deletions-collection/53468/1 "2021-11-13T19:07:39Z")

</div>

Hi!

Working on one of my projects, I realised that there is no data structure that can address random insertions. I implemented implicit treap for this purpose that behaves like a general Array. It has O(log n) complexity for insert / remove / access.

I believe that it would be nice to see this kind of structure in the package.
