{"id":13730660,"url":"https://github.com/sparsehash/sparsehash-c11","last_synced_at":"2025-08-24T09:36:46.555Z","repository":{"id":36617577,"uuid":"40923777","full_name":"sparsehash/sparsehash-c11","owner":"sparsehash","description":"Experimental C++11 version of sparsehash","archived":false,"fork":false,"pushed_at":"2022-10-18T15:10:22.000Z","size":1127,"stargazers_count":289,"open_issues_count":8,"forks_count":59,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-30T14:11:15.991Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://travis-ci.org/sparsehash/sparsehash-c11","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sparsehash.png","metadata":{"files":{"readme":"README","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":"2015-08-17T19:47:10.000Z","updated_at":"2025-02-26T10:46:38.000Z","dependencies_parsed_at":"2022-07-15T20:17:19.823Z","dependency_job_id":null,"html_url":"https://github.com/sparsehash/sparsehash-c11","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsehash%2Fsparsehash-c11","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsehash%2Fsparsehash-c11/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsehash%2Fsparsehash-c11/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsehash%2Fsparsehash-c11/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparsehash","download_url":"https://codeload.github.com/sparsehash/sparsehash-c11/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509235,"owners_count":20950232,"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":[],"created_at":"2024-08-03T02:01:17.739Z","updated_at":"2025-04-06T16:12:45.174Z","avatar_url":"https://github.com/sparsehash.png","language":"C++","readme":"This directory contains several hash-map implementations, similar in\nAPI to SGI's hash_map class, but with different performance\ncharacteristics.  sparse_hash_map uses very little space overhead, 1-2\nbits per entry.  dense_hash_map is very fast, particulary on lookup.\n(sparse_hash_set and dense_hash_set are the set versions of these\nroutines.)  On the other hand, these classes have requirements that\nmay not make them appropriate for all applications.\n\nAll these implementation use a hashtable with internal quadratic\nprobing.  This method is space-efficient -- there is no pointer\noverhead -- and time-efficient for good hash functions.\n\nCOMPILING\n---------\nTo compile test applications with these classes, run ./configure\nfollowed by make.  To install these header files on your system, run\n'make install'.  (On Windows, the instructions are different; see\nREADME_windows.txt.)  See INSTALL for more details.\n\nThis code should work on any modern C++ system.  It has been tested on\nLinux (Ubuntu, Fedora, RedHat, Debian), Solaris 10 x86, FreeBSD 6.0,\nOS X 10.3 and 10.4, and Windows under both VC++7 and VC++8.\n\nUSING\n-----\nSee the html files in the doc directory for small example programs\nthat use these classes.  It's enough to just include the header file:\n\n   #include \u003csparsehash/sparse_hash_map\u003e // or sparse_hash_set, dense_hash_map, ...\n   google::sparse_hash_set\u003cint, int\u003e number_mapper;\n\nand use the class the way you would other hash-map implementations.\n(Though see \"API\" below for caveats.)\n\nBy default (you can change it via a flag to ./configure), these hash\nimplementations are defined in the google namespace.\n\nAPI\n---\nThe API for sparse_hash_map, dense_hash_map, sparse_hash_set, and\ndense_hash_set, are a superset of the API of SGI's hash_map class.\nSee doc/sparse_hash_map.html, et al., for more information about the\nAPI.\n\nThe usage of these classes differ from SGI's hash_map, and other\nhashtable implementations, in the following major ways:\n\n1) dense_hash_map requires you to set aside one key value as the\n   'empty bucket' value, set via the set_empty_key() method.  This\n   *MUST* be called before you can use the dense_hash_map.  It is\n   illegal to insert any elements into a dense_hash_map whose key is\n   equal to the empty-key.\n\n2) For both dense_hash_map and sparse_hash_map, if you wish to delete\n   elements from the hashtable, you must set aside a key value as the\n   'deleted bucket' value, set via the set_deleted_key() method.  If\n   your hash-map is insert-only, there is no need to call this\n   method.  If you call set_deleted_key(), it is illegal to insert any\n   elements into a dense_hash_map or sparse_hash_map whose key is\n   equal to the deleted-key.\n\n3) These hash-map implementation support I/O.  See below.\n\nThere are also some smaller differences:\n\n1) The constructor takes an optional argument that specifies the\n   number of elements you expect to insert into the hashtable.  This\n   differs from SGI's hash_map implementation, which takes an optional\n   number of buckets.\n\n2) erase() does not immediately reclaim memory.  As a consequence,\n   erase() does not invalidate any iterators, making loops like this\n   correct:\n      for (it = ht.begin(); it != ht.end(); ++it)\n        if (...) ht.erase(it);\n   As another consequence, a series of erase() calls can leave your\n   hashtable using more memory than it needs to.  The hashtable will\n   automatically compact at the next call to insert(), but to\n   manually compact a hashtable, you can call\n      ht.resize(0)\n\nI/O\n---\nIn addition to the normal hash-map operations, sparse_hash_map can\nread and write hashtables to disk.  (dense_hash_map also has the API,\nbut it has not yet been implemented, and writes will always fail.)\n\nIn the simplest case, writing a hashtable is as easy as calling two\nmethods on the hashtable:\n   ht.write_metadata(fp);\n   ht.write_nopointer_data(fp);\n\nReading in this data is equally simple:\n   google::sparse_hash_map\u003c...\u003e ht;\n   ht.read_metadata(fp);\n   ht.read_nopointer_data(fp);\n\nThe above is sufficient if the key and value do not contain any\npointers: they are basic C types or agglomorations of basic C types.\nIf the key and/or value do contain pointers, you can still store the\nhashtable by replacing write_nopointer_data() with a custom writing\nroutine.  See sparse_hash_map.html et al. for more information.\n\nSPARSETABLE\n-----------\nIn addition to the hash-map and hash-set classes, this package also\nprovides sparsetable.h, an array implementation that uses space\nproportional to the number of elements in the array, rather than the\nmaximum element index.  It uses very little space overhead: 2 to 5\nbits per entry.  See doc/sparsetable.html for the API.\n\nRESOURCE USAGE\n--------------\n* sparse_hash_map has memory overhead of about 4 to 10 bits per \n  hash-map entry, assuming a typical average occupancy of 50%.\n* dense_hash_map has a factor of 2-3 memory overhead: if your\n  hashtable data takes X bytes, dense_hash_map will use 3X-4X memory\n  total.\n\nHashtables tend to double in size when resizing, creating an\nadditional 50% space overhead.  dense_hash_map does in fact have a\nsignificant \"high water mark\" memory use requirement, which is 6 times\nthe size of hash entries in the table when resizing (when reaching \n50% occupancy, the table resizes to double the previous size, and the \nold table (2x) is copied to the new table (4x)).\n\nsparse_hash_map, however, is written to need very little space\noverhead when resizing: only a few bits per hashtable entry.\n\nPERFORMANCE\n-----------\nYou can compile and run the included file time_hash_map.cc to examine\nthe performance of sparse_hash_map, dense_hash_map, and your native\nhash_map implementation on your system.  One test against the\nSGI hash_map implementation gave the following timing information for\na simple find() call:\n   SGI hash_map:     22 ns\n   dense_hash_map:   13 ns\n   sparse_hash_map: 117 ns\n   SGI map:         113 ns\n\nSee doc/performance.html for more detailed charts on resource usage\nand performance data.\n\n---\n16 March 2005\n(Last updated: 12 September 2010)\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparsehash%2Fsparsehash-c11","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparsehash%2Fsparsehash-c11","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparsehash%2Fsparsehash-c11/lists"}