C++ linked map template
C++ Makefile
Switch branches/tags
Nothing to show

README.md

Build Status

This project provides a header-only C++ template called linked_map, an interface-compatible extension of std::map that provides methods to iterate the key/value pairs in the order of original insertion.

The code was originally from my libnstdc++ library and recently updated.

Getting Started

The linked_map template utilizes Boost.Intrusive to provide the entry linking feature. Thus, in order to use linked_map, you need to add Boost to your compiler's include path. (linked_map is known to work with Boost 1.41+, but older versions may work as well.)

Anywhere you are using a std::map, you should be able to replace std::map with linked_map without changing the code's behavior. You can then use linked_map's member functions to access insertion iterators:

template <typename Key, typename Type, class KeyCompare, class Allocator>
class linked_map
{
  typedef *unspecified* insertion_iterator;
  typedef *unspecified* const_insertion_iterator;
  typedef *unspecified* reverse_insertion_iterator;
  typedef *unspecified* const_reverse_insertion_iterator;

  //...

  insertion_iterator ibegin();
  const_insertion_iterator ibegin() const;
  insertion_iterator iend();
  const_insertion_iterator iend() const;
  reverse_insertion_iterator ribegin();
  const_reverse_insertion_iterator ribegin() const;
  reverse_insertion_iterator riend();
  const_reverse_insertion_iterator riend() const;

  const_insertion_iterator cibegin() const;
  const_insertion_iterator ciend() const;
  const_reverse_insertion_iterator cribegin() const;
  const_reverse_insertion_iterator criend() const;
};

License

The linked_map template source is Public Domain.

Documentation and comment text, written by Daniel Trebbien, is licensed under the Creative Commons Attribution 3.0 Unported License.

Test suite source code is licensed under the GNU General Public License as published by the Free Software Foundation, either version 3 of the GPL or (at your option) any later version.