14#ifndef SPARSEMANYINDEXED_HPP_
15#define SPARSEMANYINDEXED_HPP_
24 namespace InterpreterClass
28 template<
class ValueClass >
37 operator()( std::vector< int >
const& indexVector );
43 operator()( std::vector< int >
const& indexVector )
const;
49 operator()( std::string
const& indicesAsString );
53 operator()( std::string
const& indicesAsString )
const;
59 hasEntry( std::vector< int >
const& indexVector )
const;
62 hasEntry( std::string
const& indicesAsString )
const;
65 virtual std::string
const&
75 std::map< std::vector< int >, ValueClass >::const_iterator
78 std::map< std::vector< int >, ValueClass >
valueMap;
90 template<
class ValueClass >
101 template<
class ValueClass >
109 template<
class ValueClass >
112 std::vector< int >
const& indexVector )
118 if( 0 >= valueMap.count( indexVector ) )
120 valueMap[ indexVector ] = this->defaultUnsetValue;
122 return valueMap[ indexVector ];
125 template<
class ValueClass >
126 inline ValueClass
const&
128 std::vector< int >
const& indexVector )
const
134 mapIterator valueFinder( valueMap.find( indexVector ) );
135 if( valueMap.end() != valueFinder )
137 return valueFinder->second;
141 return this->defaultUnsetValue;
145 template<
class ValueClass >
148 std::string
const& indicesAsString )
157 template<
class ValueClass >
158 inline ValueClass
const&
160 std::string
const& indicesAsString )
const
170 template<
class ValueClass >
173 std::vector< int >
const& indexVector )
const
176 return ( 0 < valueMap.count( indexVector ) );
179 template<
class ValueClass >
182 std::string
const& indicesAsString )
const
190 template<
class ValueClass >
191 inline std::string
const&
195 this->stringInterpretation.clear();
197 while( valueFinder != valueMap.end() )
199 this->indexPrintingVector = valueFinder->first;
200 this->stringInterpretation.append( this->indicesToPrintingString() );
201 this->stringInterpretation.append( this->valueToPrintingString(
202 valueFinder->second ) );
203 this->stringInterpretation.append(
"\n" );
206 return this->stringInterpretation;
209 template<
class ValueClass >
216 template<
class ValueClass >
220 for(
int whichLine( this->currentStringBlock->getNumberOfBodyLines() );
224 valueRecorder.first.clear();
225 this->lineRemainderB.assign(
226 (*(this->currentStringBlock))[ whichLine ].first );
227 for(
int indexCount( this->indexDigitsVector.size() );
231 this->lineRemainderA.assign( this->lineRemainderB );
233 this->lineRemainderA,
234 &(this->lineRemainderB),
236 if( this->currentWord.empty() )
240 valueRecorder.first.push_back(
245 this->lineRemainderB,
247 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::vector< int > stringToIntVector(std::string stringToInterpret)
static std::string trimFromFrontAndBack(std::string const &stringToTrim, std::string const &charsToTrim=whitespaceAndNewlineChars)
static int stringToInt(std::string const &stringToInterpret)
std::pair< std::vector< int >, ValueClass > valueRecorder
std::map< std::vector< int >, ValueClass >::const_iterator mapIterator
bool hasEntry(std::vector< int > const &indexVector) const
std::vector< int > mapKey
virtual void clearEntries()
virtual std::string const & getAsString()
std::map< std::vector< int >, ValueClass > valueMap
virtual void interpretCurrentStringBlock()
ValueClass & operator()(std::vector< int > const &indexVector)
virtual ~SparseManyIndexed()