2019-03-08 09:45:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-10-14 12:07:17 +00:00
|
|
|
#include <algorithm>
|
2019-03-08 09:45:34 +00:00
|
|
|
#include <memory>
|
2022-10-14 12:27:11 +00:00
|
|
|
#include <absl/container/inlined_vector.h>
|
2019-03-08 09:45:34 +00:00
|
|
|
|
2019-03-11 13:22:51 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2019-03-08 09:45:34 +00:00
|
|
|
|
|
|
|
class IAST;
|
|
|
|
using ASTPtr = std::shared_ptr<IAST>;
|
2022-10-13 19:50:11 +00:00
|
|
|
/// sizeof(absl::InlinedVector<ASTPtr, N>) == 8 + N * 16.
|
|
|
|
/// 7 elements take 120 Bytes which is ~128
|
|
|
|
using ASTs = absl::InlinedVector<ASTPtr, 7>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
2022-10-13 21:29:27 +00:00
|
|
|
inline typename DB::ASTs::size_type erase(DB::ASTs & asts, const DB::ASTPtr & element)
|
2022-10-13 19:50:11 +00:00
|
|
|
{
|
|
|
|
auto old_size = asts.size();
|
|
|
|
asts.erase(std::remove(asts.begin(), asts.end(), element), asts.end());
|
|
|
|
return old_size - asts.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Predicate>
|
2022-10-13 21:29:27 +00:00
|
|
|
inline typename DB::ASTs::size_type erase_if(DB::ASTs & asts, Predicate pred)
|
2022-10-13 19:50:11 +00:00
|
|
|
{
|
|
|
|
auto old_size = asts.size();
|
|
|
|
asts.erase(std::remove_if(asts.begin(), asts.end(), pred), asts.end());
|
|
|
|
return old_size - asts.size();
|
|
|
|
}
|
2019-03-08 09:45:34 +00:00
|
|
|
|
2019-06-13 10:37:13 +00:00
|
|
|
}
|