Rosetta 3.3
Public Types | Public Member Functions | Static Public Attributes
utility::subset_mapping Class Reference

This class handles the bookeeping to map between a set of integer ids in the "source" enumeration to a subset of those ids -- the destination enumartion. Elements in the source enumeration that do not map to elements in the destination enumeration are represented by the value 0. Both enumerations should count from 1. Once the class has been initialized, this class offers O(1) mapping between elements in the enumerations. More...

#include <integer_mapping.hh>

Inheritance diagram for utility::subset_mapping:
Inheritance graph
[legend]
Collaboration diagram for utility::subset_mapping:
Collaboration graph
[legend]

List of all members.

Public Types

typedef
utility::pointer::ReferenceCount 
parent

Public Member Functions

 subset_mapping ()
 subset_mapping (platform::Size source_enumeration_size)
 subset_mapping (subset_mapping const &src)
subset_mapping const & operator= (subset_mapping const &rhs)
virtual ~subset_mapping ()
void set_source_size (platform::Size)
 Required before the first call to set_next_correspondence may be called. The size of the source enumeration must be known before the mapping may begin.
void reserve_destination_size (platform::Size)
 If you know the size of the destination enumeration, then you can save some under-the-hood vector resizing operations by informing the subset_mapping its size up front. This call must proceed the first call to set_next_correspondence.
void set_next_correspondence (platform::Size source_id)
 Inform the mapping of the next source-enumeration id that should be mapped to a destination-enumeration id. This will increase the size of the destination enumeration by one. It is not essential that the source-enumeration ids appear in sorted order, however, by construction, the destination ids will be in sorted order.
platform::Size source_size () const
 The number of elements in the source enumeration.
platform::Size destination_size () const
 The number of elements in the destination enumeration -- this represents the number of calls that have been made to set_next_correspondence()
platform::Size s2d (platform::Size source_id) const
 Map from the id of an element in source enumeration to an id in the the destination enumeration, which may in fact be UNMAPPED.
platform::Size d2s (platform::Size destination_id) const
 Map from the id of an element in the destination enumeration to an id in the source enumeration. This is guaranteed to return a non-zero value.
bool source_id_is_mapped (platform::Size source_id) const

Static Public Attributes

static platform::Size const UNMAPPED = 0

Detailed Description

This class handles the bookeeping to map between a set of integer ids in the "source" enumeration to a subset of those ids -- the destination enumartion. Elements in the source enumeration that do not map to elements in the destination enumeration are represented by the value 0. Both enumerations should count from 1. Once the class has been initialized, this class offers O(1) mapping between elements in the enumerations.


Member Typedef Documentation


Constructor & Destructor Documentation

utility::subset_mapping::subset_mapping ( )
utility::subset_mapping::subset_mapping ( platform::Size  source_enumeration_size)
utility::subset_mapping::subset_mapping ( subset_mapping const &  src)
utility::subset_mapping::~subset_mapping ( ) [virtual]

Member Function Documentation

platform::Size utility::subset_mapping::d2s ( platform::Size  destination_id) const

Map from the id of an element in the destination enumeration to an id in the source enumeration. This is guaranteed to return a non-zero value.

platform::Size utility::subset_mapping::destination_size ( ) const

The number of elements in the destination enumeration -- this represents the number of calls that have been made to set_next_correspondence()

subset_mapping const & utility::subset_mapping::operator= ( subset_mapping const &  rhs)
void utility::subset_mapping::reserve_destination_size ( platform::Size  dst_size)

If you know the size of the destination enumeration, then you can save some under-the-hood vector resizing operations by informing the subset_mapping its size up front. This call must proceed the first call to set_next_correspondence.

platform::Size utility::subset_mapping::s2d ( platform::Size  source_id) const

Map from the id of an element in source enumeration to an id in the the destination enumeration, which may in fact be UNMAPPED.

void utility::subset_mapping::set_next_correspondence ( platform::Size  source_id)

Inform the mapping of the next source-enumeration id that should be mapped to a destination-enumeration id. This will increase the size of the destination enumeration by one. It is not essential that the source-enumeration ids appear in sorted order, however, by construction, the destination ids will be in sorted order.

Prevent out-of-bounds assignment and the overwriting of previously mapped ids. Throws excn::EXCN_Msg_Exceptions

References utility::to_string(), and UNMAPPED.

void utility::subset_mapping::set_source_size ( platform::Size  src_size)

Required before the first call to set_next_correspondence may be called. The size of the source enumeration must be known before the mapping may begin.

References UNMAPPED.

bool utility::subset_mapping::source_id_is_mapped ( platform::Size  source_id) const

References UNMAPPED.

platform::Size utility::subset_mapping::source_size ( ) const

The number of elements in the source enumeration.


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines