class_packedbytearray.rst 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  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. \ **Note:** Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
  309. .. rst-class:: classref-item-separator
  310. ----
  311. .. _class_PackedByteArray_method_decompress_dynamic:
  312. .. rst-class:: classref-method
  313. :ref:`PackedByteArray<class_PackedByteArray>` **decompress_dynamic** **(** :ref:`int<class_int>` max_output_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  314. 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.**\
  315. 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.
  316. 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.
  317. \ **Note:** Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
  318. .. rst-class:: classref-item-separator
  319. ----
  320. .. _class_PackedByteArray_method_duplicate:
  321. .. rst-class:: classref-method
  322. :ref:`PackedByteArray<class_PackedByteArray>` **duplicate** **(** **)**
  323. Creates a copy of the array, and returns it.
  324. .. rst-class:: classref-item-separator
  325. ----
  326. .. _class_PackedByteArray_method_encode_double:
  327. .. rst-class:: classref-method
  328. void **encode_double** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  329. 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.
  330. .. rst-class:: classref-item-separator
  331. ----
  332. .. _class_PackedByteArray_method_encode_float:
  333. .. rst-class:: classref-method
  334. void **encode_float** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  335. 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.
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_PackedByteArray_method_encode_half:
  339. .. rst-class:: classref-method
  340. void **encode_half** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  341. 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.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_PackedByteArray_method_encode_s8:
  345. .. rst-class:: classref-method
  346. void **encode_s8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  347. 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.
  348. .. rst-class:: classref-item-separator
  349. ----
  350. .. _class_PackedByteArray_method_encode_s16:
  351. .. rst-class:: classref-method
  352. void **encode_s16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  353. 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.
  354. .. rst-class:: classref-item-separator
  355. ----
  356. .. _class_PackedByteArray_method_encode_s32:
  357. .. rst-class:: classref-method
  358. void **encode_s32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  359. 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.
  360. .. rst-class:: classref-item-separator
  361. ----
  362. .. _class_PackedByteArray_method_encode_s64:
  363. .. rst-class:: classref-method
  364. void **encode_s64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  365. 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.
  366. .. rst-class:: classref-item-separator
  367. ----
  368. .. _class_PackedByteArray_method_encode_u8:
  369. .. rst-class:: classref-method
  370. void **encode_u8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  371. 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.
  372. .. rst-class:: classref-item-separator
  373. ----
  374. .. _class_PackedByteArray_method_encode_u16:
  375. .. rst-class:: classref-method
  376. void **encode_u16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  377. 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.
  378. .. rst-class:: classref-item-separator
  379. ----
  380. .. _class_PackedByteArray_method_encode_u32:
  381. .. rst-class:: classref-method
  382. void **encode_u32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  383. 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.
  384. .. rst-class:: classref-item-separator
  385. ----
  386. .. _class_PackedByteArray_method_encode_u64:
  387. .. rst-class:: classref-method
  388. void **encode_u64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  389. 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.
  390. .. rst-class:: classref-item-separator
  391. ----
  392. .. _class_PackedByteArray_method_encode_var:
  393. .. rst-class:: classref-method
  394. :ref:`int<class_int>` **encode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` allow_objects=false **)**
  395. 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.
  396. .. rst-class:: classref-item-separator
  397. ----
  398. .. _class_PackedByteArray_method_fill:
  399. .. rst-class:: classref-method
  400. void **fill** **(** :ref:`int<class_int>` value **)**
  401. 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.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_PackedByteArray_method_find:
  405. .. rst-class:: classref-method
  406. :ref:`int<class_int>` **find** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |const|
  407. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_PackedByteArray_method_get_string_from_ascii:
  411. .. rst-class:: classref-method
  412. :ref:`String<class_String>` **get_string_from_ascii** **(** **)** |const|
  413. 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>`.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_PackedByteArray_method_get_string_from_utf8:
  417. .. rst-class:: classref-method
  418. :ref:`String<class_String>` **get_string_from_utf8** **(** **)** |const|
  419. 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.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_PackedByteArray_method_get_string_from_utf16:
  423. .. rst-class:: classref-method
  424. :ref:`String<class_String>` **get_string_from_utf16** **(** **)** |const|
  425. 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.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_PackedByteArray_method_get_string_from_utf32:
  429. .. rst-class:: classref-method
  430. :ref:`String<class_String>` **get_string_from_utf32** **(** **)** |const|
  431. 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.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_PackedByteArray_method_get_string_from_wchar:
  435. .. rst-class:: classref-method
  436. :ref:`String<class_String>` **get_string_from_wchar** **(** **)** |const|
  437. 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.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_PackedByteArray_method_has:
  441. .. rst-class:: classref-method
  442. :ref:`bool<class_bool>` **has** **(** :ref:`int<class_int>` value **)** |const|
  443. Returns ``true`` if the array contains ``value``.
  444. .. rst-class:: classref-item-separator
  445. ----
  446. .. _class_PackedByteArray_method_has_encoded_var:
  447. .. rst-class:: classref-method
  448. :ref:`bool<class_bool>` **has_encoded_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  449. 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``.
  450. .. rst-class:: classref-item-separator
  451. ----
  452. .. _class_PackedByteArray_method_hex_encode:
  453. .. rst-class:: classref-method
  454. :ref:`String<class_String>` **hex_encode** **(** **)** |const|
  455. Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
  456. .. tabs::
  457. .. code-tab:: gdscript
  458. var array = PackedByteArray([11, 46, 255])
  459. print(array.hex_encode()) # Prints: 0b2eff
  460. .. code-tab:: csharp
  461. var array = new byte[] {11, 46, 255};
  462. GD.Print(array.HexEncode()); // Prints: 0b2eff
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_PackedByteArray_method_insert:
  466. .. rst-class:: classref-method
  467. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)**
  468. 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()``).
  469. .. rst-class:: classref-item-separator
  470. ----
  471. .. _class_PackedByteArray_method_is_empty:
  472. .. rst-class:: classref-method
  473. :ref:`bool<class_bool>` **is_empty** **(** **)** |const|
  474. Returns ``true`` if the array is empty.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_PackedByteArray_method_push_back:
  478. .. rst-class:: classref-method
  479. :ref:`bool<class_bool>` **push_back** **(** :ref:`int<class_int>` value **)**
  480. Appends an element at the end of the array.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_PackedByteArray_method_remove_at:
  484. .. rst-class:: classref-method
  485. void **remove_at** **(** :ref:`int<class_int>` index **)**
  486. Removes an element from the array by index.
  487. .. rst-class:: classref-item-separator
  488. ----
  489. .. _class_PackedByteArray_method_resize:
  490. .. rst-class:: classref-method
  491. :ref:`int<class_int>` **resize** **(** :ref:`int<class_int>` new_size **)**
  492. 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.
  493. .. rst-class:: classref-item-separator
  494. ----
  495. .. _class_PackedByteArray_method_reverse:
  496. .. rst-class:: classref-method
  497. void **reverse** **(** **)**
  498. Reverses the order of the elements in the array.
  499. .. rst-class:: classref-item-separator
  500. ----
  501. .. _class_PackedByteArray_method_rfind:
  502. .. rst-class:: classref-method
  503. :ref:`int<class_int>` **rfind** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const|
  504. 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.
  505. .. rst-class:: classref-item-separator
  506. ----
  507. .. _class_PackedByteArray_method_set:
  508. .. rst-class:: classref-method
  509. void **set** **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)**
  510. Changes the byte at the given index.
  511. .. rst-class:: classref-item-separator
  512. ----
  513. .. _class_PackedByteArray_method_size:
  514. .. rst-class:: classref-method
  515. :ref:`int<class_int>` **size** **(** **)** |const|
  516. Returns the number of elements in the array.
  517. .. rst-class:: classref-item-separator
  518. ----
  519. .. _class_PackedByteArray_method_slice:
  520. .. rst-class:: classref-method
  521. :ref:`PackedByteArray<class_PackedByteArray>` **slice** **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const|
  522. Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
  523. 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())``).
  524. 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)``).
  525. .. rst-class:: classref-item-separator
  526. ----
  527. .. _class_PackedByteArray_method_sort:
  528. .. rst-class:: classref-method
  529. void **sort** **(** **)**
  530. Sorts the elements of the array in ascending order.
  531. .. rst-class:: classref-item-separator
  532. ----
  533. .. _class_PackedByteArray_method_to_float32_array:
  534. .. rst-class:: classref-method
  535. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array** **(** **)** |const|
  536. 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``).
  537. 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``.
  538. If the original data can't be converted to 32-bit floats, the resulting data is undefined.
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _class_PackedByteArray_method_to_float64_array:
  542. .. rst-class:: classref-method
  543. :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array** **(** **)** |const|
  544. 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>`).
  545. 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``.
  546. If the original data can't be converted to 64-bit floats, the resulting data is undefined.
  547. .. rst-class:: classref-item-separator
  548. ----
  549. .. _class_PackedByteArray_method_to_int32_array:
  550. .. rst-class:: classref-method
  551. :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array** **(** **)** |const|
  552. 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``).
  553. 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``.
  554. If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
  555. .. rst-class:: classref-item-separator
  556. ----
  557. .. _class_PackedByteArray_method_to_int64_array:
  558. .. rst-class:: classref-method
  559. :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array** **(** **)** |const|
  560. 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>`).
  561. 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``.
  562. If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
  563. .. rst-class:: classref-section-separator
  564. ----
  565. .. rst-class:: classref-descriptions-group
  566. Operator Descriptions
  567. ---------------------
  568. .. _class_PackedByteArray_operator_neq_PackedByteArray:
  569. .. rst-class:: classref-operator
  570. :ref:`bool<class_bool>` **operator !=** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  571. Returns ``true`` if contents of the arrays differ.
  572. .. rst-class:: classref-item-separator
  573. ----
  574. .. _class_PackedByteArray_operator_sum_PackedByteArray:
  575. .. rst-class:: classref-operator
  576. :ref:`PackedByteArray<class_PackedByteArray>` **operator +** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  577. 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.
  578. .. rst-class:: classref-item-separator
  579. ----
  580. .. _class_PackedByteArray_operator_eq_PackedByteArray:
  581. .. rst-class:: classref-operator
  582. :ref:`bool<class_bool>` **operator ==** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  583. Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
  584. .. rst-class:: classref-item-separator
  585. ----
  586. .. _class_PackedByteArray_operator_idx_int:
  587. .. rst-class:: classref-operator
  588. :ref:`int<class_int>` **operator []** **(** :ref:`int<class_int>` index **)**
  589. 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.
  590. Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
  591. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  592. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  593. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  594. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  595. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  596. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  597. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`