diff --git a/include/silo/common/cons_list.h b/include/silo/common/cons_list.h index 0ccb43a03..14bc31de0 100644 --- a/include/silo/common/cons_list.h +++ b/include/silo/common/cons_list.h @@ -4,6 +4,7 @@ //! (no reference counting). This is meant to be used with recursive //! algorithms to maintain a path back up. +#include #include #include #include @@ -62,7 +63,7 @@ class ConsList { // then set Vec slots via index, but that needs Default and // writes to memory twice, too), right? std::vector values = toVec(); - std::reverse(values.begin(), values.end()); + std::ranges::reverse(values); return values; } }; diff --git a/src/config/config_specification.cpp b/src/config/config_specification.cpp index b4d1817dd..6ea2d582c 100644 --- a/src/config/config_specification.cpp +++ b/src/config/config_specification.cpp @@ -34,14 +34,10 @@ namespace silo::config { std::optional ConfigSpecification:: getAttributeSpecificationFromAmbiguousKey(const AmbiguousConfigKeyPath& key) const { - // TODO(#663) - auto maybe_result = std::find_if( - attribute_specifications.begin(), - attribute_specifications.end(), - [&](const auto& attribute_spec) { + auto maybe_result = + std::ranges::find_if(attribute_specifications, [&](const auto& attribute_spec) { return AmbiguousConfigKeyPath::from(attribute_spec.key) == key; - } - ); + }); if (maybe_result == attribute_specifications.end()) { return std::nullopt; } @@ -51,12 +47,10 @@ std::optional ConfigSpecification:: std::optional ConfigSpecification::getAttributeSpecification( const ConfigKeyPath& key ) const { - // TODO(#663) - auto maybe_result = std::find_if( - attribute_specifications.begin(), - attribute_specifications.end(), - [&](const auto& attribute_spec) { return attribute_spec.key == key; } - ); + auto maybe_result = + std::ranges::find_if(attribute_specifications, [&](const auto& attribute_spec) { + return attribute_spec.key == key; + }); if (maybe_result == attribute_specifications.end()) { return std::nullopt; } diff --git a/src/config/source/environment_variables.cpp b/src/config/source/environment_variables.cpp index bcc1f15ed..3610b63c5 100644 --- a/src/config/source/environment_variables.cpp +++ b/src/config/source/environment_variables.cpp @@ -106,7 +106,7 @@ AmbiguousConfigKeyPath EnvironmentVariables::stringToConfigKeyPath( const ConfigValue value = attribute_spec.parseValueFromString(value_string); config_values.emplace(attribute_spec.key, value); } else { - if (std::find(allow_list.begin(), allow_list.end(), key_string) != allow_list.end()) { + if (std::ranges::find(allow_list, key_string) != allow_list.end()) { SPDLOG_INFO( "Given env variable '{}' is not a valid key for '{}' but in allow_list.", key_string, diff --git a/src/silo/common/lineage_tree.cpp b/src/silo/common/lineage_tree.cpp index 0c5046460..20fba853d 100644 --- a/src/silo/common/lineage_tree.cpp +++ b/src/silo/common/lineage_tree.cpp @@ -102,8 +102,7 @@ std::optional> Graph::getCycle() const { // We need to remove leading vertices up until the cycle SILO_ASSERT_GE(witness_lasso.value().size(), 2UL); const Idx cycle_node = witness_lasso.value().back(); - auto cycle_node_first_occurrence = - std::find(witness_lasso.value().begin(), witness_lasso.value().end(), cycle_node); + auto cycle_node_first_occurrence = std::ranges::find(witness_lasso.value(), cycle_node); SILO_ASSERT(cycle_node_first_occurrence < witness_lasso.value().end()); witness_lasso.value().erase(witness_lasso.value().begin(), cycle_node_first_occurrence); return witness_lasso; diff --git a/src/silo/config/config_repository.cpp b/src/silo/config/config_repository.cpp index ae5b5ff9c..e6f85ea18 100644 --- a/src/silo/config/config_repository.cpp +++ b/src/silo/config/config_repository.cpp @@ -80,12 +80,10 @@ void validatePartitionBy(const DatabaseConfig& config) { const std::string partition_by = config.schema.partition_by.value(); - // TODO(#663) - const auto& partition_by_metadata = std::find_if( - config.schema.metadata.begin(), - config.schema.metadata.end(), - [&](const DatabaseMetadata& metadata) { return metadata.name == partition_by; } - ); + const auto& partition_by_metadata = + std::ranges::find_if(config.schema.metadata, [&](const DatabaseMetadata& metadata) { + return metadata.name == partition_by; + }); if (partition_by_metadata == config.schema.metadata.end()) { throw ConfigException("partitionBy '" + partition_by + "' is not in metadata"); } diff --git a/src/silo/config/database_config.cpp b/src/silo/config/database_config.cpp index 96fb2af34..06026aa1f 100644 --- a/src/silo/config/database_config.cpp +++ b/src/silo/config/database_config.cpp @@ -188,11 +188,9 @@ ColumnType DatabaseMetadata::getColumnType() const { } std::optional DatabaseConfig::getMetadata(const std::string& name) const { - // TODO(#663) - auto element = - std::find_if(schema.metadata.begin(), schema.metadata.end(), [&name](const auto& metadata) { - return metadata.name == name; - }); + auto element = std::ranges::find_if(schema.metadata, [&name](const auto& metadata) { + return metadata.name == name; + }); if (element == std::end(schema.metadata)) { return std::nullopt; } diff --git a/src/silo/preprocessing/metadata_info.cpp b/src/silo/preprocessing/metadata_info.cpp index 3f517035f..b1f4abbc5 100644 --- a/src/silo/preprocessing/metadata_info.cpp +++ b/src/silo/preprocessing/metadata_info.cpp @@ -59,8 +59,7 @@ void MetadataInfo::validateMetadataFile( std::set actual_fields; for (size_t idx = 0; idx < result->ColumnCount(); idx++) { actual_fields.emplace(result->ColumnName(idx)); - // TODO(#663) - if (std::find_if(database_config.schema.metadata.begin(), database_config.schema.metadata.end(), [&](const auto& metadata) { + if (std::ranges::find_if(database_config.schema.metadata, [&](const auto& metadata) { return metadata.name == result->ColumnName(idx); }) == database_config.schema.metadata.end()) { SPDLOG_WARN( @@ -131,8 +130,7 @@ void MetadataInfo::validateNdjsonFile( std::set actual_fields; for (size_t idx = 0; idx < result->ColumnCount(); idx++) { actual_fields.emplace(result->ColumnName(idx)); - // TODO(#663) - if (std::find_if(database_config.schema.metadata.begin(), database_config.schema.metadata.end(), [&](const auto& metadata) { + if (std::ranges::find_if(database_config.schema.metadata, [&](const auto& metadata) { return metadata.name == result->ColumnName(idx); }) == database_config.schema.metadata.end()) { SPDLOG_WARN( diff --git a/src/silo/query_engine/actions/tuple.cpp b/src/silo/query_engine/actions/tuple.cpp index 14d4d781c..8b78842b1 100644 --- a/src/silo/query_engine/actions/tuple.cpp +++ b/src/silo/query_engine/actions/tuple.cpp @@ -316,12 +316,9 @@ std::vector Tuple::getCompareFields( tuple_field_comparators.resize(order_by_fields.size()); size_t offset = 0; for (const auto& metadata : columns_metadata) { - // TODO(#663) - auto element = std::find_if( - order_by_fields.begin(), - order_by_fields.end(), - [&](const auto& order_by_field) { return metadata.name == order_by_field.name; } - ); + auto element = std::ranges::find_if(order_by_fields, [&](const auto& order_by_field) { + return metadata.name == order_by_field.name; + }); if (element != order_by_fields.end()) { const size_t index = std::distance(order_by_fields.begin(), element); tuple_field_comparators[index] =