Class CharsArray
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.CharsArray
-
- All Implemented Interfaces:
Chars,CharsModifiable
public class CharsArray extends Object implements CharsModifiable
- Author:
- hogye
-
-
Constructor Summary
Constructors Constructor Description CharsArray()CharsArray(char[] a)For efficiency, does not clone the array arg.CharsArray(char[] a, int n)For efficiency, does not clone the array arg.CharsArray(int n)CharsArray(Chars xs)Clones the sequence arg.CharsArray(String xs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(char v)voidappend(char[] vs)voidappend(char[] vs, int from, int to)voidappend(Chars vs)voidappend(Chars vs, int from, int to)voidappend(String vs)voidappend(String vs, int from, int to)voidappend(CharBuffer vs)voidappend(CharBuffer vs, int c)voidclear()voidcompact()CharsArraycopy()char[]copyOf()char[]copyOf(int i, int c)voidcopyTo(int i, char[] dest, int iDest, int c)voidcopyTo(int i, CharBuffer dest, int c)voidcopyTo(CharBuffer dest)voidensureCapacity(int minCapacity)charfirst()voidinsert(int i, char v)voidinsert(int i, char[] vs)voidinsert(int i, char[] vs, int from, int to)voidinsert(int i, Chars vs)voidinsert(int i, Chars vs, int from, int to)voidinsert(int i, String vs)voidinsert(int i, String vs, int from, int to)voidinsert(int i, CharBuffer vs)voidinsert(int i, CharBuffer vs, int c)booleanisEmpty()charlast()intn()Length of the sequencestatic char[]newArray(int oldCapacity, int minNewCapacity)Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.voidprepend(char v)voidprepend(char[] vs)voidprepend(char[] vs, int from, int to)voidprepend(Chars vs)voidprepend(Chars vs, int from, int to)voidprepend(String vs)voidprepend(String vs, int from, int to)voidprepend(CharBuffer vs)voidprepend(CharBuffer vs, int c)voidprepForAppend(int c)Makes room in this array for new values to be appended.voidprepForInsert(int i, int c)Makes room in this array for new values to be inserted.voidprepForPrepend(int c)Makes room in this array for new values to be prepended.voidremove(char v)Removes a single copy of the specified value.voidremoveIndex(int index)Remove value at index.voidremoveRange(int from, int to)Removes values starting at index from (inclusive) to index to (exclusive).voidset(int i, char v)voidset(int i, char[] vs)voidset(int i, char[] vs, int from, int to)Stringstring()Stringstring(int i, int c)charv(int i)Value at index i
-
-
-
Constructor Detail
-
CharsArray
public CharsArray(char[] a)
For efficiency, does not clone the array arg.
-
CharsArray
public CharsArray(int n)
-
CharsArray
public CharsArray()
-
CharsArray
public CharsArray(char[] a, int n)For efficiency, does not clone the array arg.
-
CharsArray
public CharsArray(Chars xs)
Clones the sequence arg.
-
CharsArray
public CharsArray(String xs)
-
-
Method Detail
-
v
public char v(int i)
Description copied from interface:CharsValue at index i
-
n
public int n()
Description copied from interface:CharsLength of the sequence
-
copyTo
public void copyTo(int i, char[] dest, int iDest, int c)
-
copyTo
public void copyTo(int i, CharBuffer dest, int c)
-
copyTo
public void copyTo(CharBuffer dest)
-
copy
public CharsArray copy()
- Specified by:
copyin interfaceChars- Specified by:
copyin interfaceCharsModifiable
-
set
public void set(int i, char v)- Specified by:
setin interfaceCharsModifiable
-
set
public void set(int i, char[] vs)- Specified by:
setin interfaceCharsModifiable
-
set
public void set(int i, char[] vs, int from, int to)- Specified by:
setin interfaceCharsModifiable
-
insert
public void insert(int i, char v)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, Chars vs)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, Chars vs, int from, int to)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, String vs)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, String vs, int from, int to)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, char[] vs)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, char[] vs, int from, int to)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, CharBuffer vs)- Specified by:
insertin interfaceCharsModifiable
-
insert
public void insert(int i, CharBuffer vs, int c)- Specified by:
insertin interfaceCharsModifiable
-
prepForInsert
public void prepForInsert(int i, int c)Makes room in this array for new values to be inserted. When this call returns, the values inthis.aon[i,i+c)are undefined. Writing meaningful values to these indices is up to the caller.- Parameters:
i- The index at which new values will be insertedc- The count of new values that will be inserted
-
prepend
public void prepend(char v)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(Chars vs)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(Chars vs, int from, int to)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(String vs)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(String vs, int from, int to)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(char[] vs)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(char[] vs, int from, int to)- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(CharBuffer vs)
- Specified by:
prependin interfaceCharsModifiable
-
prepend
public void prepend(CharBuffer vs, int c)
- Specified by:
prependin interfaceCharsModifiable
-
prepForPrepend
public void prepForPrepend(int c)
Makes room in this array for new values to be prepended. When this call returns, the values inthis.aon[0,c)are undefined. Writing meaningful values to these indices is up to the caller.- Parameters:
c- The count of new values that will be inserted
-
append
public void append(char v)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(Chars vs)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(Chars vs, int from, int to)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(String vs)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(String vs, int from, int to)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(char[] vs)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(char[] vs, int from, int to)- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(CharBuffer vs)
- Specified by:
appendin interfaceCharsModifiable
-
append
public void append(CharBuffer vs, int c)
- Specified by:
appendin interfaceCharsModifiable
-
prepForAppend
public void prepForAppend(int c)
Makes room in this array for new values to be appended. When this call returns, the values inthis.aon[this.n-c,this.n)are undefined. Writing meaningful values to these indices is up to the caller.- Parameters:
c- The count of new values that will be appended
-
remove
public void remove(char v)
Description copied from interface:CharsModifiableRemoves a single copy of the specified value. If multiple copies are present, there is no guarantee which one will be removed.- Specified by:
removein interfaceCharsModifiable
-
removeRange
public void removeRange(int from, int to)Description copied from interface:CharsModifiableRemoves values starting at index from (inclusive) to index to (exclusive). All other values with indices greater than or equal to index to have their index in the array decreased by to-from and the size of the array is decreased by to-from.- Specified by:
removeRangein interfaceCharsModifiable
-
removeIndex
public void removeIndex(int index)
Description copied from interface:CharsModifiableRemove value at index. All other values with indices greater than index have their index in the array decreased by one and the size of the array is decreased by one.- Specified by:
removeIndexin interfaceCharsModifiable
-
clear
public void clear()
- Specified by:
clearin interfaceCharsModifiable
-
ensureCapacity
public void ensureCapacity(int minCapacity)
- Specified by:
ensureCapacityin interfaceCharsModifiable
-
compact
public void compact()
- Specified by:
compactin interfaceCharsModifiable
-
newArray
public static char[] newArray(int oldCapacity, int minNewCapacity)Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.
-
-