#ifndef MARISA_CONTAINER_H_ #define MARISA_CONTAINER_H_ #include #include "base.h" namespace marisa { template class Container; template class Container *> { public: Container(std::vector *vec) : vec_(vec) {} Container(const Container &container) : vec_(container.vec_) {} void insert(std::size_t, const T &value) const { vec_->push_back(value); } bool is_valid() const { return vec_ != NULL; } private: std::vector *vec_; // Disallows assignment. Container &operator=(const Container &query); }; template class Container { public: explicit Container(T *ptr) : ptr_(ptr) {} Container(const Container &container) : ptr_(container.ptr_) {} void insert(std::size_t i, const T &value) { ptr_[i] = value; } bool is_valid() const { return ptr_ != NULL; } private: T *ptr_; // Disallows assignment. Container &operator=(const Container &); }; template inline Container MakeContainer(T *ptr) { return Container(ptr); } } // namespace marisa #endif // MARISA_CONTAINER_H_