{"id":20397307,"url":"https://github.com/nielsbasjes/prefixmap","last_synced_at":"2025-04-12T13:08:44.365Z","repository":{"id":34294942,"uuid":"162128553","full_name":"nielsbasjes/prefixmap","owner":"nielsbasjes","description":"A Map type data structure intended to store prefixes instead of keys. ","archived":false,"fork":false,"pushed_at":"2025-04-11T16:08:58.000Z","size":570,"stargazers_count":8,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T13:08:39.080Z","etag":null,"topics":["datastructures","java","prefixmap"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nielsbasjes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"nielsbasjes","custom":"https://www.paypal.me/nielsbasjes"}},"created_at":"2018-12-17T12:38:22.000Z","updated_at":"2025-04-11T16:08:36.000Z","dependencies_parsed_at":"2023-10-22T18:28:29.658Z","dependency_job_id":"dafc078c-c027-4c5f-8b6a-82fe1d4e5e56","html_url":"https://github.com/nielsbasjes/prefixmap","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsbasjes%2Fprefixmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsbasjes%2Fprefixmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsbasjes%2Fprefixmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsbasjes%2Fprefixmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nielsbasjes","download_url":"https://codeload.github.com/nielsbasjes/prefixmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571891,"owners_count":21126522,"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","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":["datastructures","java","prefixmap"],"created_at":"2024-11-15T04:13:13.917Z","updated_at":"2025-04-12T13:08:44.335Z","avatar_url":"https://github.com/nielsbasjes.png","language":"Java","funding_links":["https://github.com/sponsors/nielsbasjes","https://www.paypal.me/nielsbasjes"],"categories":[],"sub_categories":[],"readme":"PrefixMap: A Map type datastructure that uses prefixes instead of keys\n========================================\n[![Github actions Build status](https://img.shields.io/github/actions/workflow/status/nielsbasjes/prefixmap/build.yml?branch=main)](https://github.com/nielsbasjes/prefixmap/actions)\n[![Coverage Status](https://img.shields.io/codecov/c/github/nielsbasjes/prefixmap)](https://app.codecov.io/gh/nielsbasjes/prefixmap)\n[![License](https://img.shields.io/:license-apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Maven Central](https://img.shields.io/maven-central/v/nl.basjes.collections/prefixmap.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22nl.basjes.collections%22)\n[![If this project has business value for you then don't hesitate to support me with a small donation.](https://img.shields.io/badge/Sponsor%20me-via%20Github-red.svg)](https://github.com/sponsors/nielsbasjes)\n[![If this project has business value for you then don't hesitate to support me with a small donation.](https://img.shields.io/badge/Donations-via%20Paypal-red.svg)](https://www.paypal.me/nielsbasjes)\n\nThis is a java library that implements a datastructure I consider to be missing in the java landscape.\n\nThe datastructure and its usages\n================================\nIn several situations I have a set of values that are each associated with a different prefix of a String.\n\nThe example where I found the biggest need for this was when analyzing the device tags of mobile devices.\n\n- A \"GT-I8190N\" is a \"Samsung\" device because it starts with \"GT-\".\n- A \"RM-1092\" is a \"Nokia\" device because it starts with \"RM-\".\n\nSo I needed a lookup structure that maps these prefixes to the desired brands.\n\n    \"GT-\" : \"Samsung\"\n    \"RM-\" : \"Nokia\"\n\nWith this code you can now do this type of lookup in a very fast way:\n\n    // Parameter caseSensitive=false --\u003e so lookups are caseINsensitive\n    PrefixMap\u003cString\u003e brandLookup = new StringPrefixMap\u003c\u003e(false);\n\n    brandLookup.put(\"GT-\", \"Samsung\");\n    brandLookup.put(\"RM-\", \"Nokia\");\n\n    String brandGT = brandLookup.getLongestMatch(\"GT-I8190N\");   // --\u003e \"Samsung\"\n    String brandRM = brandLookup.getLongestMatch(\"RM-1092\");     // --\u003e \"Nokia\"\n\nAll you need is to add this dependency to you project\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003enl.basjes.collections\u003c/groupId\u003e\n      \u003cartifactId\u003eprefixmap\u003c/artifactId\u003e\n      \u003cversion\u003e2.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\nVersion 2.0 If you are using Kryo 5.x you can use this to register all classes:\n\n    StringPrefixMap.configureKryo(kryo);\n\nBlog post\n=========\nA bit more background about this datastructure and how it works can be found in this blog which I wrote about it: [https://techlab.bol.com/finding-the-longest-matching-string-prefix-fast/](https://techlab.bol.com/finding-the-longest-matching-string-prefix-fast/) ([Local copy](Article.md))\n\nDonations\n===\nIf this project has business value for you then don't hesitate to support me with a small donation.\n\n[![If this project has business value for you then don't hesitate to support me with a small donation.](https://img.shields.io/badge/Sponsor%20me-via%20Github-red.svg)](https://github.com/sponsors/nielsbasjes)\n[![If this project has business value for you then don't hesitate to support me with a small donation.](https://img.shields.io/badge/Donations-via%20Paypal-red.svg)](https://www.paypal.me/nielsbasjes)\n\nLicense\n=======\n\n    Copyright (C) 2018-2021 Niels Basjes\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnielsbasjes%2Fprefixmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnielsbasjes%2Fprefixmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnielsbasjes%2Fprefixmap/lists"}