Prerequisits

#include <Map.h>

using namespace polymake; 

Introduction

template <class Key, class Data, class KeyComparator=BuildBinary<operations::cmp> > class Map;

An associative container in the STL sense. It differs from the standard std::map in the implementation: it uses an AVL tree instead of the red-black tree. The tree is attached via a smart pointer with reference counting.

Construction

This assertion is active only in the debugging compilation mode.
Map();
explicit Map (const KeyComparator&)
Create an empty map. Initialize the element comparator with its default constructor (the first variant) or from a given prototype (the second variant).
template <typename Iterator>
Map (Iterator src, Iterator src_end);
template <typename Iterator>
Map (Iterator src, end_sensitive);
Initialize the map elements from an input sequence. The keys must follow in the ascending order in the sense of the KeyComparator.
The only purpose of the dummy argument end_sensitive is to signal that the first argument src has to be treated as an end-sensitive iterator. A template constructor with a single argument would shadow all other constructors away!

Modification

void std::swap(Map&, Map&);
Swap the contents of two maps in a most efficient way.
void Map::clear();
Make the map empty.

Element access

The real return type is a masquerade reference Keys< Map >& referring to the originator map.
The real return type is a masquerade reference Values< Map >& referring to the originator map.

Map inherits the AVL tree data access interface. The map entries accesible via iterators have the form std::pair< Key, Data >.

const GenericSet& keys (const Map&);
const Container& values (const Map&);
Give separate access to the key and data parts of the map entries. Since the keys are sorted, the key sequence belongs to the GenericSet family. The data parts (values) are visited in the same order as the keys.
The names of these functions are chosen deliberately identical to those of standard perl functions.

Random access

The real return type is a temporary object pm::TransformedContainer< const KeyContainer&, operations::associative<Map> >. It serves as a proxy object forwarding the lookup requests for single keys to the originator Map object.
template <typename SomeKey>
Data& operator[] (const SomeKey&);
template <typename SomeKey>
const Data& operator[] (const SomeKey&) const
throw (no_match);
Find the data element associated with the given key. If it didn't exist so far, it will be created with the default constructor of Data in the non-const variant, while the const method will raise an exception, since it is not allowed to create new elements.
Note that the type of the search key is not necessarily the same as of the map entries. It suffices that both are comparable with each other.
template <typename KeyContainer>
Container operator[] (const KeyContainer&);
template <typename KeyContainer>
const Container operator[] (const KeyContainer&) const
throw (no_match);
Create a pseudo-container consisting of data elements associated with the given keys. Non-existent elements are handled analogously to the single-key operator [].
The idea of this operator is leaned from perl, too.
Note that the implementation of the single-key and multi-key search operators is one and the same method; they are explained separately with the only aim: to describe the result types as simple as possible.

Exception type

class no_match : public std::runtime_error
Raised by random search methods of associative containers, such as Map, if a search key can not be found and the container object is immutable.

Input/output

std::ostream& operator<< (std::ostream& , const Map&);
Print the map to the output stream. The entries are printed as (key value) pairs, the whole sequence is enclosed in curly braces.
explicit Map (Poly&);
Poly& operator>> (Poly&, Map&);
Read a property from the polymake server. Parse errors are reported by raising the std::iostream::failure exception in the constructor, or via std::iostream::fail() flag in the input operator.