Backed out changeset f1426851ae30 (bug 1844755) for causing failures on test_printpre...
[gecko.git] / xpcom / base / EnumeratedArrayCycleCollection.h
blob465d4cf38af4bba713cf26b5dfd1e3e13680721a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef EnumeratedArrayCycleCollection_h_
8 #define EnumeratedArrayCycleCollection_h_
10 #include "mozilla/EnumeratedArray.h"
11 #include "nsCycleCollectionTraversalCallback.h"
13 template <typename IndexType, IndexType SizeAsEnumValue, typename ValueType>
14 inline void ImplCycleCollectionUnlink(
15 mozilla::EnumeratedArray<IndexType, SizeAsEnumValue, ValueType>& aField) {
16 for (size_t i = 0; i < size_t(SizeAsEnumValue); ++i) {
17 aField[IndexType(i)] = nullptr;
21 template <typename IndexType, IndexType SizeAsEnumValue, typename ValueType>
22 inline void ImplCycleCollectionTraverse(
23 nsCycleCollectionTraversalCallback& aCallback,
24 mozilla::EnumeratedArray<IndexType, SizeAsEnumValue, ValueType>& aField,
25 const char* aName, uint32_t aFlags = 0) {
26 aFlags |= CycleCollectionEdgeNameArrayFlag;
27 for (size_t i = 0; i < size_t(SizeAsEnumValue); ++i) {
28 ImplCycleCollectionTraverse(aCallback, aField[IndexType(i)], aName, aFlags);
32 #endif // EnumeratedArrayCycleCollection_h_