Package gnu.lists
Class CharBuffer
- 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>
Editable character sequence using a buffer-gap implementation and
self-adjusting position.
Can implement (the text part of) an Emacs buffer, or a
javax.swing.text.AbstractDocument.Content
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
copyPos
(int ipos) Make a copy of a position int.int
createPos
(int index, boolean isAfter) Generate a position at a given index.void
dump()
int
endPos()
protected void
gapReserve
(int where, int needed) char[]
getArray()
boolean
hasNext
(int ipos) void
insert
(int where, int ch, boolean beforeMarkers) void
boolean
isAfterPos
(int ipos) Tests whether the position has the "isAfter" property.int
nextIndex
(int ipos) Get the offset from the beginning corresponding to a position cookie.int
nextPos
(int ipos) Return the next position following the argument.void
releasePos
(int ipos) Reclaim any resources used by the given position int.int
startPos()
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.FString
addAll, addAllStrings, alloc, append, append, append, append, appendCharacter, characterAt, consumePosRange, copy, createRelativePos, effectiveIndex, equals, get, getElementKind, getRaw, getTag, indexOf, insertRepeated, lastIndexOf, newInstance, prepend, prepend, prependCharacter, replace, replace, replace, set, setCharacterAt, setCharAt, setCharAtBuffer, setRaw, shift, size, subSequence, substring, toCharArray
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, gapReserveGeneric, getGapEnd, getGapSize, getGapStart, getOffsetBits, getRowMajor, getSegment, getSegment, getSegmentReadOnly, getSizeBits, 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, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, 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, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, parentPos, previousPos, rank, remove, remove, removeAll, removePos, removePosRange, retainAll, set, setAt, setPosNext, setPosPrevious, stableCompare, 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
-
CharBuffer
-
CharBuffer
public CharBuffer(int initialSize) -
CharBuffer
protected CharBuffer()
-
-
Method Details
-
getArray
public char[] getArray() -
startPos
public int startPos()- Overrides:
startPos
in classAbstractSequence<Char>
-
endPos
public int endPos()- Overrides:
endPos
in classAbstractSequence<Char>
-
isAfterPos
public boolean isAfterPos(int ipos) Description copied from class:AbstractSequence
Tests whether the position has the "isAfter" property. I.e. if something is inserted at the position, will the iterator end up being after the new data?- Overrides:
isAfterPos
in classSimpleVector<Char>
-
hasNext
public boolean hasNext(int ipos) - Overrides:
hasNext
in classAbstractSequence<Char>
-
nextPos
public int nextPos(int ipos) Description copied from class:AbstractSequence
Return the next position following the argument. The new position has the isAfter property. The argument is implicitly released (as in releasePos). Returns 0 if we are already at end of file.- Overrides:
nextPos
in classAbstractSequence<Char>
-
copyPos
public int copyPos(int ipos) Description copied from class:AbstractSequence
Make a copy of a position int. For simple positions returns the argument. However, if the positions are magic cookies that are actively managed by the sequence (as opposed to for example a simple index), then making a copy may need to increment a reference count, or maybe allocate a new position cookie. In any case, the new position is initialized to the same offset (and isAfter property) as the original.- Overrides:
copyPos
in classAbstractSequence<Char>
- Parameters:
ipos
- the position being copied.- Returns:
- the new position
-
nextIndex
public int nextIndex(int ipos) Description copied from class:AbstractSequence
Get the offset from the beginning corresponding to a position cookie. -
releasePos
public void releasePos(int ipos) Description copied from class:AbstractSequence
Reclaim any resources used by the given position int.- Overrides:
releasePos
in classAbstractSequence<Char>
- Parameters:
ipos
- the Pos being free'd.
-
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. -
insert
public void insert(int where, int ch, boolean beforeMarkers) -
insert
-
gapReserve
protected void gapReserve(int where, int needed) - Overrides:
gapReserve
in classSimpleVector<Char>
-
toString
-
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
- Overrides:
writeTo
in classFString
- Throws:
IOException
-
writeTo
- Specified by:
writeTo
in interfaceCharSeq
- Overrides:
writeTo
in classFString
- Throws:
IOException
-
dump
public void dump()
-