Which collection type in kotlin is considered to b...
# kotlin-native
j
Which collection type in kotlin is considered to be the most performant? Things to be considdering is that it should handle a lot add and a lot of deletes. Is there even such a collection, that tries to as performant as it could possibly be?
d
iirc, K/N doesn't have Linked Lists (yet).
p
Yes, there is no Linked List library at the moment
Would be a great idea for an open source project tbh
s
Also there’s no such thing as “performant as it could possibly be” generally. If you optimize performance for certain operations you’ll likely not be able to optimize for others. Best data structures for insertion/deletion are stacks, queues, linked lists, and hash tables, all of which are constant time ideally for both operations. Of course depending on your needs one may be better than the others.
k
hashtable does involve rehashing, making it amortized constant. usually not a concern, but could be when doing a lot of insertions and deletions.
j
@Sam Schilling Actually there is, both hashmaps and tiered vectors fit this criteria for the specified operation
Seems like this would be a cool side-project then, thanks for the answers 🙂
s
I said generally, meaning a “one-size fits all” collection that maxes performance for all criteria. For your operations though yes, there are collections that work better