# A Better Hash Map -- 1

DevFeed: [A Better Hash Map -- 1](<https://devfeed.tech/articles/a-better-hash-map-1-25594.md>)

Original publisher: [Read original article](<https://www.romainguy.dev/posts/2024/a-better-hashmap/>)

Author: Romain Guy

Published: 2024-01-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Posts on Romain Guy](<https://devfeed.tech/sources/posts-on-romain-guy.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Compose](<https://devfeed.tech/topics/compose.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [Cache](<https://devfeed.tech/topics/cache.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [compose](<https://devfeed.tech/tags/compose.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [developer](<https://devfeed.tech/tags/developer.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [memory](<https://devfeed.tech/tags/memory.md>), [performance](<https://devfeed.tech/tags/performance.md>), [storage](<https://devfeed.tech/tags/storage.md>)

## AI overview

This article examines hash maps in Jetpack Compose and introduces ScatterMap as a more memory-efficient alternative for the toolkit's use cases. It describes reduced per-entry overhead, allocation-free operations in several cases, linear storage for improved cache behavior, and performance that is better than or comparable to existing map implementations, based on benchmark results from a Pixel 6 running Android 13.

## Source excerpt

Hash maps are extremely common data structures, and Jetpack Compose unsurprisingly takes advantage of them for various tasks. Kotlin makes it easy to create a new mutable hash map by calling the mutableMapOf() function. Most developer will -- and should -- stop there, and use the map however they need to. Things are however a bit different when working on a toolkit like Jetpack Compose as we need to ensure the toolkit's behavior is as unintrusive as possible for the app.