58 rows.push_back(std::move(row));
61 void remove(TimeStamp from, TimeStamp to)
63 rows.erase(std::remove_if(rows.begin(), rows.end(),
66 return r.timestamp >= from && r.timestamp <= to;
71 std::vector<const Row*> range(TimeStamp from, TimeStamp to)
const
73 std::vector<const Row*> result;
75 for (
const auto& r : rows)
77 if (r.timestamp >= from && r.timestamp <= to)
84 template<
typename Predicate>
85 std::vector<const Row*> query(Predicate pred)
const
87 std::vector<const Row*> result;
89 for (
const auto& r : rows)
100 std::vector<Row> rows;
103 template<TimeRow Row>
106 TypeId
id = type_id<Row>;
108 if (tables.contains(
id))
111 tables[id] = std::make_unique<Table<Row>>();
114 template<TimeRow Row>
117 table<Row>().insert(std::move(row));
120 template<TimeRow Row>
121 void remove(TimeStamp from, TimeStamp to)
123 table<Row>().remove(from, to);
126 template<TimeRow Row>
127 std::vector<const Row*> range(TimeStamp from, TimeStamp to)
129 return table<Row>().range(from, to);
132 template<TimeRow Row,
typename Predicate>
133 std::vector<const Row*> query(Predicate pred)
135 return table<Row>().query(pred);
140 template<TimeRow Row>
143 TypeId
id = type_id<Row>;
145 auto it = tables.find(
id);
147 if (it == tables.end())
149 auto tbl = std::make_unique<Table<Row>>();
150 auto* ptr = tbl.get();
152 tables[id] = std::move(tbl);
157 return *
static_cast<Table<Row>*
>(it->second.get());
162 std::unordered_map<TypeId, std::unique_ptr<ITable>> tables;