// Copyright (c) 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef SOURCE_UTIL_SMALL_VECTOR_H_ #define SOURCE_UTIL_SMALL_VECTOR_H_ #include <array> #include <cassert> #include <cstddef> #include <iostream> #include <memory> #include <utility> #include <vector> #include "source/util/make_unique.h" namespace spvtools { namespace utils { // The |SmallVector| class is intended to be a drop-in replacement for // |std::vector|. The difference is in the implementation. A |SmallVector| is // optimized for when the number of elements in the vector are small. Small is // defined by the template parameter |small_size|. // // Note that |SmallVector| is not always faster than an |std::vector|, so you // should experiment with different values for |small_size| and compare to // using and |std::vector|. // // TODO: I have implemented the public member functions from |std::vector| that // I needed. If others are needed they should be implemented. Do not implement // public member functions that are not defined by std::vector. template <class T, size_t small_size> class SmallVector { … }; // namespace utils } // namespace utils } // namespace spvtools #endif // SOURCE_UTIL_SMALL_VECTOR_H_