🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.6 KiB

  1. # Crash Course: containers
  2. <!--
  3. @cond TURN_OFF_DOXYGEN
  4. -->
  5. # Table of Contents
  6. * [Introduction](#introduction)
  7. * [Containers](#containers)
  8. * [Dense map](#dense-map)
  9. * [Dense set](#dense-set)
  10. <!--
  11. @endcond TURN_OFF_DOXYGEN
  12. -->
  13. # Introduction
  14. The standard C++ library offers a wide range of containers and it's really
  15. difficult to do better (although it's very easy to do worse, as many examples
  16. available online demonstrate).<br/>
  17. `EnTT` doesn't try in any way to replace what is offered by the standard. Quite
  18. the opposite, given the widespread use that is made of standard containers.<br/>
  19. However, the library also tries to fill a gap in features and functionality by
  20. making available some containers initially developed for internal use.
  21. This section of the library is likely to grow larger over time. However, for the
  22. moment it's quite small and mainly aimed at satisfying some internal needs.<br/>
  23. For all containers made available, full test coverage and stability over time is
  24. guaranteed as usual.
  25. # Containers
  26. ## Dense map
  27. The dense map made available in `EnTT` is a hash map that aims to return a
  28. packed array of elements, so as to reduce the number of jumps in memory during
  29. iterations.<br/>
  30. The implementation is based on _sparse sets_ and each bucket is identified by an
  31. implicit list within the packed array itself.
  32. The interface is very close to its counterpart in the standard library, that is,
  33. `std::unordered_map`.<br/>
  34. However, both local and non-local iterators returned by a dense map belong to
  35. the input iterator category although they respectively model the concepts of a
  36. _forward iterator_ type and a _random access iterator_ type.<br/>
  37. This is because they return a pair of references rather than a reference to a
  38. pair. In other words, dense maps return a so called _proxy iterator_ the value
  39. type of which is:
  40. * `std::pair<const Key &, Type &>` for non-const iterator types.
  41. * `std::pair<const Key &, const Type &>` for const iterator types.
  42. This is quite different from what any standard library map returns and should be
  43. taken into account when looking for a drop-in replacement.
  44. ## Dense set
  45. The dense set made available in `EnTT` is a hash set that aims to return a
  46. packed array of elements, so as to reduce the number of jumps in memory during
  47. iterations.<br/>
  48. The implementation is based on _sparse sets_ and each bucket is identified by an
  49. implicit list within the packed array itself.
  50. The interface is in all respects similar to its counterpart in the standard
  51. library, that is, `std::unordered_set`.<br/>
  52. Therefore, there is no need to go into the API description.