blob: 53d41d42d6517f7e81afbd5c6bae60abce424bc8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#pragma once
#include <algorithm>
#include <memory>
#include <absl/container/inlined_vector.h>
namespace DB
{
class IAST;
using ASTPtr = std::shared_ptr<IAST>;
/// sizeof(absl::InlinedVector<ASTPtr, N>) == 8 + N * 16.
/// 7 elements take 120 Bytes which is ~128
using ASTs = absl::InlinedVector<ASTPtr, 7>;
}
namespace std
{
inline typename DB::ASTs::size_type erase(DB::ASTs & asts, const DB::ASTPtr & element)
{
auto old_size = asts.size();
asts.erase(std::remove(asts.begin(), asts.end(), element), asts.end());
return old_size - asts.size();
}
template <class Predicate>
inline typename DB::ASTs::size_type erase_if(DB::ASTs & asts, Predicate pred)
{
auto old_size = asts.size();
asts.erase(std::remove_if(asts.begin(), asts.end(), pred), asts.end());
return old_size - asts.size();
}
}
|