Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/core/draco_index_type_vector.h
- This file was moved from extern/draco/dracoenc/src/draco/core/draco_index_type_vector.h.
| Show All 22 Lines | |||||
| namespace draco { | namespace draco { | ||||
| // A wrapper around the standard std::vector that supports indexing of the | // A wrapper around the standard std::vector that supports indexing of the | ||||
| // vector entries using the strongly typed indices as defined in | // vector entries using the strongly typed indices as defined in | ||||
| // draco_index_type.h . | // draco_index_type.h . | ||||
| // TODO(ostava): Make the interface more complete. It's currently missing | // TODO(ostava): Make the interface more complete. It's currently missing | ||||
| // features such as iterators. | // features such as iterators. | ||||
| // TODO(draco-eng): Make unit tests for this class. | // TODO(vytyaz): Add more unit tests for this class. | ||||
| template <class IndexTypeT, class ValueTypeT> | template <class IndexTypeT, class ValueTypeT> | ||||
| class IndexTypeVector { | class IndexTypeVector { | ||||
| public: | public: | ||||
| typedef typename std::vector<ValueTypeT>::const_reference const_reference; | typedef typename std::vector<ValueTypeT>::const_reference const_reference; | ||||
| typedef typename std::vector<ValueTypeT>::reference reference; | typedef typename std::vector<ValueTypeT>::reference reference; | ||||
| IndexTypeVector() {} | IndexTypeVector() {} | ||||
| explicit IndexTypeVector(size_t size) : vector_(size) {} | explicit IndexTypeVector(size_t size) : vector_(size) {} | ||||
| IndexTypeVector(size_t size, const ValueTypeT &val) : vector_(size, val) {} | IndexTypeVector(size_t size, const ValueTypeT &val) : vector_(size, val) {} | ||||
| void clear() { vector_.clear(); } | void clear() { vector_.clear(); } | ||||
| void reserve(size_t size) { vector_.reserve(size); } | void reserve(size_t size) { vector_.reserve(size); } | ||||
| void resize(size_t size) { vector_.resize(size); } | void resize(size_t size) { vector_.resize(size); } | ||||
| void resize(size_t size, const ValueTypeT &val) { vector_.resize(size, val); } | void resize(size_t size, const ValueTypeT &val) { vector_.resize(size, val); } | ||||
| void assign(size_t size, const ValueTypeT &val) { vector_.assign(size, val); } | void assign(size_t size, const ValueTypeT &val) { vector_.assign(size, val); } | ||||
| void swap(IndexTypeVector<IndexTypeT, ValueTypeT> &arg) { | void swap(IndexTypeVector<IndexTypeT, ValueTypeT> &arg) { | ||||
| vector_.swap(arg.vector_); | vector_.swap(arg.vector_); | ||||
| } | } | ||||
| size_t size() const { return vector_.size(); } | size_t size() const { return vector_.size(); } | ||||
| bool empty() const { return vector_.empty(); } | |||||
| void push_back(const ValueTypeT &val) { vector_.push_back(val); } | void push_back(const ValueTypeT &val) { vector_.push_back(val); } | ||||
| void push_back(ValueTypeT &&val) { vector_.push_back(std::move(val)); } | void push_back(ValueTypeT &&val) { vector_.push_back(std::move(val)); } | ||||
| template <typename... Args> | |||||
| void emplace_back(Args &&... args) { | |||||
| vector_.emplace_back(std::forward<Args>(args)...); | |||||
| } | |||||
| inline reference operator[](const IndexTypeT &index) { | inline reference operator[](const IndexTypeT &index) { | ||||
| return vector_[index.value()]; | return vector_[index.value()]; | ||||
| } | } | ||||
| inline const_reference operator[](const IndexTypeT &index) const { | inline const_reference operator[](const IndexTypeT &index) const { | ||||
| return vector_[index.value()]; | return vector_[index.value()]; | ||||
| } | } | ||||
| inline reference at(const IndexTypeT &index) { | inline reference at(const IndexTypeT &index) { | ||||
| return vector_[index.value()]; | return vector_[index.value()]; | ||||
| Show All 13 Lines | |||||