Package gnu.lists
Class FString
- All Implemented Interfaces:
BoundedHashable
,Array<Char>
,AVector<Char>
,CharSeq
,Consumable
,Sequence<Char>
,Externalizable
,Serializable
,Appendable
,CharSequence
,Comparable
,Iterable<Char>
,Collection<Char>
,List<Char>
,RandomAccess
,SequencedCollection<Char>
- Direct Known Subclasses:
CharBuffer
Simple adjustable-length vector whose elements are 32-bit code points
Used for the Scheme string type.
This isn't a regular SimpleVector because character indexing
isn't a simple lookup.
"Sub-range mode" is not used (at least not for Kawa Scheme):
if you need an immutable sub-string, use an IString (or java.lang.String).
- See Also:
-
Field Summary
Fields inherited from class gnu.lists.AbstractCharVector
data, empty
Fields inherited from class gnu.lists.SimpleVector
COPY_ON_WRITE, GAP_FLAG, info, MAX_GAP_SIZE, READ_ONLY_FLAG, SHARED_FLAG, SUBRANGE_FLAG, VERY_SIMPLE_FLAG
Fields inherited from class gnu.lists.AbstractSequence
noInts
Fields inherited from interface gnu.lists.Sequence
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, ELEMENT_VALUE, EOF_VALUE, eofValue, FLOAT_VALUE, INT_S16_VALUE, INT_S32_VALUE, INT_S64_VALUE, INT_S8_VALUE, INT_U16_VALUE, INT_U32_VALUE, INT_U64_VALUE, INT_U8_VALUE, OBJECT_VALUE, PRIM_VALUE, PROCESSING_INSTRUCTION_VALUE, TEXT_BYTE_VALUE
-
Constructor Summary
ConstructorsConstructorDescriptionFString()
FString
(char[] values) Create an FString from a char[].FString
(char[] buffer, int offset, int length) This constructor makes a copy.FString
(int num) FString
(int num, int value) FString
(CharSequence seq) FString
(CharSequence seq, int offset, int length) Copy a substring of a CharSequence. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
addAllStrings
(Object[] args, int startIndex) Append arguments to this FString.static FString
alloc
(int sz) Create a empty string, but with a given initial buffer size.append
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) appendCharacter
(int c) Append a Unicode code point.final int
characterAt
(int index) void
consumePosRange
(int iposStart, int iposEnd, Consumer out) copy
(int start, int end) int
createPos
(int index, boolean isAfter) Generate a position at a given index.int
createRelativePos
(int pos, int delta, boolean isAfter) int
effectiveIndex
(int index) boolean
Must override, since we override hashCode.final Char
get
(int index) See java.util.List.int
final Char
getRaw
(int index) Given an "effective index", return element as object.getTag()
This is convenience hack for printing "uniform vectors" (srfi 4).int
indexOf
(int ch, int fromChar) void
insert
(int where, int ch, boolean beforeMarkers) void
void
insertRepeated
(int where, int value, int count) int
lastIndexOf
(int ch, int fromChar) protected FString
newInstance
(int newLength) protected int
nextIndex
(int ipos) Get the offset from the beginning corresponding to a position cookie.prepend
(CharSequence str, int start, int end) prependCharacter
(int c) void
replace
(int where, char[] chars, int start, int count) void
void
replace
(CharSequence src, int srcStart, int srcEnd, int dstStart, int dstEnd) Replace a substring of this string with another.See java.util.List.void
setCharacterAt
(int index, int ch) void
setCharAt
(int index, char ch) void
setCharAtBuffer
(int index, char ch) final void
Given an "effective index", set selected element.void
shift
(int srcStart, int dstStart, int count) int
size()
See java.util.List.subSequence
(int start, int end) substring
(int start, int end) char[]
Return a char[] contain the characters of this string.toString()
void
writeTo
(int start, int count, Appendable dest) Append a specified subsequence to anAppendable
.void
writeTo
(Appendable dest) Methods inherited from class gnu.lists.AbstractCharVector
charAt, clearBuffer, compareTo, compareTo, compareTo, copyBuffer, ensureBufferLength, equals, getBuffer, getBufferLength, getCharRaw, getChars, hashCode, length, openReader, openReader, setBuffer
Methods inherited from class gnu.lists.SimpleVector
add, add, addPos, addSpace, asImmutable, checkCanWrite, delete, doCopyOnWrite, fill, forEach, gapReserve, gapReserveGeneric, getGapEnd, getGapSize, getGapStart, getOffsetBits, getRowMajor, getSegment, getSegment, getSegmentReadOnly, getSizeBits, isAfterPos, isGapBuffer, isReadOnly, isSubRange, isVerySimple, readExternal, setGapBounds, setGapBounds, setInfoField, setReadOnly, toDataArray, vsize, writeExternal
Methods inherited from class gnu.lists.AbstractSequence
addAll, addAll, badRank, boundedHash, checkRank, clear, compare, compare, compare, consume, consume, consumeNext, contains, containsAll, copyPos, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, endPos, equals, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getContainingSequenceSize, getDoubleRaw, getFloatRaw, getIndexDifference, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getShortRaw, getSize, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hasNext, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, setAt, setPosNext, setPosPrevious, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedException
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface gnu.lists.Array
effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, get, get, get, get, getBooleanRaw, getByteRaw, getDoubleRaw, getFloatRaw, getInt, getInt, getInt, getInt, getInt, getIntRaw, getLongRaw, getLowBound, getShortRaw, getSize, getSize, isEmpty, rank, set
Methods inherited from interface gnu.kawa.util.BoundedHashable
boundedHash
Methods inherited from interface java.lang.CharSequence
chars, codePoints
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface gnu.lists.Consumable
consume
Methods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, getFirst, getLast, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
FString
public FString() -
FString
public FString(int num) -
FString
public FString(int num, int value) -
FString
public FString(char[] values) Create an FString from a char[]. Note that this contructor does *not* copy the argument. -
FString
public FString(char[] buffer, int offset, int length) This constructor makes a copy. -
FString
-
FString
Copy a substring of a CharSequence.- Parameters:
offset
- - start offset in 16-bit char unitslength
- - length in 16-bit char units
-
-
Method Details
-
size
public int size()Description copied from interface:Sequence
See java.util.List. -
effectiveIndex
public int effectiveIndex(int index) - Specified by:
effectiveIndex
in interfaceArray<Char>
- Overrides:
effectiveIndex
in classSimpleVector<Char>
- Parameters:
index
- measured in Unicode code points (characters)
-
createPos
public int createPos(int index, boolean isAfter) Description copied from class:AbstractSequence
Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.- Overrides:
createPos
in classAbstractSequence<Char>
- Parameters:
index
- offset from beginning of desired positionisAfter
- should the position have the isAfter property
-
nextIndex
protected int nextIndex(int ipos) Description copied from class:AbstractSequence
Get the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndex
in classAbstractSequence<Char>
-
createRelativePos
public int createRelativePos(int pos, int delta, boolean isAfter) - Overrides:
createRelativePos
in classAbstractSequence<Char>
-
alloc
Create a empty string, but with a given initial buffer size. -
getRaw
Description copied from interface:Array
Given an "effective index", return element as object. -
get
Description copied from interface:Sequence
See java.util.List. -
indexOf
public int indexOf(int ch, int fromChar) - Parameters:
fromChar
- offset in 16-bit code units
-
lastIndexOf
public int lastIndexOf(int ch, int fromChar) - Parameters:
fromChar
- offset in 16-bit code units
-
set
Description copied from interface:Sequence
See java.util.List. -
setRaw
Description copied from class:AbstractSequence
Given an "effective index", set selected element. -
characterAt
public final int characterAt(int index) - Parameters:
index
- offset in 16-bit code units
-
toCharArray
public char[] toCharArray()Return a char[] contain the characters of this string. It is unspecified if the result is a copy or shares with this FString. -
shift
public void shift(int srcStart, int dstStart, int count) - Overrides:
shift
in classSimpleVector<Char>
-
copy
-
addAll
-
insert
public void insert(int where, int ch, boolean beforeMarkers) -
insert
-
addAllStrings
Append arguments to this FString. Used to implement Scheme's string-append.- Parameters:
args
- an array of FString valuestartIndex
- index of first string inargs
to use
-
toString
- Specified by:
toString
in interfaceCharSeq
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classAbstractSequence<Char>
-
substring
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
setCharAt
public void setCharAt(int index, char ch) -
setCharacterAt
public void setCharacterAt(int index, int ch) - Specified by:
setCharacterAt
in interfaceCharSeq
-
replace
Replace a substring of this string with another. The two strings may have different lengths, so this generalizes insertion and deletion. All indexes are code-unit (16-bit char) offsets. -
setCharAtBuffer
public void setCharAtBuffer(int index, char ch) -
insertRepeated
public void insertRepeated(int where, int value, int count) -
replace
public void replace(int where, char[] chars, int start, int count) -
replace
-
equals
Description copied from class:AbstractCharVector
Must override, since we override hashCode.- Specified by:
equals
in interfaceCollection<Char>
- Specified by:
equals
in interfaceList<Char>
- Specified by:
equals
in classAbstractCharVector<Char>
-
newInstance
- Specified by:
newInstance
in classSimpleVector<Char>
-
getElementKind
public int getElementKind()- Specified by:
getElementKind
in interfaceArray<Char>
- Overrides:
getElementKind
in classAbstractSequence<Char>
-
getTag
Description copied from class:SimpleVector
This is convenience hack for printing "uniform vectors" (srfi 4). It may go away without notice!- Overrides:
getTag
in classSimpleVector<Char>
-
consumePosRange
- Overrides:
consumePosRange
in classAbstractSequence<Char>
-
append
- Specified by:
append
in interfaceAppendable
-
appendCharacter
Append a Unicode code point. -
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
append
-
prependCharacter
-
prepend
-
prepend
-
writeTo
Description copied from interface:CharSeq
Append a specified subsequence to anAppendable
. An allowable implementation is:dest.append(this, start, start+count)
. Hence implementors ofAppendable
should avoid callingwriteTo
- though they can callgetChars
.- Specified by:
writeTo
in interfaceCharSeq
- Throws:
IOException
-
writeTo
- Specified by:
writeTo
in interfaceCharSeq
- Throws:
IOException
-