This documentation is automatically generated by competitive-verifier/competitive-verifier
#include "cp-algo/structures/stack_union.hpp"
#ifndef CP_ALGO_STRUCTURES_STACK_UNION_HPP
#define CP_ALGO_STRUCTURES_STACK_UNION_HPP
#include <cstddef>
#include <vector>
namespace cp_algo::structures {
template<class datatype>
struct stack_union {
stack_union(int n = 0): head(n), next(1), data(1) {}
void push(int v, datatype const& vdata) {
next.push_back(head[v]);
head[v] = (int)std::size(next) - 1;
data.push_back(vdata);
}
template<typename... Args>
void emplace(int v, Args&&... vdata) {
next.push_back(head[v]);
head[v] = size(next) - 1;
data.emplace_back(std::forward<Args...>(vdata...));
}
void reserve(int m) {
data.reserve(m);
next.reserve(m);
}
size_t size() const {return std::size(head);}
size_t nodes() const {return std::size(data);}
std::vector<int> head, next;
std::vector<datatype> data;
};
}
#endif // CP_ALGO_STRUCTURES_STACK_UNION_HPP
#line 1 "cp-algo/structures/stack_union.hpp"
#include <cstddef>
#include <vector>
namespace cp_algo::structures {
template<class datatype>
struct stack_union {
stack_union(int n = 0): head(n), next(1), data(1) {}
void push(int v, datatype const& vdata) {
next.push_back(head[v]);
head[v] = (int)std::size(next) - 1;
data.push_back(vdata);
}
template<typename... Args>
void emplace(int v, Args&&... vdata) {
next.push_back(head[v]);
head[v] = size(next) - 1;
data.emplace_back(std::forward<Args...>(vdata...));
}
void reserve(int m) {
data.reserve(m);
next.reserve(m);
}
size_t size() const {return std::size(head);}
size_t nodes() const {return std::size(data);}
std::vector<int> head, next;
std::vector<datatype> data;
};
}