53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#ifndef COLLECTION_HPP
|
|
#define COLLECTION_HPP
|
|
|
|
#include "matador/object/collection_proxy.hpp"
|
|
|
|
namespace matador::object {
|
|
|
|
template < class Type >
|
|
class collection {
|
|
public:
|
|
using value_type = Type;
|
|
using iterator = typename std::vector<value_type>::iterator;
|
|
using const_iterator = typename std::vector<value_type>::const_iterator;
|
|
|
|
void push_back(const value_type& value) {
|
|
proxy_->items().push_back(value);
|
|
}
|
|
|
|
iterator begin() {
|
|
return proxy_->items().begin();
|
|
}
|
|
|
|
iterator end() {
|
|
return proxy_->items().end();
|
|
}
|
|
|
|
const_iterator begin() const {
|
|
return proxy_->items().begin();
|
|
}
|
|
|
|
const_iterator end() const {
|
|
return proxy_->items().end();
|
|
}
|
|
|
|
[[nodiscard]] size_t size() const {
|
|
return proxy_->items().size();
|
|
}
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
return proxy_->items_.empty();
|
|
}
|
|
|
|
void reset(std::shared_ptr<collection_proxy<typename Type::value_type>> proxy) {
|
|
proxy_ = std::move(proxy);
|
|
}
|
|
|
|
private:
|
|
std::shared_ptr<collection_proxy<typename Type::value_type>> proxy_;
|
|
};
|
|
|
|
}
|
|
#endif //COLLECTION_HPP
|