Skip to content

Commit 7799304

Browse files
committed
std::vector instead of std::deque
1 parent 9849611 commit 7799304

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

cp-algo/math/fft.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ namespace cp_algo::math::fft {
250250
void mul(auto &&B, auto& res, size_t k) {
251251
mul(B.A, B.B, res, k);
252252
}
253-
std::deque<base> operator *= (auto &&B) {
254-
std::deque<base> res(2 * A.size());
253+
std::vector<base> operator *= (auto &&B) {
254+
std::vector<base> res(2 * A.size());
255255
mul(B.A, B.B, res, size(res));
256256
return res;
257257
}

cp-algo/math/poly.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
#include <optional>
1313
#include <utility>
1414
#include <vector>
15-
#include <deque>
1615
#include <list>
1716
namespace cp_algo::math {
1817
template<typename T>
1918
struct poly_t {
2019
using base = T;
21-
std::deque<T> a;
20+
std::vector<T> a;
2221

2322
void normalize() {poly::impl::normalize(*this);}
2423

2524
poly_t(){}
2625
poly_t(T a0): a{a0} {normalize();}
27-
poly_t(std::vector<T> const& t): a(begin(t), end(t)) {normalize();}
28-
poly_t(std::deque<T> const& t): a(t) {normalize();}
26+
poly_t(std::vector<T> const& t): a(t) {normalize();}
27+
poly_t(std::vector<T>&& t): a(std::move(t)) {normalize();}
2928

3029
poly_t operator -() const {return poly::impl::neg(*this);}
3130
poly_t& operator += (poly_t const& t) {return poly::impl::add(*this, t);}
@@ -576,7 +575,7 @@ namespace cp_algo::math {
576575
}
577576

578577
poly_t x2() { // P(x) -> P(x^2)
579-
std::deque<T> res(2 * a.size());
578+
std::vector<T> res(2 * a.size());
580579
for(size_t i = 0; i < a.size(); i++) {
581580
res[2 * i] = a[i];
582581
}
@@ -586,7 +585,7 @@ namespace cp_algo::math {
586585
// Return {P0, P1}, where P(x) = P0(x) + xP1(x)
587586
std::array<poly_t, 2> bisect(size_t n) const {
588587
n = std::min(n, size(a));
589-
std::deque<T> res[2];
588+
std::vector<T> res[2];
590589
for(size_t i = 0; i < n; i++) {
591590
res[i % 2].push_back(a[i]);
592591
}

0 commit comments

Comments
 (0)