mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +09:00
Add a ClearElementAt API to nsTArray
This commit is contained in:
parent
a3f38ee838
commit
c4115c8ad5
1 changed files with 18 additions and 0 deletions
|
|
@ -1503,6 +1503,24 @@ public:
|
|||
mozilla::Forward<Item>(aItem));
|
||||
}
|
||||
|
||||
// Reconstruct the element at the given index, and return a pointer to the
|
||||
// reconstructed element. This will destroy the existing element and
|
||||
// default-construct a new one, giving you a state much like what single-arg
|
||||
// InsertElementAt(), or no-arg AppendElement() does, but without changing the
|
||||
// length of the array.
|
||||
//
|
||||
// array[idx] = T()
|
||||
//
|
||||
// would accomplish the same thing as long as T has the appropriate moving
|
||||
// operator=, but some types don't for various reasons.
|
||||
elem_type* ReconstructElementAt(index_type aIndex)
|
||||
{
|
||||
elem_type* elem = &ElementAt(aIndex);
|
||||
elem_traits::Destruct(elem);
|
||||
elem_traits::Construct(elem);
|
||||
return elem;
|
||||
}
|
||||
|
||||
// This method searches for the smallest index of an element that is strictly
|
||||
// greater than |aItem|. If |aItem| is inserted at this index, the array will
|
||||
// remain sorted and |aItem| would come after all elements that are equal to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue