Package org.miaixz.bus.core.text
Class CharArray
java.lang.Object
org.miaixz.bus.core.text.CharArray
- All Implemented Interfaces:
CharSequence,Iterable<Character>
char[]包装,提供zero-copy的数组操作
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmptyMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CharArray
构造- Parameters:
value- String值
-
CharArray
public CharArray(char[] value, boolean copy) 构造,注意此方法共享数组- Parameters:
value- char数组copy- 可选是否拷贝数组,如果为false则复用数组
-
-
Method Details
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
set
设置字符- Parameters:
index- 位置,支持复数,-1表示最后一个位置c- 字符- Returns:
- this
-
array
public char[] array()获取原始数组,不做拷贝- Returns:
- array
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
equals
-
hashCode
public int hashCode() -
iterator
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-