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 mozilla_dom_TreeOrderedArray_h
8 #define mozilla_dom_TreeOrderedArray_h
12 namespace mozilla::dom
{
14 // A sorted tree-ordered list of raw pointers to nodes.
15 template <typename Node
>
16 class TreeOrderedArray
{
18 operator const nsTArray
<Node
*>&() const { return mList
; }
20 const nsTArray
<Node
*>* operator->() const { return &mList
; }
22 // Inserts a node into the list, and returns the new index in the array.
24 // All the nodes in the list should be in the same subtree, and debug builds
27 // It's also forbidden to call Insert() with the same node multiple times, and
28 // it will assert as well.
29 inline size_t Insert(Node
&);
31 bool RemoveElement(Node
& aNode
) { return mList
.RemoveElement(&aNode
); }
33 void Clear() { mList
.Clear(); }
36 AutoTArray
<Node
*, 1> mList
;
39 } // namespace mozilla::dom