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, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcopyPos(int ipos) Make a copy of a position int.intcreatePos(int index, boolean isAfter) Generate a position at a given index.voiddump()intendPos()protected voidgapReserve(int where, int needed) char[]getArray()booleanhasNext(int ipos) voidinsert(int where, int ch, boolean beforeMarkers) voidbooleanisAfterPos(int ipos) Tests whether the position has the "isAfter" property.intnextIndex(int ipos) Get the offset from the beginning corresponding to a position cookie.intnextPos(int ipos) Return the next position following the argument.voidreleasePos(int ipos) Reclaim any resources used by the given position int.intstartPos()toString()voidwriteTo(int start, int count, Appendable dest) Append a specified subsequence to anAppendable.voidwriteTo(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, toCharArrayMethods 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, gapReserveGeneric, getGapEnd, getGapSize, getGapStart, getOffsetBits, getRowMajor, getSegment, getSegment, getSegmentReadOnly, getSizeBits, 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, 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, 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
-
CharBuffer
-
CharBuffer
public CharBuffer(int initialSize) -
CharBuffer
protected CharBuffer()
-
-
Method Details
-
getArray
public char[] getArray() -
startPos
public int startPos()- Overrides:
startPosin classAbstractSequence<Char>
-
endPos
public int endPos()- Overrides:
endPosin classAbstractSequence<Char>
-
isAfterPos
public boolean isAfterPos(int ipos) Description copied from class:AbstractSequenceTests 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:
isAfterPosin classSimpleVector<Char>
-
hasNext
public boolean hasNext(int ipos) - Overrides:
hasNextin classAbstractSequence<Char>
-
nextPos
public int nextPos(int ipos) Description copied from class:AbstractSequenceReturn 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:
nextPosin classAbstractSequence<Char>
-
copyPos
public int copyPos(int ipos) Description copied from class:AbstractSequenceMake 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:
copyPosin classAbstractSequence<Char>- Parameters:
ipos- the position being copied.- Returns:
- the new position
-
nextIndex
public int nextIndex(int ipos) Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie. -
releasePos
public void releasePos(int ipos) Description copied from class:AbstractSequenceReclaim any resources used by the given position int.- Overrides:
releasePosin classAbstractSequence<Char>- Parameters:
ipos- the Pos being free'd.
-
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. -
insert
public void insert(int where, int ch, boolean beforeMarkers) -
insert
-
gapReserve
protected void gapReserve(int where, int needed) - Overrides:
gapReservein classSimpleVector<Char>
-
toString
-
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- Overrides:
writeToin classFString- Throws:
IOException
-
writeTo
- Specified by:
writeToin interfaceCharSeq- Overrides:
writeToin classFString- Throws:
IOException
-
dump
public void dump()
-