Large cleanup
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2019-07-25 17:23:54 +02:00
parent e639a2c170
commit e2a0c35992
58 changed files with 700 additions and 539 deletions

View File

@@ -10,55 +10,63 @@ using namespace std;
namespace Porygon::Evaluation {
class NumericalTableEvalValue : public EvalValue {
const shared_ptr<vector<shared_ptr<EvalValue>>> _table;
const shared_ptr<vector<shared_ptr<const EvalValue>>> _table;
const size_t _hash;
explicit NumericalTableEvalValue(shared_ptr<vector<shared_ptr<EvalValue>>> table, size_t hash)
explicit NumericalTableEvalValue(shared_ptr<vector<shared_ptr<const EvalValue>>> table, size_t hash)
: _table(std::move(table)),
_hash(hash)
{
}
public:
explicit NumericalTableEvalValue(shared_ptr<vector<shared_ptr<EvalValue>>> table) :
explicit NumericalTableEvalValue(shared_ptr<vector<shared_ptr<const EvalValue>>> table) :
_table(std::move(table)),
_hash(rand())
{
}
inline const TypeClass GetTypeClass() const final {
[[nodiscard]]
inline TypeClass GetTypeClass() const final {
return TypeClass::Table;
}
inline const size_t GetHashCode() const final {
[[nodiscard]]
inline size_t GetHashCode() const final {
return _hash;
}
inline const bool operator==(EvalValue *b) const final {
[[nodiscard]]
inline bool operator==(const EvalValue *b) const final {
return this->_hash == b->GetHashCode();
}
inline const shared_ptr<EvalValue> Clone() const final {
[[nodiscard]]
inline shared_ptr<const EvalValue> Clone() const final {
return shared_ptr<EvalValue>(new NumericalTableEvalValue(_table, _hash));
}
inline const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
[[nodiscard]]
inline shared_ptr<const EvalValue> IndexValue(const EvalValue *val) const final {
const auto index = val->EvaluateInteger() - 1;
return this->_table->at(index);
}
inline const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
[[nodiscard]]
inline shared_ptr<const EvalValue> IndexValue(uint32_t hash) const final {
return this->_table->at(hash - 1);
}
inline void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const final {
inline void SetIndexValue(const EvalValue *key, const shared_ptr<const EvalValue> &value) const final {
auto index = key->EvaluateInteger();
this->_table->at(index - 1) = value;
}
[[nodiscard]]
Iterator * GetKeyIterator() const final;
inline const shared_ptr<vector<shared_ptr<EvalValue>>> GetTable() const{
[[nodiscard]]
inline shared_ptr<vector<shared_ptr<const EvalValue>>> GetTable() const{
return _table;
};
};