! * \brief Copy on write semantics * Do nothing if current handle is the unique copy of the array. * Otherwise make a new copy of the array to ensure the current handle * hold a unique copy. * * \return Handle to the internal node container(which ganrantees to be unique) */
| 659 | * \return Handle to the internal node container(which ganrantees to be unique) |
| 660 | */ |
| 661 | ArrayObj* CopyOnWrite() { |
| 662 | if (data_ == nullptr) { |
| 663 | return SwitchContainer(ArrayObj::kInitSize); |
| 664 | } |
| 665 | if (!data_.unique()) { |
| 666 | return SwitchContainer(capacity()); |
| 667 | } |
| 668 | return static_cast<ArrayObj*>(data_.get()); |
| 669 | } |
| 670 | |
| 671 | /*! \brief specify container node */ |
| 672 | using ContainerType = ArrayObj; |