Bug 1910362 - Create new Nimbus helper r=aaronmt,ohorvath
[gecko.git] / xpcom / base / EnumeratedArrayCycleCollection.h
blob863b990de7c0c8c965435cd6261610648198af03
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, typename ValueType, size_t Size>
14 inline void ImplCycleCollectionUnlink(
15 mozilla::EnumeratedArray<IndexType, ValueType, Size>& aField) {
16 for (size_t i = 0; i < Size; ++i) {
17 aField[IndexType(i)] = nullptr;
21 template <typename IndexType, typename ValueType, size_t Size>
22 inline void ImplCycleCollectionTraverse(
23 nsCycleCollectionTraversalCallback& aCallback,
24 mozilla::EnumeratedArray<IndexType, ValueType, Size>& aField,
25 const char* aName, uint32_t aFlags = 0) {
26 aFlags |= CycleCollectionEdgeNameArrayFlag;
27 for (size_t i = 0; i < Size; ++i) {
28 ImplCycleCollectionTraverse(aCallback, aField[IndexType(i)], aName, aFlags);
32 #endif // EnumeratedArrayCycleCollection_h_