{"id":15482443,"url":"https://github.com/uchuhimo/kotlinx-bimap","last_synced_at":"2025-08-07T17:45:00.992Z","repository":{"id":57729274,"uuid":"96764721","full_name":"uchuhimo/kotlinx-bimap","owner":"uchuhimo","description":"A bimap (bidirectional map) implementation for Kotlin","archived":false,"fork":false,"pushed_at":"2018-10-20T09:42:48.000Z","size":191,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T15:50:44.113Z","etag":null,"topics":["bimap","guava","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uchuhimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-10T10:22:11.000Z","updated_at":"2023-09-29T17:34:49.000Z","dependencies_parsed_at":"2022-09-10T21:51:33.152Z","dependency_job_id":null,"html_url":"https://github.com/uchuhimo/kotlinx-bimap","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/uchuhimo/kotlinx-bimap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchuhimo%2Fkotlinx-bimap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchuhimo%2Fkotlinx-bimap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchuhimo%2Fkotlinx-bimap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchuhimo%2Fkotlinx-bimap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uchuhimo","download_url":"https://codeload.github.com/uchuhimo/kotlinx-bimap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchuhimo%2Fkotlinx-bimap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269298127,"owners_count":24393710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bimap","guava","kotlin"],"created_at":"2024-10-02T05:09:12.677Z","updated_at":"2025-08-07T17:45:00.911Z","avatar_url":"https://github.com/uchuhimo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kotlinx-bimap\n\n[![Java 6+](https://img.shields.io/badge/Java-6+-4c7e9f.svg)](http://java.oracle.com)\n[![Maven metadata URL](https://img.shields.io/maven-metadata/v/http/central.maven.org/maven2/com/uchuhimo/kotlinx-bimap/maven-metadata.xml.svg)](https://search.maven.org/artifact/com.uchuhimo/kotlinx-bimap)\n[![Bintray](https://api.bintray.com/packages/uchuhimo/maven/kotlinx-bimap/images/download.svg)](https://bintray.com/uchuhimo/maven/kotlinx-bimap/_latestVersion)\n[![JitPack](https://jitpack.io/v/uchuhimo/kotlinx-bimap.svg)](https://jitpack.io/#uchuhimo/kotlinx-bimap)\n[![Build Status](https://travis-ci.org/uchuhimo/kotlinx-bimap.svg?branch=master)](https://travis-ci.org/uchuhimo/kotlinx-bimap)\n[![codecov](https://codecov.io/gh/uchuhimo/kotlinx-bimap/branch/master/graph/badge.svg)](https://codecov.io/gh/uchuhimo/kotlinx-bimap)\n[![codebeat badge](https://codebeat.co/badges/92db60e6-08a4-443d-a7b8-1868c5bb7ab8)](https://codebeat.co/projects/github-com-uchuhimo-kotlinx-bimap-master)\n\nA bimap (bidirectional map) implementation for Kotlin.\n\n## Prerequisites\n\n- JDK 1.6 or higher\n\n## Interfaces and implementations\n\nThis library provides interfaces for read-only/mutable bimap:\n\n| Interface | Bases | Implementations |\n| - | - | - |\n| `BiMap` | `Map` | `emptyBiMap`, `biMapOf`, `toBiMap` |\n| `MutableBiMap` | `MutableMap`, `BiMap` | `mutableBiMapOf`, `toMutableBiMap` |\n\n## Operations\n\n### Create read-only bimap\n\n- Create an empty read-only bimap:\n\n  ```kotlin\n  val newBiMap = emptyBiMap()\n  ```\n\n- Create a new read-only bimap from pairs:\n\n  ```kotlin\n  val newBiMap = biMapOf(1 to \"1\", 2 to \"2\", 3 to \"3\")\n  ```\n\n- Create a new read-only bimap from map:\n\n  ```kotlin\n  val newBiMap = mapOf(1 to \"1\", 2 to \"2\", 3 to \"3\").toBiMap()\n  ```\n\n### Create mutable bimap\n\n- Create an empty mutable bimap:\n\n  ```kotlin\n  val newBiMap = mutableBiMapOf()\n  ```\n\n- Create a new mutable bimap from pairs:\n\n  ```kotlin\n  val newBiMap = mutableBiMapOf(1 to \"1\", 2 to \"2\", 3 to \"3\")\n  ```\n\n- Create a new mutable bimap from map:\n\n  ```kotlin\n  val newBiMap = mapOf(1 to \"1\", 2 to \"2\", 3 to \"3\").toMutableBiMap()\n  ```\n\n### Query bimap\n\n- Bimap support all operations of map:\n\n  ```kotlin\n  val biMap = biMapOf(1 to \"1\", 2 to \"2\", 3 to \"3\")\n  biMap.size // 3\n  biMap.isEmpty() // false\n  biMap.values // [\"1\", \"2\", \"3\"]\n  biMap[1] // \"1\"\n  biMap.containsKey(4) // false\n  ```\n\n- Get the inverse view of bimap:\n\n  ```kotlin\n  val biMap = biMapOf(1 to \"1\", 2 to \"2\", 3 to \"3\")\n  val inverseBiMap = biMap.inverse\n  inverseBiMap.values // [1, 2, 3]\n  ```\n\n### Mutate mutable bimap\n\nMutable bimap support all operations of mutable map:\n\n```kotlin\nval mutableBiMap = mutableBiMapOf(1 to \"1\", 2 to \"2\", 3 to \"3\")\nmutableBiMap[3] = \"4\"\nmutableBiMap.remove(1)\nmutableBiMap.clear()\n```\n\nWhen using `put` operation (i.e., `mutableBiMap[3] = \"4\"`), the bimap throws `IllegalArgumentException` if the given value is already bound to a different key in it. The bimap will remain unmodified in this event. To avoid this exception, call `forcePut` instead:\n\n```kotlin\nmutableBiMap.forcePut(4, \"2\")\n```\n\nThe `forcePut` operation will silently remove any existing entry with the value before proceeding with the `put` operation.\n\n### Interoperability with Guava bimap\n\n- Views a mutable bimap as a Guava bimap:\n\n  ```kotlin\n  val mutableBiMap = mutableBiMapOf(1 to \"1\", 2 to \"2\", 3 to \"3\")\n  val guavaBiMap = mutableBiMap.asGuavaBiMap()\n  ```\n\n- Views a Guava bimap as a mutable bimap:\n\n  ```kotlin\n  val guavaBiMap = HashBiMap.create(mapOf(1 to \"1\", 2 to \"2\", 3 to \"3\"))\n  val mutableBiMap = guavaBiMap.asMutableBiMap()\n  ```\n\n## Using in your projects\n\nThis library has been published to [Maven Central](https://search.maven.org/artifact/com.uchuhimo/kotlinx-bimap), [JCenter](https://bintray.com/uchuhimo/maven/kotlinx-bimap) and [JitPack](https://jitpack.io/#uchuhimo/kotlinx-bimap).\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.uchuhimo\u003c/groupId\u003e\n  \u003cartifactId\u003ekotlinx-bimap\u003c/artifactId\u003e\n  \u003cversion\u003e1.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n\n```groovy\ncompile 'com.uchuhimo:kotlinx-bimap:1.2'\n```\n\n### Gradle Kotlin DSL\n\n```kotlin\ncompile(group = \"com.uchuhimo\", name = \"kotlinx-bimap\", version = \"1.2\")\n```\n\n## Building from source\n\nBuild library with Gradle using the following command:\n\n```\ngradlew clean assemble\n```\n\nTest library with Gradle using the following command:\n\n```\ngradlew clean test\n```\n\nSince Gradle has excellent incremental build support, you can usually omit executing the `clean` task.\n\nInstall library in a local Maven repository for consumption in other projects via the following command:\n\n```\ngradlew clean install\n```\n\n# License\n\n© uchuhimo, 2017-2018. Licensed under an [Apache 2.0](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuchuhimo%2Fkotlinx-bimap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuchuhimo%2Fkotlinx-bimap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuchuhimo%2Fkotlinx-bimap/lists"}