CatapultServer  v0.5.0.1 (Elephant)
Functional.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include <type_traits>
23 
24 namespace catapult { namespace utils {
25 
28  template<typename TContainer, typename TInitial, typename TFunction>
29  auto Reduce(const TContainer& container, TInitial initialValue, TFunction fun) {
30  for (const auto& element : container)
31  initialValue = fun(initialValue, element);
32 
33  return initialValue;
34  }
35 
38  template<typename TContainer, typename TFunction>
39  auto Sum(const TContainer& container, TFunction accessor) {
40  std::invoke_result_t<TFunction, typename TContainer::value_type> sum = 0;
41 
42  for (const auto& element : container)
43  sum += accessor(element);
44 
45  return sum;
46  }
47 }}
forwardsValidation.ForwardsValidator.mode
mode
Definition: forwardsValidation.py:80
forwardsValidation.ForwardsValidator._collectNsName
def _collectNsName(self)
Definition: forwardsValidation.py:183
SimpleValidator.Line
Definition: SimpleValidator.py:1
forwardsValidation.ForwardsValidator._collectOpeningBrace
def _collectOpeningBrace(self)
Definition: forwardsValidation.py:223
forwardsValidation.ForwardsValidator.formatError
def formatError(err)
Definition: forwardsValidation.py:341
forwardsValidation.ForwardsValidator._collectTypeName
def _collectTypeName(self)
Definition: forwardsValidation.py:237
forwardsValidation.ForwardsValidator.__init__
def __init__(self, errorReporter)
Definition: forwardsValidation.py:71
forwardsValidation.ForwardsValidator
Definition: forwardsValidation.py:67
forwardsValidation.ForwardsValidator._getPath
def _getPath(self)
Definition: forwardsValidation.py:169
forwardsValidation.ForwardsValidator.finalize
def finalize(self)
Definition: forwardsValidation.py:323
forwardsValidation.SimpleNsTokenizer.__init__
def __init__(self)
Definition: forwardsValidation.py:18
forwardsValidation.ForwardsValidator._keywordCheck
def _keywordCheck(self)
Definition: forwardsValidation.py:138
forwardsValidation.ForwardsValidator._addForward
def _addForward(self, typeType, typeName)
Definition: forwardsValidation.py:207
forwardsValidation.SimpleNsTokenizer
Definition: forwardsValidation.py:17
SimpleValidator.SimpleValidator
Definition: SimpleValidator.py:9
forwardsValidation.ForwardsValidator.lastName
lastName
Definition: forwardsValidation.py:87
forwardsValidation.ForwardsValidator.reset
def reset(self, path)
Definition: forwardsValidation.py:76
forwardsValidation.ForwardsValidator._collectSemiColon
def _collectSemiColon(self)
Definition: forwardsValidation.py:229
forwardsValidation.ForwardsValidator.hadForwards
hadForwards
Definition: forwardsValidation.py:89
forwardsValidation.ForwardsValidator.lastNamespaceLineNumber
lastNamespaceLineNumber
Definition: forwardsValidation.py:92
forwardsValidation.createDict
def createDict()
Definition: forwardsValidation.py:62
forwardsValidation.ForwardsValidator.previousBlockLineNumber
previousBlockLineNumber
Definition: forwardsValidation.py:94
colorPrint
Definition: colorPrint.py:1
forwardsValidation.NamespaceType
Definition: forwardsValidation.py:57
catapult::utils::Sum
auto Sum(const TContainer &container, TFunction accessor)
Definition: Functional.h:39
forwardsValidation.ForwardsValidator.declarations
declarations
Definition: forwardsValidation.py:85
forwardsValidation.ForwardsValidator._parse
def _parse(self, lineNumber, line)
Definition: forwardsValidation.py:105
SimpleValidator.SimpleValidator.errorReporter
errorReporter
Definition: SimpleValidator.py:11
forwardsValidation.ForwardsValidator.lastLineNumber
lastLineNumber
Definition: forwardsValidation.py:91
forwardsValidation.ForwardsValidator.matchLineNumber
matchLineNumber
Definition: forwardsValidation.py:78
forwardsValidation.ForwardsValidator._collectNamespaceKeyword
def _collectNamespaceKeyword(self)
Definition: forwardsValidation.py:175
forwardsValidation.ForwardsValidator.typeType
typeType
Definition: forwardsValidation.py:86
forwardsValidation.ForwardsValidator.tokenizer
tokenizer
Definition: forwardsValidation.py:82
forwardsValidation.ForwardsValidator.namespaceStack
namespaceStack
Definition: forwardsValidation.py:84
forwardsValidation.ForwardsValidator.tok
tok
Definition: forwardsValidation.py:83
forwardsValidation.ForwardsValidator._skipTillEol
def _skipTillEol(self)
Definition: forwardsValidation.py:264
forwardsValidation.ForwardsValidator.parsingDone
parsingDone
Definition: forwardsValidation.py:79
forwardsValidation.SimpleNsTokenizer.__next__
def __next__(self)
Definition: forwardsValidation.py:41
forwardsValidation.info
def info(*args)
Definition: forwardsValidation.py:12
forwardsValidation.Mode
Definition: forwardsValidation.py:46
forwardsValidation.SimpleNsTokenizer.__iter__
def __iter__(self)
Definition: forwardsValidation.py:27
forwardsValidation.SimpleNsTokenizer.feed
def feed(self, line)
Definition: forwardsValidation.py:23
forwardsValidation.ForwardsValidator.tokPos
tokPos
Definition: forwardsValidation.py:131
catapult::utils::Reduce
auto Reduce(const TContainer &container, TInitial initialValue, TFunction fun)
Definition: Functional.h:29
SimpleValidator.SimpleValidator.path
path
Definition: SimpleValidator.py:22
forwardsValidation.ForwardsValidator.NAME
string NAME
Definition: forwardsValidation.py:69
forwardsValidation.ForwardsValidator.line
line
Definition: forwardsValidation.py:116
forwardsValidation.ForwardsValidator.patternNamespace
patternNamespace
Definition: forwardsValidation.py:73
forwardsValidation.ForwardsValidator._formatFwd
def _formatFwd(className, classSpec)
Definition: forwardsValidation.py:269
forwardsValidation.ForwardsValidator._collectEnum
def _collectEnum(self)
Definition: forwardsValidation.py:241
forwardsValidation.SimpleNsTokenizer.line
line
Definition: forwardsValidation.py:19
forwardsValidation.ForwardsValidator.check
def check(self, lineNumber, line)
Definition: forwardsValidation.py:97
forwardsValidation.SimpleNsTokenizer.lex
lex
Definition: forwardsValidation.py:20
catapult
Definition: AddressExtractionExtension.cpp:28
forwardsValidation.ForwardsValidator.namespaceType
namespaceType
Definition: forwardsValidation.py:81
forwardsValidation.ForwardsValidator.collectedLines
collectedLines
Definition: forwardsValidation.py:95
forwardsValidation.ForwardsValidator.preTypeLines
preTypeLines
Definition: forwardsValidation.py:88
forwardsValidation.ForwardsValidator.lastNamespaceNextLineLength
lastNamespaceNextLineLength
Definition: forwardsValidation.py:93
forwardsValidation.ForwardsValidator.lastForwardLineNumber
lastForwardLineNumber
Definition: forwardsValidation.py:90
forwardsValidation.ForwardsValidator.indentNotEmpty
def indentNotEmpty(line)
Definition: forwardsValidation.py:279
forwardsValidation.ForwardsValidator._format
def _format(declarations, level=1)
Definition: forwardsValidation.py:283
forwardsValidation.SimpleNsTokenizer.find
def find(self)
Definition: forwardsValidation.py:30