Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
Link Mode

A Link Mode defines the relationship between a node and the links that bear the node.

It provides all necessary informations in order to get from the node to the link, and to access the key and value information contained in the link.

The important concept to understand is that the link is the type that aggregates the key, the value and the node. A tree is composed of a series of nodes all tied to their key and values through the link type.

There are multiple types of link in the library. Sometimes, the link derives from the node and the key and values are attributes. Other times, the value type is the link itself, and it contains the node as an attribute. This diversity explains why, in the tree algorithm, only the node is being used, and the key, the value or the link are only retreived on demand.

The models of LinkMode shall publicly provide the following interface:

Signature/TypedefDescription
Legend T A model of Link Mode
Require typename T::link_type; The link type which should be defined as Link.
Require typename T::key_type; The key type in the link.
Require typename T::value_type; The value type in the link.
Require typename T::link_ptr A pointer to a mutable value of T::link_type.
Require typename T::const_link_ptr A pointer to a contant value of T::link_type.
Require typename T::node_ptr An alias to the type of Node<T>::ptr.
Require typename T::const_node_ptr An alias to the type of Node<T>::const_ptr.
Require T::key_type& key(Node<T>&); A function to return a T::key_type reference from a node must exists.
Require const T::key_type& const key(const Node<T>&); A function to return a const T::key_type reference from a constant node must exists.
Require T::value_type& value(Node<T>&); A function to return a T::value_type reference from a node must exists.
Require const T::value_type& value(const Node<T>&); A function to return a const T::value_type reference from a constant node must exists.
Require T::link_type& link(Node<T>&); A function to return a T::link_type from a node must exists.
Require const T::link_type& link(const Node<T>&); A function to return a const T::link_type from a constant node must exists.
Require void swap(Node<T>&, Node<T>&); A function to swap two instances of T::link_type must exists.

This level of abstraction allows the same algorithms to be used for regular and intrusive containers, without loss of performance and without the use of an otherwise cumbersome syntax.