- Learn Scala Programming
- Slava Schmidt
- 119字
- 2025-02-24 07:23:39
SeqMap
SeqMap is a generic abstraction for ordered immutable maps. SeqMap itself exists in mutable and immutable forms. These forms have few different implementations:
- The immutable ListMap implements immutable maps using a list-based data structure. The methods traversing ListMap visit its elements in the order they were inserted.
- The mutable ListMap is a simple mutable map backed by a list. It preserves insertion order as its immutable sibling does.
- VectorMap exists only in immutable form. It is implemented using a vector/map-based data structure and preserves insertion order. It has constant lookup but slower other operations.
- LinkedHashMap is a mutable map whose implementation is based on a hashtable and preserves the insertion order if iterated over.