PoolByteArray

类别: 内置类型

简要说明

集合 Array 字节数。

方法

PoolByteArray

PoolByteArray ( Array from )

无效

append ( int byte )

无效

append_array ( PoolByteArray array )

PoolByteArray

compress ( int compression_mode=0 )

PoolByteArray

decompress ( int buffer_size, int compression_mode=0 )

String

get_string_from_ascii ( )

String

get_string_from_utf8 ( )

int

insert ( int idx, int byte )

无效

invert ( )

无效

push_back ( int byte )

无效

remove ( int idx )

无效

resize ( int idx )

无效

set ( int idx, int byte )

String

sha256_string ( )

int

size ( )

PoolByteArray

subarray ( int from, int to )

描述

Array 专门设计用于保存字节。针对内存使用进行了优化,不会将内存碎片化。

注: 此类型是通过值传递的,而不是通过引用传递的。

方法说明

构建新的 PoolByteArray . 或者,可以传入一个泛型 Array 这将被转换。

  • void append ( int byte )

在数组末尾附加一个元素(数组的别名 push_back

附录A PoolByteArray 在这个数组的末尾。

返回新的 PoolByteArray 数据被压缩。使用以下选项之一设置压缩模式 CompressionMode 的常量。

返回新的 PoolByteArray 将数据解压缩。集合 buffer_size 到未压缩数据的大小。使用以下选项之一设置压缩模式 CompressionMode 的常量。

  • String get_string_from_ascii ( )

将数组内容的副本返回为 String . 快速替代 get_string_from_utf8 如果内容仅为ASCII。与utf-8函数不同,此函数将每个字节映射到数组中的一个字符。多字节序列将无法正确解释。对于分析用户输入,始终使用 get_string_from_utf8 .

  • String get_string_from_utf8 ( )

将数组内容的副本返回为 String . 比…慢 get_string_from_ascii 但支持UTF-8编码数据。如果您不确定数据源,请使用此函数。对于用户输入,应始终首选此功能。

在数组的给定位置插入新元素。位置必须有效,或在数组末尾 (idx == size()

  • void invert ( )

反转数组中元素的顺序。

  • void push_back ( int byte )

在数组末尾附加元素。

  • void remove ( int idx )

按索引从数组中删除元素。

  • void resize ( int idx )

设置数组的大小。如果数组增大,则在数组末尾保留元素。如果数组收缩,则将数组截断为新的大小。

  • void set ( int idx, int byte )

更改给定索引处的字节。

返回poolbytearray的sha-256字符串。

返回数组的大小。

返回 PoolByteArray 作为新的 PoolByteArray . 任何负索引都被认为是从数组的末尾开始的。