mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968520 - Add fallible variants of nsTArray::InsertElementSorted. r=froydnj
This commit is contained in:
parent
24c1c3301c
commit
bd16fa84fb
@ -1392,23 +1392,40 @@ public:
|
||||
// Inserts |aItem| at such an index to guarantee that if the array
|
||||
// was previously sorted, it will remain sorted after this
|
||||
// insertion.
|
||||
template<class Item, class Comparator>
|
||||
template<class Item, class Comparator, typename ActualAlloc = Alloc>
|
||||
elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp)
|
||||
{
|
||||
index_type index = IndexOfFirstElementGt<Item, Comparator>(aItem, aComp);
|
||||
return InsertElementAt<Item, Alloc>(
|
||||
return InsertElementAt<Item, ActualAlloc>(
|
||||
index, mozilla::Forward<Item>(aItem));
|
||||
}
|
||||
|
||||
template<class Item, class Comparator>
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp,
|
||||
const mozilla::fallible_t&)
|
||||
{
|
||||
return InsertElementSorted<Item, Comparator, FallibleAlloc>(
|
||||
mozilla::Forward<Item>(aItem), aComp);
|
||||
}
|
||||
|
||||
// A variation on the InsertElementSorted method defined above.
|
||||
template<class Item>
|
||||
template<class Item, typename ActualAlloc = Alloc>
|
||||
elem_type* InsertElementSorted(Item&& aItem)
|
||||
{
|
||||
nsDefaultComparator<elem_type, Item> comp;
|
||||
return InsertElementSorted<Item, decltype(comp)>(
|
||||
return InsertElementSorted<Item, decltype(comp), ActualAlloc>(
|
||||
mozilla::Forward<Item>(aItem), comp);
|
||||
}
|
||||
|
||||
template<class Item>
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* InsertElementSorted(Item&& aItem, const mozilla::fallible_t&)
|
||||
{
|
||||
return InsertElementSorted<Item, FallibleAlloc>(
|
||||
mozilla::Forward<Item>(aItem));
|
||||
}
|
||||
|
||||
// This method appends elements to the end of this array.
|
||||
// @param aArray The elements to append to this array.
|
||||
// @param aArrayLen The number of elements to append to this array.
|
||||
|
Loading…
Reference in New Issue
Block a user