14#ifndef SPARSEDOUBLYINDEXED_HPP_
15#define SPARSEDOUBLYINDEXED_HPP_
24 namespace InterpreterClass
28 template<
class ValueClass >
37 operator()( std::pair< int, int >
const& indexPair );
43 operator()( std::pair< int, int >
const& indexPair )
const;
50 int const secondIndex )
51 {
return (*
this)( std::make_pair( firstIndex,
55 int const secondIndex )
const
56 {
return (*
this)( std::make_pair( firstIndex,
59 hasEntry( std::pair< int, int >
const& indexPair )
const;
63 int const secondIndex )
const
64 {
return hasEntry( std::make_pair( firstIndex,
66 virtual std::string
const&
76 std::map< std::pair< int, int >, ValueClass >::const_iterator
79 std::map< std::pair< int, int >, ValueClass >
valueMap;
91 template<
class ValueClass >
103 template<
class ValueClass >
111 template<
class ValueClass >
114 std::pair< int, int >
const& indexPair )
120 if( 0 >= valueMap.count( indexPair ) )
122 valueMap[ indexPair ] = this->defaultUnsetValue;
124 return valueMap[ indexPair ];
127 template<
class ValueClass >
128 inline ValueClass
const&
130 std::pair< int, int >
const& indexPair )
const
136 mapIterator valueFinder( valueMap.find( indexPair ) );
137 if( valueMap.end() != valueFinder )
139 return valueFinder->second;
143 return this->defaultUnsetValue;
147 template<
class ValueClass >
150 std::pair< int, int >
const& indexPair )
const
153 return ( 0 < valueMap.count( indexPair ) );
156 template<
class ValueClass >
157 inline std::string
const&
161 this->stringInterpretation.clear();
163 while( valueFinder != valueMap.end() )
165 this->indexPrintingVector[ 0 ] = valueFinder->first.first;
166 this->indexPrintingVector[ 1 ] = valueFinder->first.second;
167 this->stringInterpretation.append( this->indicesToPrintingString() );
168 this->stringInterpretation.append( this->valueToPrintingString(
169 valueFinder->second ) );
170 this->stringInterpretation.append(
"\n" );
173 return this->stringInterpretation;
176 template<
class ValueClass >
183 template<
class ValueClass >
187 for(
int whichLine( this->currentStringBlock->getNumberOfBodyLines() );
192 (*(this->currentStringBlock))[ whichLine ].first,
193 &(this->lineRemainderA),
195 if( !(this->currentWord.empty()) )
197 valueRecorder.first.first
200 this->lineRemainderA,
201 &(this->lineRemainderB),
203 if( !(this->currentWord.empty()) )
205 valueRecorder.first.second
209 this->lineRemainderB,
211 valueMap.insert( valueRecorder );
static std::string firstWordOf(std::string const &stringToParse, std::string *const remainderString=NULL, std::string const &separatorChars=whitespaceChars)
static std::string const whitespaceAndNewlineChars
static std::string trimFromFrontAndBack(std::string const &stringToTrim, std::string const &charsToTrim=whitespaceAndNewlineChars)
static int stringToInt(std::string const &stringToInterpret)
virtual std::string const & getAsString()
bool hasEntry(int const firstIndex, int const secondIndex) const
bool hasEntry(std::pair< int, int > const &indexPair) const
virtual void interpretCurrentStringBlock()
std::map< std::pair< int, int >, ValueClass > valueMap
std::pair< int, int > mapKey
virtual ~SparseDoublyIndexed()
ValueClass & operator()(int const firstIndex, int const secondIndex)
ValueClass const & operator()(int const firstIndex, int const secondIndex) const
ValueClass & operator()(std::pair< int, int > const &indexPair)
std::map< std::pair< int, int >, ValueClass >::const_iterator mapIterator
virtual void clearEntries()
std::pair< std::pair< int, int >, ValueClass > valueRecorder