This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
forked from yayahjb/ncdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapBoundaryStrings2Colors.cpp
executable file
·44 lines (34 loc) · 1.83 KB
/
MapBoundaryStrings2Colors.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <algorithm>
#include <utility>
#include "MapBoundaryStrings2Colors.h"
#include "FollowerConstants.h"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
MapBoundaryStrings2Colors::MapBoundaryStrings2Colors(void)
: m_colorAssignments( )
, m_nextColorIndex( 0 )
, m_numberOfAssignableColors( (size_t)FollowerConstants::globalColorsForBoundaries.size() )
/*-------------------------------------------------------------------------------------*/
{
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
MapBoundaryStrings2Colors::~MapBoundaryStrings2Colors(void){
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
std::string MapBoundaryStrings2Colors::BoundaryIsAlreadyAssignedColor( const std::string& boundary ){
const std::string nextColorString = (*m_colorAssignments.find( boundary )).second;
return( nextColorString );
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
std::string MapBoundaryStrings2Colors::BoundaryNeedsColorAssignment( const std::string& boundary ){
m_nextColorIndex = (m_nextColorIndex+1) % m_numberOfAssignableColors;
const std::string nextColorString = FollowerConstants::globalColorsForBoundaries[m_nextColorIndex];
m_colorAssignments.insert( std::make_pair( boundary, nextColorString ) );
return( nextColorString );
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
std::string MapBoundaryStrings2Colors::operator() (const std::string& boundary ) {
if ( m_colorAssignments.find( boundary ) != m_colorAssignments.end( ) )
return( BoundaryIsAlreadyAssignedColor( boundary ) );
else
return( BoundaryNeedsColorAssignment( boundary ) );
}