| 293 | |
| 294 | //! A smart-pointer to a ref-counted immutable sequence of TSharedRef-s. |
| 295 | class TSharedRefArray |
| 296 | { |
| 297 | public: |
| 298 | TSharedRefArray() = default; |
| 299 | TSharedRefArray(const TSharedRefArray& other); |
| 300 | TSharedRefArray(TSharedRefArray&& other) noexcept; |
| 301 | |
| 302 | explicit TSharedRefArray(const TSharedRef& part); |
| 303 | explicit TSharedRefArray(TSharedRef&& part); |
| 304 | |
| 305 | struct TCopyParts |
| 306 | { }; |
| 307 | struct TMoveParts |
| 308 | { }; |
| 309 | |
| 310 | template <class TParts> |
| 311 | TSharedRefArray(const TParts& parts, TCopyParts); |
| 312 | template <class TParts> |
| 313 | TSharedRefArray(TParts&& parts, TMoveParts); |
| 314 | |
| 315 | TSharedRefArray& operator = (const TSharedRefArray& other); |
| 316 | TSharedRefArray& operator = (TSharedRefArray&& other); |
| 317 | |
| 318 | explicit operator bool() const; |
| 319 | |
| 320 | void Reset(); |
| 321 | |
| 322 | size_t Size() const; |
| 323 | size_t size() const; |
| 324 | i64 ByteSize() const; |
| 325 | bool Empty() const; |
| 326 | const TSharedRef& operator [] (size_t index) const; |
| 327 | |
| 328 | const TSharedRef* Begin() const; |
| 329 | const TSharedRef* End() const; |
| 330 | |
| 331 | std::vector<TSharedRef> ToVector() const; |
| 332 | TString ToString() const; |
| 333 | |
| 334 | //! Creates a copy of a given TSharedRefArray. |
| 335 | //! The memory is marked with a given tag. |
| 336 | static TSharedRefArray MakeCopy(const TSharedRefArray& array, TRefCountedTypeCookie tagCookie); |
| 337 | |
| 338 | //! Checks if #lhs and #rhs consist of the same number of bitwise-equal parts. |
| 339 | static bool AreBitwiseEqual(const TSharedRefArray& lhs, const TSharedRefArray& rhs); |
| 340 | |
| 341 | private: |
| 342 | friend class TSharedRefArrayBuilder; |
| 343 | |
| 344 | TSharedRefArrayImplPtr Impl_; |
| 345 | |
| 346 | explicit TSharedRefArray(TSharedRefArrayImplPtr impl); |
| 347 | |
| 348 | template <class... As> |
| 349 | static TSharedRefArrayImplPtr NewImpl( |
| 350 | size_t size, |
| 351 | size_t poolCapacity, |
| 352 | TRefCountedTypeCookie cookie, |