{"id":16825738,"url":"https://github.com/nlohmann/fifo_map","last_synced_at":"2025-04-09T13:06:43.696Z","repository":{"id":36464768,"uuid":"40770011","full_name":"nlohmann/fifo_map","owner":"nlohmann","description":"a FIFO-ordered associative container for C++","archived":false,"fork":false,"pushed_at":"2023-06-15T18:45:13.000Z","size":149,"stargazers_count":190,"open_issues_count":6,"forks_count":80,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-02T11:06:33.597Z","etag":null,"topics":["associative-map","container","fifo","ordered","stl"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nlohmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nlohmann","custom":"http://paypal.me/nlohmann"}},"created_at":"2015-08-15T16:12:43.000Z","updated_at":"2025-02-19T13:41:41.000Z","dependencies_parsed_at":"2024-10-26T21:14:23.860Z","dependency_job_id":"40505e75-9fb5-4d5f-ab8f-eddf05402bbc","html_url":"https://github.com/nlohmann/fifo_map","commit_stats":{"total_commits":43,"total_committers":9,"mean_commits":4.777777777777778,"dds":0.2558139534883721,"last_synced_commit":"d732aaf9a315415ae8fd7eb11e3a4c1f80e42a48"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlohmann%2Ffifo_map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlohmann%2Ffifo_map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlohmann%2Ffifo_map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlohmann%2Ffifo_map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nlohmann","download_url":"https://codeload.github.com/nlohmann/fifo_map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"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":["associative-map","container","fifo","ordered","stl"],"created_at":"2024-10-13T11:14:55.789Z","updated_at":"2025-04-09T13:06:43.676Z","avatar_url":"https://github.com/nlohmann.png","language":"C++","readme":"[![Build Status](https://travis-ci.org/nlohmann/fifo_map.svg?branch=master)](https://travis-ci.org/nlohmann/fifo_map)\n[![Build status](https://ci.appveyor.com/api/projects/status/ilx8h73gq2gcfbmf?svg=true)](https://ci.appveyor.com/project/nlohmann/fifo-map)\n[![Coverage Status](https://img.shields.io/coveralls/nlohmann/fifo_map.svg)](https://coveralls.io/r/nlohmann/fifo_map)\n[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/l2f2Qxhq95qVKRgE)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/fifo_map/master/LICENSE.MIT)\n[![Github Releases](https://img.shields.io/github/release/nlohmann/fifo_map.svg)](https://github.com/nlohmann/fifo_map/releases)\n[![Github Issues](https://img.shields.io/github/issues/nlohmann/fifo_map.svg)](http://github.com/nlohmann/fifo_map/issues)\n\n# `fifo_map` – a FIFO-ordered associative container for C++\n\n## Overview\n\nC++ allows to defined associative containers such as `std::map`. The values are ordered according to their keys and an ordering relation. The `fifo_map` is an associative container which uses **the order in which keys were inserted to the container** as ordering relation.\n\nAs it has the same interface than `std::map`, it can be used as drop-in replacement. The code is header-only (see file [src/fifo_map.hpp](https://github.com/nlohmann/fifo_map/blob/master/src/fifo_map.hpp)) and only relies on the STL.\n\n## Complexity\n\nA `fifo_map` object has the space overhead of:\n- one `std::unordered_map\u003cKey, std::size_t\u003e` object to store the key order,\n- one pointer to this object in the `Compare` object.\n\nInserting a value (via `operator[]`, `insert`) and removing a value (`erase`) rely on `std::unordered_map::insert` and `std::unordered_map::erase` which have O(1) average complexity and O(n) worst-case complexity. All other methods have the same performance as the equivalent `std::map` options.\n\n## Example\n\n```cpp\n#include \"src/fifo_map.hpp\"\n\n// for convenience\nusing nlohmann::fifo_map;\n\nint main() {\n    // create fifo_map with template arguments\n    fifo_map\u003cint, std::string\u003e m;\n\n    // add elements\n    m[2] = \"two\";\n    m[3] = \"three\";\n    m[1] = \"one\";\n    \n    // output the map; will print\n    // 2: two\n    // 3: three\n    // 1: one\n    for (auto x : m) {\n        std::cout \u003c\u003c x.first \u003c\u003c \": \" \u003c\u003c x.second \u003c\u003c \"\\n\";\n    }\n    \n    // delete an element\n    m.erase(2);\n    \n    // re-add element\n    m[2] = \"zwei\";\n    \n    // output the map; will print\n    // 3: three\n    // 1: one\n    // 2: zwei\n    for (auto x : m) {\n        std::cout \u003c\u003c x.first \u003c\u003c \": \" \u003c\u003c x.second \u003c\u003c \"\\n\";\n    }\n}\n```\n\n[Try this code online.](http://melpon.org/wandbox/permlink/l2f2Qxhq95qVKRgE)\n\n## License\n\n\u003cimg align=\"right\" src=\"http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png\"\u003e\n\nThe code is licensed under the [MIT License](http://opensource.org/licenses/MIT):\n\nCopyright \u0026copy; 2015-2017 [Niels Lohmann](http://nlohmann.me)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n## Execute unit tests\n\nTo compile and run the tests, you need to execute\n\n```sh\n$ make\n$ ./unit\n\n===============================================================================\nAll tests passed (1286 assertions in 8 test cases)\n```\n\nFor more information, have a look at the file [.travis.yml](https://github.com/nlohmann/fifo_map/blob/master/.travis.yml).\n","funding_links":["https://github.com/sponsors/nlohmann","http://paypal.me/nlohmann"],"categories":["Containers"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlohmann%2Ffifo_map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlohmann%2Ffifo_map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlohmann%2Ffifo_map/lists"}