class_poolrealarray.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the PoolRealArray.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_PoolRealArray:
  6. PoolRealArray
  7. =============
  8. A pooled :ref:`Array<class_Array>` of reals (:ref:`float<class_float>`).
  9. Description
  10. -----------
  11. An :ref:`Array<class_Array>` specifically designed to hold floating-point values. Optimized for memory usage, does not fragment the memory.
  12. **Note:** This type is passed by value and not by reference.
  13. **Note:** Unlike primitive :ref:`float<class_float>`\ s which are 64-bit, numbers stored in ``PoolRealArray`` are 32-bit floats. This means values stored in ``PoolRealArray`` have lower precision compared to primitive :ref:`float<class_float>`\ s. If you need to store 64-bit floats in an array, use a generic :ref:`Array<class_Array>` with :ref:`float<class_float>` elements as these will still be 64-bit. However, using a generic :ref:`Array<class_Array>` to store :ref:`float<class_float>`\ s will use roughly 6 times more memory compared to a ``PoolRealArray``.
  14. Methods
  15. -------
  16. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`PoolRealArray<class_PoolRealArray>` | :ref:`PoolRealArray<class_PoolRealArray_method_PoolRealArray>` **(** :ref:`Array<class_Array>` from **)** |
  18. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`append<class_PoolRealArray_method_append>` **(** :ref:`float<class_float>` value **)** |
  20. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`append_array<class_PoolRealArray_method_append_array>` **(** :ref:`PoolRealArray<class_PoolRealArray>` array **)** |
  22. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`empty<class_PoolRealArray_method_empty>` **(** **)** |
  24. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`insert<class_PoolRealArray_method_insert>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` value **)** |
  26. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`invert<class_PoolRealArray_method_invert>` **(** **)** |
  28. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`push_back<class_PoolRealArray_method_push_back>` **(** :ref:`float<class_float>` value **)** |
  30. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`remove<class_PoolRealArray_method_remove>` **(** :ref:`int<class_int>` idx **)** |
  32. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`resize<class_PoolRealArray_method_resize>` **(** :ref:`int<class_int>` idx **)** |
  34. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set<class_PoolRealArray_method_set>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` value **)** |
  36. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`size<class_PoolRealArray_method_size>` **(** **)** |
  38. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  39. Method Descriptions
  40. -------------------
  41. .. _class_PoolRealArray_method_PoolRealArray:
  42. - :ref:`PoolRealArray<class_PoolRealArray>` **PoolRealArray** **(** :ref:`Array<class_Array>` from **)**
  43. Constructs a new ``PoolRealArray``. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  44. ----
  45. .. _class_PoolRealArray_method_append:
  46. - void **append** **(** :ref:`float<class_float>` value **)**
  47. Appends an element at the end of the array (alias of :ref:`push_back<class_PoolRealArray_method_push_back>`).
  48. ----
  49. .. _class_PoolRealArray_method_append_array:
  50. - void **append_array** **(** :ref:`PoolRealArray<class_PoolRealArray>` array **)**
  51. Appends a ``PoolRealArray`` at the end of this array.
  52. ----
  53. .. _class_PoolRealArray_method_empty:
  54. - :ref:`bool<class_bool>` **empty** **(** **)**
  55. Returns ``true`` if the array is empty.
  56. ----
  57. .. _class_PoolRealArray_method_insert:
  58. - :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` value **)**
  59. 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()``).
  60. ----
  61. .. _class_PoolRealArray_method_invert:
  62. - void **invert** **(** **)**
  63. Reverses the order of the elements in the array.
  64. ----
  65. .. _class_PoolRealArray_method_push_back:
  66. - void **push_back** **(** :ref:`float<class_float>` value **)**
  67. Appends an element at the end of the array.
  68. ----
  69. .. _class_PoolRealArray_method_remove:
  70. - void **remove** **(** :ref:`int<class_int>` idx **)**
  71. Removes an element from the array by index.
  72. ----
  73. .. _class_PoolRealArray_method_resize:
  74. - void **resize** **(** :ref:`int<class_int>` idx **)**
  75. 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.
  76. **Note:** Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values.
  77. ----
  78. .. _class_PoolRealArray_method_set:
  79. - void **set** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` value **)**
  80. Changes the float at the given index.
  81. ----
  82. .. _class_PoolRealArray_method_size:
  83. - :ref:`int<class_int>` **size** **(** **)**
  84. Returns the size of the array.
  85. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  86. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  87. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`