1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_quota_arraycluster_h__
8 #define mozilla_dom_quota_arraycluster_h__
10 #include "mozilla/dom/quota/QuotaCommon.h"
16 template <class ValueType
, uint32_t Length
= Client::TYPE_MAX
>
22 mArrays
.AppendElements(Length
);
26 ArrayAt(uint32_t aIndex
)
28 MOZ_ASSERT(aIndex
< Length
, "Bad index!");
29 return mArrays
[aIndex
];
33 operator[](uint32_t aIndex
)
35 return ArrayAt(aIndex
);
41 for (uint32_t index
= 0; index
< Length
; index
++) {
42 if (!mArrays
[index
].IsEmpty()) {
51 AppendElementsTo(uint32_t aIndex
, nsTArray
<T
>& aArray
)
53 NS_ASSERTION(aIndex
< Length
, "Bad index!");
54 aArray
.AppendElements(mArrays
[aIndex
]);
59 AppendElementsTo(uint32_t aIndex
, ArrayCluster
<T
, Length
>& aArrayCluster
)
61 NS_ASSERTION(aIndex
< Length
, "Bad index!");
62 aArrayCluster
[aIndex
].AppendElements(mArrays
[aIndex
]);
67 AppendElementsTo(nsTArray
<T
>& aArray
)
69 for (uint32_t index
= 0; index
< Length
; index
++) {
70 aArray
.AppendElements(mArrays
[index
]);
76 AppendElementsTo(ArrayCluster
<T
, Length
>& aArrayCluster
)
78 for (uint32_t index
= 0; index
< Length
; index
++) {
79 aArrayCluster
[index
].AppendElements(mArrays
[index
]);
85 SwapElements(ArrayCluster
<T
, Length
>& aArrayCluster
)
87 for (uint32_t index
= 0; index
< Length
; index
++) {
88 mArrays
[index
].SwapElements(aArrayCluster
.mArrays
[index
]);
95 for (uint32_t index
= 0; index
< Length
; index
++) {
96 mArrays
[index
].Clear();
101 nsAutoTArray
<nsTArray
<ValueType
>, Length
> mArrays
;
106 #endif // mozilla_dom_quota_arraycluster_h__