class_packedbytearray.rst 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  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.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/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_s8<class_PackedByteArray_method_decode_s8>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  52. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`decode_s16<class_PackedByteArray_method_decode_s16>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  54. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`decode_s32<class_PackedByteArray_method_decode_s32>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  56. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`decode_s64<class_PackedByteArray_method_decode_s64>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  58. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`decode_u8<class_PackedByteArray_method_decode_u8>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  60. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`decode_u16<class_PackedByteArray_method_decode_u16>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  62. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`decode_u32<class_PackedByteArray_method_decode_u32>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  64. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`decode_u64<class_PackedByteArray_method_decode_u64>` **(** :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_s8<class_PackedByteArray_method_encode_s8>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  84. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`encode_s16<class_PackedByteArray_method_encode_s16>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  86. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`encode_s32<class_PackedByteArray_method_encode_s32>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  88. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`encode_s64<class_PackedByteArray_method_encode_s64>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  90. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`encode_u8<class_PackedByteArray_method_encode_u8>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  92. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`encode_u16<class_PackedByteArray_method_encode_u16>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  94. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`encode_u32<class_PackedByteArray_method_encode_u32>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  96. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`encode_u64<class_PackedByteArray_method_encode_u64>` **(** :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_utf8<class_PackedByteArray_method_get_string_from_utf8>` **(** **)** |const| |
  108. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`String<class_String>` | :ref:`get_string_from_utf16<class_PackedByteArray_method_get_string_from_utf16>` **(** **)** |const| |
  110. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`String<class_String>` | :ref:`get_string_from_utf32<class_PackedByteArray_method_get_string_from_utf32>` **(** **)** |const| |
  112. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`String<class_String>` | :ref:`get_string_from_wchar<class_PackedByteArray_method_get_string_from_wchar>` **(** **)** |const| |
  114. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`bool<class_bool>` | :ref:`has<class_PackedByteArray_method_has>` **(** :ref:`int<class_int>` value **)** |const| |
  116. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :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| |
  118. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`String<class_String>` | :ref:`hex_encode<class_PackedByteArray_method_hex_encode>` **(** **)** |const| |
  120. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`int<class_int>` | :ref:`insert<class_PackedByteArray_method_insert>` **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)** |
  122. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`bool<class_bool>` | :ref:`is_empty<class_PackedByteArray_method_is_empty>` **(** **)** |const| |
  124. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`bool<class_bool>` | :ref:`push_back<class_PackedByteArray_method_push_back>` **(** :ref:`int<class_int>` value **)** |
  126. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`remove_at<class_PackedByteArray_method_remove_at>` **(** :ref:`int<class_int>` index **)** |
  128. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`int<class_int>` | :ref:`resize<class_PackedByteArray_method_resize>` **(** :ref:`int<class_int>` new_size **)** |
  130. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | void | :ref:`reverse<class_PackedByteArray_method_reverse>` **(** **)** |
  132. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`int<class_int>` | :ref:`rfind<class_PackedByteArray_method_rfind>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const| |
  134. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | void | :ref:`set<class_PackedByteArray_method_set>` **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)** |
  136. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`int<class_int>` | :ref:`size<class_PackedByteArray_method_size>` **(** **)** |const| |
  138. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`slice<class_PackedByteArray_method_slice>` **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const| |
  140. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | void | :ref:`sort<class_PackedByteArray_method_sort>` **(** **)** |
  142. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`to_float32_array<class_PackedByteArray_method_to_float32_array>` **(** **)** |const| |
  144. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`PackedFloat64Array<class_PackedFloat64Array>` | :ref:`to_float64_array<class_PackedByteArray_method_to_float64_array>` **(** **)** |const| |
  146. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`to_int32_array<class_PackedByteArray_method_to_int32_array>` **(** **)** |const| |
  148. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`PackedInt64Array<class_PackedInt64Array>` | :ref:`to_int64_array<class_PackedByteArray_method_to_int64_array>` **(** **)** |const| |
  150. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. .. rst-class:: classref-reftable-group
  152. Operators
  153. ---------
  154. .. table::
  155. :widths: auto
  156. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  157. | :ref:`bool<class_bool>` | :ref:`operator !=<class_PackedByteArray_operator_neq_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  158. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  159. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`operator +<class_PackedByteArray_operator_sum_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  160. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  161. | :ref:`bool<class_bool>` | :ref:`operator ==<class_PackedByteArray_operator_eq_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  162. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  163. | :ref:`int<class_int>` | :ref:`operator []<class_PackedByteArray_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
  164. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  165. .. rst-class:: classref-section-separator
  166. ----
  167. .. rst-class:: classref-descriptions-group
  168. Constructor Descriptions
  169. ------------------------
  170. .. _class_PackedByteArray_constructor_PackedByteArray:
  171. .. rst-class:: classref-constructor
  172. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** **)**
  173. Constructs an empty **PackedByteArray**.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. rst-class:: classref-constructor
  177. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)**
  178. Constructs a **PackedByteArray** as a copy of the given **PackedByteArray**.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. rst-class:: classref-constructor
  182. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** :ref:`Array<class_Array>` from **)**
  183. Constructs a new **PackedByteArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  184. .. rst-class:: classref-section-separator
  185. ----
  186. .. rst-class:: classref-descriptions-group
  187. Method Descriptions
  188. -------------------
  189. .. _class_PackedByteArray_method_append:
  190. .. rst-class:: classref-method
  191. :ref:`bool<class_bool>` **append** **(** :ref:`int<class_int>` value **)**
  192. Appends an element at the end of the array (alias of :ref:`push_back<class_PackedByteArray_method_push_back>`).
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_PackedByteArray_method_append_array:
  196. .. rst-class:: classref-method
  197. void **append_array** **(** :ref:`PackedByteArray<class_PackedByteArray>` array **)**
  198. Appends a **PackedByteArray** at the end of this array.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_PackedByteArray_method_bsearch:
  202. .. rst-class:: classref-method
  203. :ref:`int<class_int>` **bsearch** **(** :ref:`int<class_int>` value, :ref:`bool<class_bool>` before=true **)**
  204. 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.
  205. \ **Note:** Calling :ref:`bsearch<class_PackedByteArray_method_bsearch>` on an unsorted array results in unexpected behavior.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_PackedByteArray_method_clear:
  209. .. rst-class:: classref-method
  210. void **clear** **(** **)**
  211. Clears the array. This is equivalent to using :ref:`resize<class_PackedByteArray_method_resize>` with a size of ``0``.
  212. .. rst-class:: classref-item-separator
  213. ----
  214. .. _class_PackedByteArray_method_compress:
  215. .. rst-class:: classref-method
  216. :ref:`PackedByteArray<class_PackedByteArray>` **compress** **(** :ref:`int<class_int>` compression_mode=0 **)** |const|
  217. Returns a new **PackedByteArray** with the data compressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  218. .. rst-class:: classref-item-separator
  219. ----
  220. .. _class_PackedByteArray_method_count:
  221. .. rst-class:: classref-method
  222. :ref:`int<class_int>` **count** **(** :ref:`int<class_int>` value **)** |const|
  223. Returns the number of times an element is in the array.
  224. .. rst-class:: classref-item-separator
  225. ----
  226. .. _class_PackedByteArray_method_decode_double:
  227. .. rst-class:: classref-method
  228. :ref:`float<class_float>` **decode_double** **(** :ref:`int<class_int>` byte_offset **)** |const|
  229. 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.
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_PackedByteArray_method_decode_float:
  233. .. rst-class:: classref-method
  234. :ref:`float<class_float>` **decode_float** **(** :ref:`int<class_int>` byte_offset **)** |const|
  235. 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.
  236. .. rst-class:: classref-item-separator
  237. ----
  238. .. _class_PackedByteArray_method_decode_half:
  239. .. rst-class:: classref-method
  240. :ref:`float<class_float>` **decode_half** **(** :ref:`int<class_int>` byte_offset **)** |const|
  241. 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.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_PackedByteArray_method_decode_s8:
  245. .. rst-class:: classref-method
  246. :ref:`int<class_int>` **decode_s8** **(** :ref:`int<class_int>` byte_offset **)** |const|
  247. 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.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_PackedByteArray_method_decode_s16:
  251. .. rst-class:: classref-method
  252. :ref:`int<class_int>` **decode_s16** **(** :ref:`int<class_int>` byte_offset **)** |const|
  253. 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.
  254. .. rst-class:: classref-item-separator
  255. ----
  256. .. _class_PackedByteArray_method_decode_s32:
  257. .. rst-class:: classref-method
  258. :ref:`int<class_int>` **decode_s32** **(** :ref:`int<class_int>` byte_offset **)** |const|
  259. 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.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_PackedByteArray_method_decode_s64:
  263. .. rst-class:: classref-method
  264. :ref:`int<class_int>` **decode_s64** **(** :ref:`int<class_int>` byte_offset **)** |const|
  265. 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.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_PackedByteArray_method_decode_u8:
  269. .. rst-class:: classref-method
  270. :ref:`int<class_int>` **decode_u8** **(** :ref:`int<class_int>` byte_offset **)** |const|
  271. 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.
  272. .. rst-class:: classref-item-separator
  273. ----
  274. .. _class_PackedByteArray_method_decode_u16:
  275. .. rst-class:: classref-method
  276. :ref:`int<class_int>` **decode_u16** **(** :ref:`int<class_int>` byte_offset **)** |const|
  277. 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.
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_PackedByteArray_method_decode_u32:
  281. .. rst-class:: classref-method
  282. :ref:`int<class_int>` **decode_u32** **(** :ref:`int<class_int>` byte_offset **)** |const|
  283. 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.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_PackedByteArray_method_decode_u64:
  287. .. rst-class:: classref-method
  288. :ref:`int<class_int>` **decode_u64** **(** :ref:`int<class_int>` byte_offset **)** |const|
  289. 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.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_PackedByteArray_method_decode_var:
  293. .. rst-class:: classref-method
  294. :ref:`Variant<class_Variant>` **decode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  295. 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``.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_PackedByteArray_method_decode_var_size:
  299. .. rst-class:: classref-method
  300. :ref:`int<class_int>` **decode_var_size** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  301. 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.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_PackedByteArray_method_decompress:
  305. .. rst-class:: classref-method
  306. :ref:`PackedByteArray<class_PackedByteArray>` **decompress** **(** :ref:`int<class_int>` buffer_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  307. 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.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_PackedByteArray_method_decompress_dynamic:
  311. .. rst-class:: classref-method
  312. :ref:`PackedByteArray<class_PackedByteArray>` **decompress_dynamic** **(** :ref:`int<class_int>` max_output_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  313. 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 brotli, gzip, and deflate compression modes.**\
  314. 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.
  315. 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.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_PackedByteArray_method_duplicate:
  319. .. rst-class:: classref-method
  320. :ref:`PackedByteArray<class_PackedByteArray>` **duplicate** **(** **)**
  321. Creates a copy of the array, and returns it.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_PackedByteArray_method_encode_double:
  325. .. rst-class:: classref-method
  326. void **encode_double** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  327. 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.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_PackedByteArray_method_encode_float:
  331. .. rst-class:: classref-method
  332. void **encode_float** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  333. 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.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_PackedByteArray_method_encode_half:
  337. .. rst-class:: classref-method
  338. void **encode_half** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  339. 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.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_PackedByteArray_method_encode_s8:
  343. .. rst-class:: classref-method
  344. void **encode_s8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  345. 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.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_PackedByteArray_method_encode_s16:
  349. .. rst-class:: classref-method
  350. void **encode_s16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  351. 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.
  352. .. rst-class:: classref-item-separator
  353. ----
  354. .. _class_PackedByteArray_method_encode_s32:
  355. .. rst-class:: classref-method
  356. void **encode_s32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  357. 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.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_PackedByteArray_method_encode_s64:
  361. .. rst-class:: classref-method
  362. void **encode_s64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  363. 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.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_PackedByteArray_method_encode_u8:
  367. .. rst-class:: classref-method
  368. void **encode_u8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  369. 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.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_PackedByteArray_method_encode_u16:
  373. .. rst-class:: classref-method
  374. void **encode_u16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  375. 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.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_PackedByteArray_method_encode_u32:
  379. .. rst-class:: classref-method
  380. void **encode_u32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  381. 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.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_PackedByteArray_method_encode_u64:
  385. .. rst-class:: classref-method
  386. void **encode_u64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  387. 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.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_PackedByteArray_method_encode_var:
  391. .. rst-class:: classref-method
  392. :ref:`int<class_int>` **encode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` allow_objects=false **)**
  393. 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.
  394. .. rst-class:: classref-item-separator
  395. ----
  396. .. _class_PackedByteArray_method_fill:
  397. .. rst-class:: classref-method
  398. void **fill** **(** :ref:`int<class_int>` value **)**
  399. 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.
  400. .. rst-class:: classref-item-separator
  401. ----
  402. .. _class_PackedByteArray_method_find:
  403. .. rst-class:: classref-method
  404. :ref:`int<class_int>` **find** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |const|
  405. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_PackedByteArray_method_get_string_from_ascii:
  409. .. rst-class:: classref-method
  410. :ref:`String<class_String>` **get_string_from_ascii** **(** **)** |const|
  411. 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>`.
  412. .. rst-class:: classref-item-separator
  413. ----
  414. .. _class_PackedByteArray_method_get_string_from_utf8:
  415. .. rst-class:: classref-method
  416. :ref:`String<class_String>` **get_string_from_utf8** **(** **)** |const|
  417. 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.
  418. .. rst-class:: classref-item-separator
  419. ----
  420. .. _class_PackedByteArray_method_get_string_from_utf16:
  421. .. rst-class:: classref-method
  422. :ref:`String<class_String>` **get_string_from_utf16** **(** **)** |const|
  423. 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.
  424. .. rst-class:: classref-item-separator
  425. ----
  426. .. _class_PackedByteArray_method_get_string_from_utf32:
  427. .. rst-class:: classref-method
  428. :ref:`String<class_String>` **get_string_from_utf32** **(** **)** |const|
  429. 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.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_PackedByteArray_method_get_string_from_wchar:
  433. .. rst-class:: classref-method
  434. :ref:`String<class_String>` **get_string_from_wchar** **(** **)** |const|
  435. Converts wide character (``wchar_t``, UTF-16 on Windows, UTF-32 on other platforms) encoded array to :ref:`String<class_String>`. Returns empty string if source array is not valid wide string.
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_PackedByteArray_method_has:
  439. .. rst-class:: classref-method
  440. :ref:`bool<class_bool>` **has** **(** :ref:`int<class_int>` value **)** |const|
  441. Returns ``true`` if the array contains ``value``.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_PackedByteArray_method_has_encoded_var:
  445. .. rst-class:: classref-method
  446. :ref:`bool<class_bool>` **has_encoded_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  447. 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``.
  448. .. rst-class:: classref-item-separator
  449. ----
  450. .. _class_PackedByteArray_method_hex_encode:
  451. .. rst-class:: classref-method
  452. :ref:`String<class_String>` **hex_encode** **(** **)** |const|
  453. Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
  454. .. tabs::
  455. .. code-tab:: gdscript
  456. var array = PackedByteArray([11, 46, 255])
  457. print(array.hex_encode()) # Prints: 0b2eff
  458. .. code-tab:: csharp
  459. var array = new byte[] {11, 46, 255};
  460. GD.Print(array.HexEncode()); // Prints: 0b2eff
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _class_PackedByteArray_method_insert:
  464. .. rst-class:: classref-method
  465. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)**
  466. 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()``).
  467. .. rst-class:: classref-item-separator
  468. ----
  469. .. _class_PackedByteArray_method_is_empty:
  470. .. rst-class:: classref-method
  471. :ref:`bool<class_bool>` **is_empty** **(** **)** |const|
  472. Returns ``true`` if the array is empty.
  473. .. rst-class:: classref-item-separator
  474. ----
  475. .. _class_PackedByteArray_method_push_back:
  476. .. rst-class:: classref-method
  477. :ref:`bool<class_bool>` **push_back** **(** :ref:`int<class_int>` value **)**
  478. Appends an element at the end of the array.
  479. .. rst-class:: classref-item-separator
  480. ----
  481. .. _class_PackedByteArray_method_remove_at:
  482. .. rst-class:: classref-method
  483. void **remove_at** **(** :ref:`int<class_int>` index **)**
  484. Removes an element from the array by index.
  485. .. rst-class:: classref-item-separator
  486. ----
  487. .. _class_PackedByteArray_method_resize:
  488. .. rst-class:: classref-method
  489. :ref:`int<class_int>` **resize** **(** :ref:`int<class_int>` new_size **)**
  490. 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.
  491. .. rst-class:: classref-item-separator
  492. ----
  493. .. _class_PackedByteArray_method_reverse:
  494. .. rst-class:: classref-method
  495. void **reverse** **(** **)**
  496. Reverses the order of the elements in the array.
  497. .. rst-class:: classref-item-separator
  498. ----
  499. .. _class_PackedByteArray_method_rfind:
  500. .. rst-class:: classref-method
  501. :ref:`int<class_int>` **rfind** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const|
  502. 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.
  503. .. rst-class:: classref-item-separator
  504. ----
  505. .. _class_PackedByteArray_method_set:
  506. .. rst-class:: classref-method
  507. void **set** **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)**
  508. Changes the byte at the given index.
  509. .. rst-class:: classref-item-separator
  510. ----
  511. .. _class_PackedByteArray_method_size:
  512. .. rst-class:: classref-method
  513. :ref:`int<class_int>` **size** **(** **)** |const|
  514. Returns the number of elements in the array.
  515. .. rst-class:: classref-item-separator
  516. ----
  517. .. _class_PackedByteArray_method_slice:
  518. .. rst-class:: classref-method
  519. :ref:`PackedByteArray<class_PackedByteArray>` **slice** **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const|
  520. Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
  521. 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())``).
  522. 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)``).
  523. .. rst-class:: classref-item-separator
  524. ----
  525. .. _class_PackedByteArray_method_sort:
  526. .. rst-class:: classref-method
  527. void **sort** **(** **)**
  528. Sorts the elements of the array in ascending order.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_PackedByteArray_method_to_float32_array:
  532. .. rst-class:: classref-method
  533. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array** **(** **)** |const|
  534. 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``).
  535. 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``.
  536. If the original data can't be converted to 32-bit floats, the resulting data is undefined.
  537. .. rst-class:: classref-item-separator
  538. ----
  539. .. _class_PackedByteArray_method_to_float64_array:
  540. .. rst-class:: classref-method
  541. :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array** **(** **)** |const|
  542. 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>`).
  543. 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``.
  544. If the original data can't be converted to 64-bit floats, the resulting data is undefined.
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_PackedByteArray_method_to_int32_array:
  548. .. rst-class:: classref-method
  549. :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array** **(** **)** |const|
  550. 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``).
  551. 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``.
  552. If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
  553. .. rst-class:: classref-item-separator
  554. ----
  555. .. _class_PackedByteArray_method_to_int64_array:
  556. .. rst-class:: classref-method
  557. :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array** **(** **)** |const|
  558. 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>`).
  559. 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``.
  560. If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
  561. .. rst-class:: classref-section-separator
  562. ----
  563. .. rst-class:: classref-descriptions-group
  564. Operator Descriptions
  565. ---------------------
  566. .. _class_PackedByteArray_operator_neq_PackedByteArray:
  567. .. rst-class:: classref-operator
  568. :ref:`bool<class_bool>` **operator !=** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  569. Returns ``true`` if contents of the arrays differ.
  570. .. rst-class:: classref-item-separator
  571. ----
  572. .. _class_PackedByteArray_operator_sum_PackedByteArray:
  573. .. rst-class:: classref-operator
  574. :ref:`PackedByteArray<class_PackedByteArray>` **operator +** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  575. 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.
  576. .. rst-class:: classref-item-separator
  577. ----
  578. .. _class_PackedByteArray_operator_eq_PackedByteArray:
  579. .. rst-class:: classref-operator
  580. :ref:`bool<class_bool>` **operator ==** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  581. Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
  582. .. rst-class:: classref-item-separator
  583. ----
  584. .. _class_PackedByteArray_operator_idx_int:
  585. .. rst-class:: classref-operator
  586. :ref:`int<class_int>` **operator []** **(** :ref:`int<class_int>` index **)**
  587. 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.
  588. Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
  589. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  590. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  591. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  592. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  593. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  594. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  595. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`