ReorderedIndexMap.d.hpp (1860B)
1 #ifndef icu4x_ReorderedIndexMap_D_HPP 2 #define icu4x_ReorderedIndexMap_D_HPP 3 4 #include <stdio.h> 5 #include <stdint.h> 6 #include <stddef.h> 7 #include <stdbool.h> 8 #include <memory> 9 #include <functional> 10 #include <optional> 11 #include <cstdlib> 12 #include "../diplomat_runtime.hpp" 13 14 15 namespace icu4x { 16 namespace capi { 17 struct ReorderedIndexMap; 18 } // namespace capi 19 } // namespace 20 21 namespace icu4x { 22 /** 23 * Thin wrapper around a vector that maps visual indices to source indices 24 * 25 * `map[visualIndex] = sourceIndex` 26 * 27 * Produced by `reorder_visual()` on [`Bidi`]. 28 */ 29 class ReorderedIndexMap { 30 public: 31 32 /** 33 * Get this as a slice/array of indices 34 */ 35 inline diplomat::span<const size_t> as_slice() const; 36 37 /** 38 * The length of this map 39 */ 40 inline size_t len() const; 41 42 /** 43 * Whether this map is empty 44 */ 45 inline bool is_empty() const; 46 47 /** 48 * Get element at `index`. Returns 0 when out of bounds 49 * (note that 0 is also a valid in-bounds value, please use `len()` 50 * to avoid out-of-bounds) 51 */ 52 inline size_t operator[](size_t index) const; 53 54 inline const icu4x::capi::ReorderedIndexMap* AsFFI() const; 55 inline icu4x::capi::ReorderedIndexMap* AsFFI(); 56 inline static const icu4x::ReorderedIndexMap* FromFFI(const icu4x::capi::ReorderedIndexMap* ptr); 57 inline static icu4x::ReorderedIndexMap* FromFFI(icu4x::capi::ReorderedIndexMap* ptr); 58 inline static void operator delete(void* ptr); 59 private: 60 ReorderedIndexMap() = delete; 61 ReorderedIndexMap(const icu4x::ReorderedIndexMap&) = delete; 62 ReorderedIndexMap(icu4x::ReorderedIndexMap&&) noexcept = delete; 63 ReorderedIndexMap operator=(const icu4x::ReorderedIndexMap&) = delete; 64 ReorderedIndexMap operator=(icu4x::ReorderedIndexMap&&) noexcept = delete; 65 static void operator delete[](void*, size_t) = delete; 66 }; 67 68 } // namespace 69 #endif // icu4x_ReorderedIndexMap_D_HPP