// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_COLLECTOR_H_ #define V8_COLLECTOR_H_ #include <vector> #include "src/base/vector.h" #include "src/common/checks.h" namespace v8 { namespace internal { /* * A class that collects values into a backing store. * Specialized versions of the class can allow access to the backing store * in different ways. * There is no guarantee that the backing store is contiguous (and, as a * consequence, no guarantees that consecutively added elements are adjacent * in memory). The collector may move elements unless it has guaranteed not * to. */ template <typename T, int growth_factor = 2, int max_growth = 1 * MB> class Collector { … }; /* * A collector that allows sequences of values to be guaranteed to * stay consecutive. * If the backing store grows while a sequence is active, the current * sequence might be moved, but after the sequence is ended, it will * not move again. * NOTICE: Blocks allocated using Collector::AddBlock(int) can move * as well, if inside an active sequence where another element is added. */ template <typename T, int growth_factor = 2, int max_growth = 1 * MB> class SequenceCollector : public Collector<T, growth_factor, max_growth> { … }; } // namespace internal } // namespace v8 #endif // V8_COLLECTOR_H_