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, emptyFields inherited from class gnu.lists.SimpleVector
COPY_ON_WRITE, GAP_FLAG, info, MAX_GAP_SIZE, READ_ONLY_FLAG, SHARED_FLAG, SUBRANGE_FLAG, VERY_SIMPLE_FLAGFields inherited from class gnu.lists.AbstractSequence
noIntsFields 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 TypeMethodDescriptionbooleanvoidaddAllStrings(Object[] args, int startIndex) Append arguments to this FString.static FStringalloc(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 intcharacterAt(int index) voidconsumePosRange(int iposStart, int iposEnd, Consumer out) copy(int start, int end) intcreatePos(int index, boolean isAfter) Generate a position at a given index.intcreateRelativePos(int pos, int delta, boolean isAfter) inteffectiveIndex(int index) booleanMust override, since we override hashCode.final Charget(int index) See java.util.List.intfinal ChargetRaw(int index) Given an "effective index", return element as object.getTag()This is convenience hack for printing "uniform vectors" (srfi 4).intindexOf(int ch, int fromChar) voidinsert(int where, int ch, boolean beforeMarkers) voidvoidinsertRepeated(int where, int value, int count) intlastIndexOf(int ch, int fromChar) protected FStringnewInstance(int newLength) protected intnextIndex(int ipos) Get the offset from the beginning corresponding to a position cookie.prepend(CharSequence str, int start, int end) prependCharacter(int c) voidreplace(int where, char[] chars, int start, int count) voidvoidreplace(CharSequence src, int srcStart, int srcEnd, int dstStart, int dstEnd) Replace a substring of this string with another.See java.util.List.voidsetCharacterAt(int index, int ch) voidsetCharAt(int index, char ch) voidsetCharAtBuffer(int index, char ch) final voidGiven an "effective index", set selected element.voidshift(int srcStart, int dstStart, int count) intsize()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()voidwriteTo(int start, int count, Appendable dest) Append a specified subsequence to anAppendable.voidwriteTo(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, setBufferMethods 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, writeExternalMethods 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, unsupportedExceptionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, setMethods inherited from interface gnu.kawa.util.BoundedHashable
boundedHashMethods inherited from interface java.lang.CharSequence
chars, codePointsMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface gnu.lists.Consumable
consumeMethods 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:SequenceSee java.util.List. -
effectiveIndex
public int effectiveIndex(int index) - Specified by:
effectiveIndexin interfaceArray<Char>- Overrides:
effectiveIndexin classSimpleVector<Char>- Parameters:
index- measured in Unicode code points (characters)
-
createPos
public int createPos(int index, boolean isAfter) Description copied from class:AbstractSequenceGenerate a position at a given index. The result is a position cookie that must be free'd with releasePos.- Overrides:
createPosin 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:AbstractSequenceGet the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndexin classAbstractSequence<Char>
-
createRelativePos
public int createRelativePos(int pos, int delta, boolean isAfter) - Overrides:
createRelativePosin classAbstractSequence<Char>
-
alloc
Create a empty string, but with a given initial buffer size. -
getRaw
Description copied from interface:ArrayGiven an "effective index", return element as object. -
get
Description copied from interface:SequenceSee 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:SequenceSee java.util.List. -
setRaw
Description copied from class:AbstractSequenceGiven 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:
shiftin 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 inargsto use
-
toString
- Specified by:
toStringin interfaceCharSeq- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classAbstractSequence<Char>
-
substring
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
setCharAt
public void setCharAt(int index, char ch) -
setCharacterAt
public void setCharacterAt(int index, int ch) - Specified by:
setCharacterAtin 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:AbstractCharVectorMust override, since we override hashCode.- Specified by:
equalsin interfaceCollection<Char>- Specified by:
equalsin interfaceList<Char>- Specified by:
equalsin classAbstractCharVector<Char>
-
newInstance
- Specified by:
newInstancein classSimpleVector<Char>
-
getElementKind
public int getElementKind()- Specified by:
getElementKindin interfaceArray<Char>- Overrides:
getElementKindin classAbstractSequence<Char>
-
getTag
Description copied from class:SimpleVectorThis is convenience hack for printing "uniform vectors" (srfi 4). It may go away without notice!- Overrides:
getTagin classSimpleVector<Char>
-
consumePosRange
- Overrides:
consumePosRangein classAbstractSequence<Char>
-
append
- Specified by:
appendin interfaceAppendable
-
appendCharacter
Append a Unicode code point. -
append
- Specified by:
appendin interfaceAppendable
-
append
- Specified by:
appendin interfaceAppendable
-
append
-
prependCharacter
-
prepend
-
prepend
-
writeTo
Description copied from interface:CharSeqAppend a specified subsequence to anAppendable. An allowable implementation is:dest.append(this, start, start+count). Hence implementors ofAppendableshould avoid callingwriteTo- though they can callgetChars.- Specified by:
writeToin interfaceCharSeq- Throws:
IOException
-
writeTo
- Specified by:
writeToin interfaceCharSeq- Throws:
IOException
-