compaKTset is a small library aimed at providing you with the most memory efficient Set implementation for any particular data type of your choosing.

Last update: Nov 16, 2021

build-status

compaKTset is a small library aimed at providing you with the most memory efficient Set implementation for any particular data type of your choosing.

Currently supported and well-optimized types:

  • Int
  • Long
  • Double

Getting Started

<dependency>
    <groupId>me.beresnevgroupId>
    <artifactId>compaktsetartifactId>
    <version>0.1.1version>
    <dummy>unpublisheddummy>
dependency>

Example:

val intSet = newCompactSet<Int>(16)

val meaningAdded = intSet.add(42)
val containsSatan = intSet.contains(666)

Memory footprint

To understand how compact compaKTset really is, we can measure it's memory footprint and compare it with java.util.HashSet for various set sizes.

First, let's compare Int and Long with CompressedOops enabled

implementation / size 10^2 10^4 10^5 10^6
java.util.HashSet 5.9 KB 545 KB 5.8 MB 56.3 MB
CompactSet <1 KB 40 KB 0.4 MB 4 MB
10^2 10^4 10^5 10^6
java.util.HashSet 6.7 KB 625 KB 6.6 MB 64.3 MB
CompactSet <1 KB 80 KB 0.8 MB 8 MB

Now let's run it on the same VM, but with -XX:-UseCompressedOops

implementation / size 10^2 10^4 10^5 10^6
java.util.HashSet 9.3 KB 851 KB 9.2 MB 88.7 MB
CompactSet 4 KB 40 KB 0.4 MB 4 MB

For primitive types, memory saving is achieved mostly by getting rid of Entry elements (that come with headers and references) and storing elements in plain arrays.

Measurements were done using JOL, 64-bit HotSpot VM, OpenJDK11, Kotlin 1.5

Contributing

Project is built by gradle wrapper shipped in the repository

./gradlew clean build

Build requirements:

  • OpenJDK >11

GitHub

https://github.com/IgnatBeresnev/compaKTset
You might also like...

Mi-FreeForm - An APP that is activated through Shizuku/Sui and can display most apps in the form of freeform

Mi-FreeForm - An APP that is activated through Shizuku/Sui and can display most apps in the form of freeform

Mi-FreeForm 简体中文 Mi-FreeForm is an APP that is activated through Shizuku/Sui and

Aug 14, 2022

Validator - Notify type based validation for input fields.

Validator - Notify type based validation for input fields.

Validator - Notify type based validation for input fields.

Aug 12, 2022

Simple-Keyboard - A quick lightweight keyboard app that helps chatting with your friends, or inserting any other texts, numbers or symbols

Simple-Keyboard - A quick lightweight keyboard app that helps chatting with your friends, or inserting any other texts, numbers or symbols

Simple Keyboard A quick lightweight keyboard app that helps chatting with your f

Aug 12, 2022

KmmCaching - An application that illustrates fetching data from remote data source and caching it in local storage

KmmCaching - An application that illustrates fetching data from remote data source and caching it in local storage

An application that illustrates fetching data from remote data source and caching it in local storage for both IOS and Android platforms using Kotlin Multiplatform Mobile and SqlDelight.

Aug 3, 2022

A set of helper classes for using dagger 1 with Android components such as Applications, Activities, Fragments, BroadcastReceivers, and Services.

##fb-android-dagger A set of helper classes for using dagger with Android components such as Applications, Activities, Fragments, BroadcastReceivers,

Jul 14, 2021

A set of lint rules to check for common mistakes when styling and theming on Android

A set of lint rules to check for common mistakes when styling and theming on Android

A set of lint rules to check for common mistakes when styling and theming on Android

Aug 29, 2021

Matches incoming and/or outgoing text messages against set rules and sends them over to webhook.

Textmatic If you ever wanted a tool to simply push the SMS (or text messages) from your phone to somewhere remote, this is it. This app matches all in

Jan 7, 2022

KDoctor - A command-line tool that helps to set up the environment for Kotlin Multiplatform Mobile app development

KDoctor is a command-line tool that helps to set up the environment for Kotlin Multiplatform Mobile app development.

Aug 17, 2022

An easy-to-use, cross-platform measurement tool that pulls data out of CD pipelines and analysis the four key metrics for you.

An easy-to-use, cross-platform measurement tool that pulls data out of CD pipelines and analysis the four key metrics for you.

Maintained by SEA team, ThoughtWorks Inc. Read this in other languages: English, 简体中文 Table of Contents About the Project Usage How to Compute Contrib

Aug 15, 2022
Related tags
A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

Aug 25, 2021
A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

Nov 18, 2021
A beautiful set of predefined colors and a set of color methods to make your Android development life easier.
A beautiful set of predefined colors and a set of color methods to make your Android development life easier.

Colours is a port of the Colours Library for iOS made by my good friend Ben Gordon. You can find that project here. Installation Maven Central Colours

May 10, 2022
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML

A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion.

Aug 17, 2022
Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app
Small Android library to help you incorporate MVP, Passive View and Presentation Model patterns in your app

DroidMVP About DroidMVP is a small Android library to help you incorporate the MVP pattern along with Passive View and Presentation Model (yes, those

Feb 23, 2022
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.

PrivacyStreams PrivacyStreams is an Android library for easy and privacy-friendly personal data access and processing. It offers a functional programm

Apr 19, 2022
A helper library to ease the most repetitive codes with simple reusable attributes.

ak-universal-android-helper A helper library to ease the most repetitive codes with simple reusable attributes. AKUAH can help you with many repetitiv

Jul 8, 2020
Utility library that utilizes KSP to generate Room type converter classes.

Roomie Roomie is an annotation processing library that utilizes KSP to geaRoomie is an annotation processing library that utilizes KSP to generate TypeConverter classes for Room. TypeConverter classes most often involve same boiler-plate code and Roomie makes it really easy to quickly create them with a single annotation.nerate TypeConverter classes for Room. TypeConverter classes most often invol

May 2, 2022
Type safe intent building for services and activities

#IntentBuilder Type safe intent building for services and activities. IntentBuilder is a type safe way of creating intents and populating them with ex

May 17, 2022
The most comprehensive utils of ViewBinding.

ViewBinding reduces exceptions caused by id or type errors, which are recommended by both Google officials and Jake Wharton, but it can be a bit cumbersome to use, so this library can help you use ViewBinding with as little code as possible in any usage scenario.

Aug 10, 2022