class_packedbytearray.rst 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/PackedByteArray.xml.
  6. .. _class_PackedByteArray:
  7. PackedByteArray
  8. ===============
  9. A packed array of bytes.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. An array specifically designed to hold bytes. Packs data tightly, so it saves memory for large array sizes.
  14. \ **PackedByteArray** also provides methods to encode/decode various types to/from bytes. The way values are encoded is an implementation detail and shouldn't be relied upon when interacting with external apps.
  15. .. rst-class:: classref-reftable-group
  16. Constructors
  17. ------------
  18. .. table::
  19. :widths: auto
  20. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>` **(** **)** |
  22. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)** |
  24. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>` **(** :ref:`Array<class_Array>` from **)** |
  26. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  27. .. rst-class:: classref-reftable-group
  28. Methods
  29. -------
  30. .. table::
  31. :widths: auto
  32. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`append<class_PackedByteArray_method_append>` **(** :ref:`int<class_int>` value **)** |
  34. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`append_array<class_PackedByteArray_method_append_array>` **(** :ref:`PackedByteArray<class_PackedByteArray>` array **)** |
  36. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`bsearch<class_PackedByteArray_method_bsearch>` **(** :ref:`int<class_int>` value, :ref:`bool<class_bool>` before=true **)** |
  38. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`clear<class_PackedByteArray_method_clear>` **(** **)** |
  40. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`compress<class_PackedByteArray_method_compress>` **(** :ref:`int<class_int>` compression_mode=0 **)** |const| |
  42. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`count<class_PackedByteArray_method_count>` **(** :ref:`int<class_int>` value **)** |const| |
  44. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`float<class_float>` | :ref:`decode_double<class_PackedByteArray_method_decode_double>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  46. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`float<class_float>` | :ref:`decode_float<class_PackedByteArray_method_decode_float>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  48. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`decode_half<class_PackedByteArray_method_decode_half>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  50. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`decode_s16<class_PackedByteArray_method_decode_s16>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  52. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`decode_s32<class_PackedByteArray_method_decode_s32>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  54. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`decode_s64<class_PackedByteArray_method_decode_s64>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  56. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`decode_s8<class_PackedByteArray_method_decode_s8>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  58. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`decode_u16<class_PackedByteArray_method_decode_u16>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  60. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`decode_u32<class_PackedByteArray_method_decode_u32>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  62. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`decode_u64<class_PackedByteArray_method_decode_u64>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  64. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`decode_u8<class_PackedByteArray_method_decode_u8>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  66. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Variant<class_Variant>` | :ref:`decode_var<class_PackedByteArray_method_decode_var>` **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  68. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`int<class_int>` | :ref:`decode_var_size<class_PackedByteArray_method_decode_var_size>` **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  70. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress<class_PackedByteArray_method_decompress>` **(** :ref:`int<class_int>` buffer_size, :ref:`int<class_int>` compression_mode=0 **)** |const| |
  72. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress_dynamic<class_PackedByteArray_method_decompress_dynamic>` **(** :ref:`int<class_int>` max_output_size, :ref:`int<class_int>` compression_mode=0 **)** |const| |
  74. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`duplicate<class_PackedByteArray_method_duplicate>` **(** **)** |
  76. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`encode_double<class_PackedByteArray_method_encode_double>` **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)** |
  78. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`encode_float<class_PackedByteArray_method_encode_float>` **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)** |
  80. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`encode_half<class_PackedByteArray_method_encode_half>` **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)** |
  82. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`encode_s16<class_PackedByteArray_method_encode_s16>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  84. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`encode_s32<class_PackedByteArray_method_encode_s32>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  86. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`encode_s64<class_PackedByteArray_method_encode_s64>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  88. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`encode_s8<class_PackedByteArray_method_encode_s8>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  90. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`encode_u16<class_PackedByteArray_method_encode_u16>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  92. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`encode_u32<class_PackedByteArray_method_encode_u32>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  94. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`encode_u64<class_PackedByteArray_method_encode_u64>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  96. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`encode_u8<class_PackedByteArray_method_encode_u8>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  98. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`int<class_int>` | :ref:`encode_var<class_PackedByteArray_method_encode_var>` **(** :ref:`int<class_int>` byte_offset, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` allow_objects=false **)** |
  100. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`fill<class_PackedByteArray_method_fill>` **(** :ref:`int<class_int>` value **)** |
  102. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`int<class_int>` | :ref:`find<class_PackedByteArray_method_find>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |const| |
  104. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`String<class_String>` | :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>` **(** **)** |const| |
  106. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`String<class_String>` | :ref:`get_string_from_utf16<class_PackedByteArray_method_get_string_from_utf16>` **(** **)** |const| |
  108. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`String<class_String>` | :ref:`get_string_from_utf32<class_PackedByteArray_method_get_string_from_utf32>` **(** **)** |const| |
  110. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`String<class_String>` | :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>` **(** **)** |const| |
  112. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`bool<class_bool>` | :ref:`has<class_PackedByteArray_method_has>` **(** :ref:`int<class_int>` value **)** |const| |
  114. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`bool<class_bool>` | :ref:`has_encoded_var<class_PackedByteArray_method_has_encoded_var>` **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  116. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`String<class_String>` | :ref:`hex_encode<class_PackedByteArray_method_hex_encode>` **(** **)** |const| |
  118. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`int<class_int>` | :ref:`insert<class_PackedByteArray_method_insert>` **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)** |
  120. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`bool<class_bool>` | :ref:`is_empty<class_PackedByteArray_method_is_empty>` **(** **)** |const| |
  122. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`bool<class_bool>` | :ref:`push_back<class_PackedByteArray_method_push_back>` **(** :ref:`int<class_int>` value **)** |
  124. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`remove_at<class_PackedByteArray_method_remove_at>` **(** :ref:`int<class_int>` index **)** |
  126. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`int<class_int>` | :ref:`resize<class_PackedByteArray_method_resize>` **(** :ref:`int<class_int>` new_size **)** |
  128. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`reverse<class_PackedByteArray_method_reverse>` **(** **)** |
  130. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`int<class_int>` | :ref:`rfind<class_PackedByteArray_method_rfind>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const| |
  132. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | void | :ref:`set<class_PackedByteArray_method_set>` **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)** |
  134. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`int<class_int>` | :ref:`size<class_PackedByteArray_method_size>` **(** **)** |const| |
  136. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`slice<class_PackedByteArray_method_slice>` **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const| |
  138. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | void | :ref:`sort<class_PackedByteArray_method_sort>` **(** **)** |
  140. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`to_float32_array<class_PackedByteArray_method_to_float32_array>` **(** **)** |const| |
  142. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`PackedFloat64Array<class_PackedFloat64Array>` | :ref:`to_float64_array<class_PackedByteArray_method_to_float64_array>` **(** **)** |const| |
  144. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`to_int32_array<class_PackedByteArray_method_to_int32_array>` **(** **)** |const| |
  146. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`PackedInt64Array<class_PackedInt64Array>` | :ref:`to_int64_array<class_PackedByteArray_method_to_int64_array>` **(** **)** |const| |
  148. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. .. rst-class:: classref-reftable-group
  150. Operators
  151. ---------
  152. .. table::
  153. :widths: auto
  154. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  155. | :ref:`bool<class_bool>` | :ref:`operator !=<class_PackedByteArray_operator_neq_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  156. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  157. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`operator +<class_PackedByteArray_operator_sum_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  158. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  159. | :ref:`bool<class_bool>` | :ref:`operator ==<class_PackedByteArray_operator_eq_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  160. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  161. | :ref:`int<class_int>` | :ref:`operator []<class_PackedByteArray_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
  162. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  163. .. rst-class:: classref-section-separator
  164. ----
  165. .. rst-class:: classref-descriptions-group
  166. Constructor Descriptions
  167. ------------------------
  168. .. _class_PackedByteArray_constructor_PackedByteArray:
  169. .. rst-class:: classref-constructor
  170. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** **)**
  171. Constructs an empty **PackedByteArray**.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. rst-class:: classref-constructor
  175. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)**
  176. Constructs a **PackedByteArray** as a copy of the given **PackedByteArray**.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. rst-class:: classref-constructor
  180. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** :ref:`Array<class_Array>` from **)**
  181. Constructs a new **PackedByteArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  182. .. rst-class:: classref-section-separator
  183. ----
  184. .. rst-class:: classref-descriptions-group
  185. Method Descriptions
  186. -------------------
  187. .. _class_PackedByteArray_method_append:
  188. .. rst-class:: classref-method
  189. :ref:`bool<class_bool>` **append** **(** :ref:`int<class_int>` value **)**
  190. Appends an element at the end of the array (alias of :ref:`push_back<class_PackedByteArray_method_push_back>`).
  191. .. rst-class:: classref-item-separator
  192. ----
  193. .. _class_PackedByteArray_method_append_array:
  194. .. rst-class:: classref-method
  195. void **append_array** **(** :ref:`PackedByteArray<class_PackedByteArray>` array **)**
  196. Appends a **PackedByteArray** at the end of this array.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_PackedByteArray_method_bsearch:
  200. .. rst-class:: classref-method
  201. :ref:`int<class_int>` **bsearch** **(** :ref:`int<class_int>` value, :ref:`bool<class_bool>` before=true **)**
  202. Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a ``before`` specifier can be passed. If ``false``, the returned index comes after all existing entries of the value in the array.
  203. \ **Note:** Calling :ref:`bsearch<class_PackedByteArray_method_bsearch>` on an unsorted array results in unexpected behavior.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_PackedByteArray_method_clear:
  207. .. rst-class:: classref-method
  208. void **clear** **(** **)**
  209. Clears the array. This is equivalent to using :ref:`resize<class_PackedByteArray_method_resize>` with a size of ``0``.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_PackedByteArray_method_compress:
  213. .. rst-class:: classref-method
  214. :ref:`PackedByteArray<class_PackedByteArray>` **compress** **(** :ref:`int<class_int>` compression_mode=0 **)** |const|
  215. Returns a new **PackedByteArray** with the data compressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_PackedByteArray_method_count:
  219. .. rst-class:: classref-method
  220. :ref:`int<class_int>` **count** **(** :ref:`int<class_int>` value **)** |const|
  221. Returns the number of times an element is in the array.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_PackedByteArray_method_decode_double:
  225. .. rst-class:: classref-method
  226. :ref:`float<class_float>` **decode_double** **(** :ref:`int<class_int>` byte_offset **)** |const|
  227. Decodes a 64-bit floating point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_PackedByteArray_method_decode_float:
  231. .. rst-class:: classref-method
  232. :ref:`float<class_float>` **decode_float** **(** :ref:`int<class_int>` byte_offset **)** |const|
  233. Decodes a 32-bit floating point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_PackedByteArray_method_decode_half:
  237. .. rst-class:: classref-method
  238. :ref:`float<class_float>` **decode_half** **(** :ref:`int<class_int>` byte_offset **)** |const|
  239. Decodes a 16-bit floating point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_PackedByteArray_method_decode_s16:
  243. .. rst-class:: classref-method
  244. :ref:`int<class_int>` **decode_s16** **(** :ref:`int<class_int>` byte_offset **)** |const|
  245. Decodes a 16-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_PackedByteArray_method_decode_s32:
  249. .. rst-class:: classref-method
  250. :ref:`int<class_int>` **decode_s32** **(** :ref:`int<class_int>` byte_offset **)** |const|
  251. Decodes a 32-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  252. .. rst-class:: classref-item-separator
  253. ----
  254. .. _class_PackedByteArray_method_decode_s64:
  255. .. rst-class:: classref-method
  256. :ref:`int<class_int>` **decode_s64** **(** :ref:`int<class_int>` byte_offset **)** |const|
  257. Decodes a 64-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _class_PackedByteArray_method_decode_s8:
  261. .. rst-class:: classref-method
  262. :ref:`int<class_int>` **decode_s8** **(** :ref:`int<class_int>` byte_offset **)** |const|
  263. Decodes a 8-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_PackedByteArray_method_decode_u16:
  267. .. rst-class:: classref-method
  268. :ref:`int<class_int>` **decode_u16** **(** :ref:`int<class_int>` byte_offset **)** |const|
  269. Decodes a 16-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_PackedByteArray_method_decode_u32:
  273. .. rst-class:: classref-method
  274. :ref:`int<class_int>` **decode_u32** **(** :ref:`int<class_int>` byte_offset **)** |const|
  275. Decodes a 32-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_PackedByteArray_method_decode_u64:
  279. .. rst-class:: classref-method
  280. :ref:`int<class_int>` **decode_u64** **(** :ref:`int<class_int>` byte_offset **)** |const|
  281. Decodes a 64-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_PackedByteArray_method_decode_u8:
  285. .. rst-class:: classref-method
  286. :ref:`int<class_int>` **decode_u8** **(** :ref:`int<class_int>` byte_offset **)** |const|
  287. Decodes a 8-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_PackedByteArray_method_decode_var:
  291. .. rst-class:: classref-method
  292. :ref:`Variant<class_Variant>` **decode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  293. Decodes a :ref:`Variant<class_Variant>` from the bytes starting at ``byte_offset``. Returns ``null`` if a valid variant can't be decoded or the value is :ref:`Object<class_Object>`-derived and ``allow_objects`` is ``false``.
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_PackedByteArray_method_decode_var_size:
  297. .. rst-class:: classref-method
  298. :ref:`int<class_int>` **decode_var_size** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  299. Decodes a size of a :ref:`Variant<class_Variant>` from the bytes starting at ``byte_offset``. Requires at least 4 bytes of data starting at the offset, otherwise fails.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_PackedByteArray_method_decompress:
  303. .. rst-class:: classref-method
  304. :ref:`PackedByteArray<class_PackedByteArray>` **decompress** **(** :ref:`int<class_int>` buffer_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  305. Returns a new **PackedByteArray** with the data decompressed. Set ``buffer_size`` to the size of the uncompressed data. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_PackedByteArray_method_decompress_dynamic:
  309. .. rst-class:: classref-method
  310. :ref:`PackedByteArray<class_PackedByteArray>` **decompress_dynamic** **(** :ref:`int<class_int>` max_output_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  311. Returns a new **PackedByteArray** with the data decompressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants. **This method only accepts gzip and deflate compression modes.**\
  312. This method is potentially slower than ``decompress``, as it may have to re-allocate its output buffer multiple times while decompressing, whereas ``decompress`` knows it's output buffer size from the beginning.
  313. GZIP has a maximal compression ratio of 1032:1, meaning it's very possible for a small compressed payload to decompress to a potentially very large output. To guard against this, you may provide a maximum size this function is allowed to allocate in bytes via ``max_output_size``. Passing -1 will allow for unbounded output. If any positive value is passed, and the decompression exceeds that amount in bytes, then an error will be returned.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_PackedByteArray_method_duplicate:
  317. .. rst-class:: classref-method
  318. :ref:`PackedByteArray<class_PackedByteArray>` **duplicate** **(** **)**
  319. Creates a copy of the array, and returns it.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_PackedByteArray_method_encode_double:
  323. .. rst-class:: classref-method
  324. void **encode_double** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  325. Encodes a 64-bit floating point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of allocated space, starting at the offset.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_PackedByteArray_method_encode_float:
  329. .. rst-class:: classref-method
  330. void **encode_float** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  331. Encodes a 32-bit floating point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_PackedByteArray_method_encode_half:
  335. .. rst-class:: classref-method
  336. void **encode_half** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  337. Encodes a 16-bit floating point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_PackedByteArray_method_encode_s16:
  341. .. rst-class:: classref-method
  342. void **encode_s16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  343. Encodes a 16-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_PackedByteArray_method_encode_s32:
  347. .. rst-class:: classref-method
  348. void **encode_s32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  349. Encodes a 32-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_PackedByteArray_method_encode_s64:
  353. .. rst-class:: classref-method
  354. void **encode_s64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  355. Encodes a 64-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of space, starting at the offset.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_PackedByteArray_method_encode_s8:
  359. .. rst-class:: classref-method
  360. void **encode_s8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  361. Encodes a 8-bit signed integer number (signed byte) at the index of ``byte_offset`` bytes. The array must have at least 1 byte of space, starting at the offset.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_PackedByteArray_method_encode_u16:
  365. .. rst-class:: classref-method
  366. void **encode_u16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  367. Encodes a 16-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  368. .. rst-class:: classref-item-separator
  369. ----
  370. .. _class_PackedByteArray_method_encode_u32:
  371. .. rst-class:: classref-method
  372. void **encode_u32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  373. Encodes a 32-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_PackedByteArray_method_encode_u64:
  377. .. rst-class:: classref-method
  378. void **encode_u64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  379. Encodes a 64-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of space, starting at the offset.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_PackedByteArray_method_encode_u8:
  383. .. rst-class:: classref-method
  384. void **encode_u8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  385. Encodes a 8-bit unsigned integer number (byte) at the index of ``byte_offset`` bytes. The array must have at least 1 byte of space, starting at the offset.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_PackedByteArray_method_encode_var:
  389. .. rst-class:: classref-method
  390. :ref:`int<class_int>` **encode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` allow_objects=false **)**
  391. Encodes a :ref:`Variant<class_Variant>` at the index of ``byte_offset`` bytes. A sufficient space must be allocated, depending on the encoded variant's size. If ``allow_objects`` is ``false``, :ref:`Object<class_Object>`-derived values are not permitted and will instead be serialized as ID-only.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _class_PackedByteArray_method_fill:
  395. .. rst-class:: classref-method
  396. void **fill** **(** :ref:`int<class_int>` value **)**
  397. Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize<class_PackedByteArray_method_resize>` to create an array with a given size and initialized elements.
  398. .. rst-class:: classref-item-separator
  399. ----
  400. .. _class_PackedByteArray_method_find:
  401. .. rst-class:: classref-method
  402. :ref:`int<class_int>` **find** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |const|
  403. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
  404. .. rst-class:: classref-item-separator
  405. ----
  406. .. _class_PackedByteArray_method_get_string_from_ascii:
  407. .. rst-class:: classref-method
  408. :ref:`String<class_String>` **get_string_from_ascii** **(** **)** |const|
  409. Converts ASCII/Latin-1 encoded array to :ref:`String<class_String>`. Fast alternative to :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>` if the content is ASCII/Latin-1 only. Unlike the UTF-8 function this function maps every byte to a character in the array. Multibyte sequences will not be interpreted correctly. For parsing user input always use :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>`.
  410. .. rst-class:: classref-item-separator
  411. ----
  412. .. _class_PackedByteArray_method_get_string_from_utf16:
  413. .. rst-class:: classref-method
  414. :ref:`String<class_String>` **get_string_from_utf16** **(** **)** |const|
  415. Converts UTF-16 encoded array to :ref:`String<class_String>`. If the BOM is missing, system endianness is assumed. Returns empty string if source array is not valid UTF-16 string.
  416. .. rst-class:: classref-item-separator
  417. ----
  418. .. _class_PackedByteArray_method_get_string_from_utf32:
  419. .. rst-class:: classref-method
  420. :ref:`String<class_String>` **get_string_from_utf32** **(** **)** |const|
  421. Converts UTF-32 encoded array to :ref:`String<class_String>`. System endianness is assumed. Returns empty string if source array is not valid UTF-32 string.
  422. .. rst-class:: classref-item-separator
  423. ----
  424. .. _class_PackedByteArray_method_get_string_from_utf8:
  425. .. rst-class:: classref-method
  426. :ref:`String<class_String>` **get_string_from_utf8** **(** **)** |const|
  427. Converts UTF-8 encoded array to :ref:`String<class_String>`. Slower than :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>` but supports UTF-8 encoded data. Use this function if you are unsure about the source of the data. For user input this function should always be preferred. Returns empty string if source array is not valid UTF-8 string.
  428. .. rst-class:: classref-item-separator
  429. ----
  430. .. _class_PackedByteArray_method_has:
  431. .. rst-class:: classref-method
  432. :ref:`bool<class_bool>` **has** **(** :ref:`int<class_int>` value **)** |const|
  433. Returns ``true`` if the array contains ``value``.
  434. .. rst-class:: classref-item-separator
  435. ----
  436. .. _class_PackedByteArray_method_has_encoded_var:
  437. .. rst-class:: classref-method
  438. :ref:`bool<class_bool>` **has_encoded_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  439. Returns ``true`` if a valid :ref:`Variant<class_Variant>` value can be decoded at the ``byte_offset``. Returns ``false`` othewrise or when the value is :ref:`Object<class_Object>`-derived and ``allow_objects`` is ``false``.
  440. .. rst-class:: classref-item-separator
  441. ----
  442. .. _class_PackedByteArray_method_hex_encode:
  443. .. rst-class:: classref-method
  444. :ref:`String<class_String>` **hex_encode** **(** **)** |const|
  445. Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
  446. .. tabs::
  447. .. code-tab:: gdscript
  448. var array = PackedByteArray([11, 46, 255])
  449. print(array.hex_encode()) # Prints: 0b2eff
  450. .. code-tab:: csharp
  451. var array = new byte[] {11, 46, 255};
  452. GD.Print(array.HexEncode()); // Prints: 0b2eff
  453. .. rst-class:: classref-item-separator
  454. ----
  455. .. _class_PackedByteArray_method_insert:
  456. .. rst-class:: classref-method
  457. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)**
  458. Inserts a new element at a given position in the array. The position must be valid, or at the end of the array (``idx == size()``).
  459. .. rst-class:: classref-item-separator
  460. ----
  461. .. _class_PackedByteArray_method_is_empty:
  462. .. rst-class:: classref-method
  463. :ref:`bool<class_bool>` **is_empty** **(** **)** |const|
  464. Returns ``true`` if the array is empty.
  465. .. rst-class:: classref-item-separator
  466. ----
  467. .. _class_PackedByteArray_method_push_back:
  468. .. rst-class:: classref-method
  469. :ref:`bool<class_bool>` **push_back** **(** :ref:`int<class_int>` value **)**
  470. Appends an element at the end of the array.
  471. .. rst-class:: classref-item-separator
  472. ----
  473. .. _class_PackedByteArray_method_remove_at:
  474. .. rst-class:: classref-method
  475. void **remove_at** **(** :ref:`int<class_int>` index **)**
  476. Removes an element from the array by index.
  477. .. rst-class:: classref-item-separator
  478. ----
  479. .. _class_PackedByteArray_method_resize:
  480. .. rst-class:: classref-method
  481. :ref:`int<class_int>` **resize** **(** :ref:`int<class_int>` new_size **)**
  482. Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
  483. .. rst-class:: classref-item-separator
  484. ----
  485. .. _class_PackedByteArray_method_reverse:
  486. .. rst-class:: classref-method
  487. void **reverse** **(** **)**
  488. Reverses the order of the elements in the array.
  489. .. rst-class:: classref-item-separator
  490. ----
  491. .. _class_PackedByteArray_method_rfind:
  492. .. rst-class:: classref-method
  493. :ref:`int<class_int>` **rfind** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const|
  494. Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array.
  495. .. rst-class:: classref-item-separator
  496. ----
  497. .. _class_PackedByteArray_method_set:
  498. .. rst-class:: classref-method
  499. void **set** **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)**
  500. Changes the byte at the given index.
  501. .. rst-class:: classref-item-separator
  502. ----
  503. .. _class_PackedByteArray_method_size:
  504. .. rst-class:: classref-method
  505. :ref:`int<class_int>` **size** **(** **)** |const|
  506. Returns the number of elements in the array.
  507. .. rst-class:: classref-item-separator
  508. ----
  509. .. _class_PackedByteArray_method_slice:
  510. .. rst-class:: classref-method
  511. :ref:`PackedByteArray<class_PackedByteArray>` **slice** **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const|
  512. Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
  513. The absolute value of ``begin`` and ``end`` will be clamped to the array size, so the default value for ``end`` makes it slice to the size of the array by default (i.e. ``arr.slice(1)`` is a shorthand for ``arr.slice(1, arr.size())``).
  514. If either ``begin`` or ``end`` are negative, they will be relative to the end of the array (i.e. ``arr.slice(0, -2)`` is a shorthand for ``arr.slice(0, arr.size() - 2)``).
  515. .. rst-class:: classref-item-separator
  516. ----
  517. .. _class_PackedByteArray_method_sort:
  518. .. rst-class:: classref-method
  519. void **sort** **(** **)**
  520. Sorts the elements of the array in ascending order.
  521. .. rst-class:: classref-item-separator
  522. ----
  523. .. _class_PackedByteArray_method_to_float32_array:
  524. .. rst-class:: classref-method
  525. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array** **(** **)** |const|
  526. Returns a copy of the data converted to a :ref:`PackedFloat32Array<class_PackedFloat32Array>`, where each block of 4 bytes has been converted to a 32-bit float (C++ ``float``).
  527. The size of the input array must be a multiple of 4 (size of 32-bit float). The size of the new array will be ``byte_array.size() / 4``.
  528. If the original data can't be converted to 32-bit floats, the resulting data is undefined.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_PackedByteArray_method_to_float64_array:
  532. .. rst-class:: classref-method
  533. :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array** **(** **)** |const|
  534. Returns a copy of the data converted to a :ref:`PackedFloat64Array<class_PackedFloat64Array>`, where each block of 8 bytes has been converted to a 64-bit float (C++ ``double``, Godot :ref:`float<class_float>`).
  535. The size of the input array must be a multiple of 8 (size of 64-bit double). The size of the new array will be ``byte_array.size() / 8``.
  536. If the original data can't be converted to 64-bit floats, the resulting data is undefined.
  537. .. rst-class:: classref-item-separator
  538. ----
  539. .. _class_PackedByteArray_method_to_int32_array:
  540. .. rst-class:: classref-method
  541. :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array** **(** **)** |const|
  542. Returns a copy of the data converted to a :ref:`PackedInt32Array<class_PackedInt32Array>`, where each block of 4 bytes has been converted to a signed 32-bit integer (C++ ``int32_t``).
  543. The size of the input array must be a multiple of 4 (size of 32-bit integer). The size of the new array will be ``byte_array.size() / 4``.
  544. If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_PackedByteArray_method_to_int64_array:
  548. .. rst-class:: classref-method
  549. :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array** **(** **)** |const|
  550. Returns a copy of the data converted to a :ref:`PackedInt64Array<class_PackedInt64Array>`, where each block of 8 bytes has been converted to a signed 64-bit integer (C++ ``int64_t``, Godot :ref:`int<class_int>`).
  551. The size of the input array must be a multiple of 8 (size of 64-bit integer). The size of the new array will be ``byte_array.size() / 8``.
  552. If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
  553. .. rst-class:: classref-section-separator
  554. ----
  555. .. rst-class:: classref-descriptions-group
  556. Operator Descriptions
  557. ---------------------
  558. .. _class_PackedByteArray_operator_neq_PackedByteArray:
  559. .. rst-class:: classref-operator
  560. :ref:`bool<class_bool>` **operator !=** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  561. Returns ``true`` if contents of the arrays differ.
  562. .. rst-class:: classref-item-separator
  563. ----
  564. .. _class_PackedByteArray_operator_sum_PackedByteArray:
  565. .. rst-class:: classref-operator
  566. :ref:`PackedByteArray<class_PackedByteArray>` **operator +** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  567. Returns a new **PackedByteArray** with contents of ``right`` added at the end of this array. For better performance, consider using :ref:`append_array<class_PackedByteArray_method_append_array>` instead.
  568. .. rst-class:: classref-item-separator
  569. ----
  570. .. _class_PackedByteArray_operator_eq_PackedByteArray:
  571. .. rst-class:: classref-operator
  572. :ref:`bool<class_bool>` **operator ==** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  573. Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
  574. .. rst-class:: classref-item-separator
  575. ----
  576. .. _class_PackedByteArray_operator_idx_int:
  577. .. rst-class:: classref-operator
  578. :ref:`int<class_int>` **operator []** **(** :ref:`int<class_int>` index **)**
  579. Returns the byte at index ``index``. Negative indices can be used to access the elements starting from the end. Using index out of array's bounds will result in an error.
  580. Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
  581. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  582. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  583. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  584. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  585. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  586. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`