Rosetta  2020.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
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]

Public Types

typedef
utility::pointer::ReferenceCount 
parent
 
- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 

Public Member Functions

 subset_mapping ()
 
 subset_mapping (platform::Size source_enumeration_size)
 
 subset_mapping (subset_mapping const &src)
 
subset_mappingoperator= (subset_mapping const &rhs)
 
 ~subset_mapping () override
 
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. More...
 
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. More...
 
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. More...
 
platform::Size source_size () const
 The number of elements in the source enumeration. More...
 
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() More...
 
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. More...
 
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. More...
 
bool source_id_is_mapped (platform::Size source_id) const
 
- Public Member Functions inherited from utility::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
virtual ~ReferenceCount ()
 

Static Public Attributes

static platform::Size const UNMAPPED = 0
 

Private Attributes

utility::vector1< platform::Sizesrc_2_dst_
 
utility::vector1< platform::Sizedst_2_src_
 

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 ( )
default
utility::subset_mapping::subset_mapping ( platform::Size  source_enumeration_size)
utility::subset_mapping::subset_mapping ( subset_mapping const &  src)
utility::subset_mapping::~subset_mapping ( )
overridedefault

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.

References dst_2_src_.

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()

References dst_2_src_.

subset_mapping & utility::subset_mapping::operator= ( subset_mapping const &  rhs)

References dst_2_src_, and src_2_dst_.

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.

References dst_2_src_.

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.

References src_2_dst_.

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 CREATE_EXCEPTION, dst_2_src_, src_2_dst_, 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 src_2_dst_, and UNMAPPED.

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

References src_2_dst_, and UNMAPPED.

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

The number of elements in the source enumeration.

References src_2_dst_.

Member Data Documentation

utility::vector1< platform::Size > utility::subset_mapping::dst_2_src_
private
utility::vector1< platform::Size > utility::subset_mapping::src_2_dst_
private
platform::Size const utility::subset_mapping::UNMAPPED = 0
static

The documentation for this class was generated from the following files: