theelectronwill / more-collections   1.0.1

Apache License 2.0 GitHub

Some optimized Scala collections that I use in several projects

Scala versions: 2.13 2.12

ElectronWill's collections

Build Status Maven Central Scala Versions

Some optimized Scala collections that I use in several projects.

Bag

A Bag is a collection optimized for removal. Removing an element in the middle of a Bag moves the last element to "fill the gap" and costs O(1).

Implementations: SimpleBag, ConcurrentBag
These implementations do not support value types, ie no primitives.

Index

An Index associates integer IDs to the elements you add in it.

Implementations: RecyclingIndex, ConcurrentRecyclingIndex
For those implementations, get, add, update and remove are O(1).
Recycling indexes try to keep the maximum ID as small as possible by reusing the IDs of the elements that have been removed.

CompactStorage

A CompactStorage is an array of unsigned values of arbitrary bit size. Each storage defines how many bits a value takes, and stores them in a contiguous way. For instance, if you create a storage with 4 bits per value, 2 values will take exactly 1 byte.