Trait/Object

com.github.arturopala.bufferandslice

Buffer

Related Docs: object Buffer | package bufferandslice

Permalink

trait Buffer[T] extends (Int) ⇒ T

Mutable indexed buffer abstraction. All modifications happens in-place.

In addition, the Buffer API offers both Stack- and List-like interfaces. For the purpose of the List-like processing, the head is a top element in the buffer.

Linear Supertypes
(Int) ⇒ T, AnyRef, Any
Known Subclasses
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Buffer
  2. Function1
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def apply(index: Int): T

    Permalink

    Returns value at the provided index.

    Returns value at the provided index.

    Definition Classes
    Buffer → Function1
  2. abstract def asArray: Array[T]

    Permalink

    Returns a trimmed copy of an underlying array.

  3. abstract def asSlice: Slice[T]

    Permalink

    Wraps accessible internal state as a Slice without making any copy.

  4. abstract def copy: Buffer.this.type

    Permalink

    Creates a copy of this buffer.

  5. abstract def emptyCopy: Buffer.this.type

    Permalink

    Creates a copy of this buffer.

  6. abstract def ensureIndex(index: Int): Unit

    Permalink

    Ensures buffer capacity to address provided index.

    Ensures buffer capacity to address provided index.

    Attributes
    protected
  7. abstract def insertArray(index: Int, sourceIndex: Int, insertLength: Int, sourceArray: Array[T]): Buffer.this.type

    Permalink

    Shift current content to the right starting from index at the insertLength distance, and copies array chunk into the gap.

    Shift current content to the right starting from index at the insertLength distance, and copies array chunk into the gap. - Sets topIndex to be at least at the end of the new chunk of values.

  8. abstract def insertSlice(index: Int, slice: Slice[T]): Buffer.this.type

    Permalink

    Shift current content to the right starting from index at the slice.length distance, and copies slice into the gap.

    Shift current content to the right starting from index at the slice.length distance, and copies slice into the gap. - Sets topIndex to be at least at the end of the new chunk of values.

  9. abstract def moveRangeLeft(fromIndex: Int, toIndex: Int, distance: Int): Buffer.this.type

    Permalink

    Moves values in [fromIndex, toIndex) to the left at a distance, to become [fromIndex - distance, toIndex - distance), and moves right any existing values in [fromIndex - distance, fromIndex) to become [toIndex, toIndex + distance).

    Moves values in [fromIndex, toIndex) to the left at a distance, to become [fromIndex - distance, toIndex - distance), and moves right any existing values in [fromIndex - distance, fromIndex) to become [toIndex, toIndex + distance). - Ignores negative distance. - Does nothing if fromIndex > topIndex. - Moves topIndex if affected.

  10. abstract def moveRangeRight(fromIndex: Int, toIndex: Int, distance: Int): Buffer.this.type

    Permalink

    Moves values in [fromIndex, toIndex) to the right at a distance, to become [fromIndex + distance, toIndex + distance), and moves left any existing values in [toIndex, toIndex + distance) to become [fromIndex, fromIndex + distance).

    Moves values in [fromIndex, toIndex) to the right at a distance, to become [fromIndex + distance, toIndex + distance), and moves left any existing values in [toIndex, toIndex + distance) to become [fromIndex, fromIndex + distance). - Ignores negative distance. - Does nothing if fromIndex > topIndex. - Moves topIndex if affected.

  11. abstract def optimize(): Buffer.this.type

    Permalink

    Attempts to optimize buffer storage, if needed.

  12. abstract def read(index: Int): T

    Permalink

    Returns value at the given index without checks.

    Returns value at the given index without checks.

    Attributes
    protected
  13. abstract def replaceFromArray(index: Int, sourceIndex: Int, replaceLength: Int, sourceArray: Array[T]): Buffer.this.type

    Permalink

    Replaces current values in the range [index, index + replaceLength) with values of the array range [sourceIndex, sourceIndex + replaceLength).

  14. abstract def replaceFromSlice(index: Int, slice: Slice[T]): Buffer.this.type

    Permalink

    Replaces current values in the range [index, index + slice.length) with values of the slice.

  15. abstract def shiftLeft(index: Int, distance: Int): Buffer.this.type

    Permalink

    Moves values in [index, length) left to [index-distance, length - distance).

    Moves values in [index, length) left to [index-distance, length - distance). Effectively removes range (index-distance, index]. - Ignores negative distance. - Moves topIndex if affected.

  16. abstract def shiftRight(index: Int, distance: Int): Buffer.this.type

    Permalink

    Moves values in [index, length) right to [index+distance, length + distance).

    Moves values in [index, length) right to [index+distance, length + distance). Effectively creates a new range [index, index+distance). - Ignores negative distance. - Does not clear existing values inside [index, index+distance). - Moves topIndex if affected.

  17. abstract def slice(from: Int, to: Int): Slice[T]

    Permalink

    Takes range and returns a Slice.

  18. abstract def swapRange(first: Int, second: Int, swapLength: Int): Buffer.this.type

    Permalink

    Swap values in range [first, first + swapLength) with values in range [second, second + swapLength) - Does nothing if any index falls outside [0,length) or if indexes are equal.

    Swap values in range [first, first + swapLength) with values in range [second, second + swapLength) - Does nothing if any index falls outside [0,length) or if indexes are equal.

    • if [first, first + swapLength) overlaps with [second, second + swapLength) then the later overwrites the former.
  19. abstract def toArray[T1 >: T](implicit arg0: ClassTag[T1]): Array[T1]

    Permalink

    Returns a trimmed copy of an underlying array.

  20. abstract def update(index: Int, value: T): Buffer.this.type

    Permalink

    Updates value at the provided index.

    Updates value at the provided index.

    Exceptions thrown

    IndexOutOfBoundsException if index lower than zero.

  21. abstract def write(index: Int, value: T): Unit

    Permalink

    Stores value at the given index without checks.

    Stores value at the given index without checks.

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def andThen[A](g: (T) ⇒ A): (Int) ⇒ A

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. final def append(value: T): Buffer.this.type

    Permalink

    Appends value at the end of the buffer and advances topIndex.

    Appends value at the end of the buffer and advances topIndex.

    Annotations
    @inline()
  6. final def appendArray(values: Array[T]): Buffer.this.type

    Permalink

    Appends values from the given array at the end of the buffer and advances topIndex.

    Appends values from the given array at the end of the buffer and advances topIndex.

    Annotations
    @inline()
  7. final def appendFromIterator(numberOfValues: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Appends number of values from the given iterator at the end of the buffer and advances topIndex.

    Appends number of values from the given iterator at the end of the buffer and advances topIndex.

    Annotations
    @inline()
  8. final def appendFromIterator(iterator: Iterator[T]): Buffer.this.type

    Permalink

    Appends values from the given iterator at the end of the buffer and advances topIndex.

  9. final def appendIterable(iterable: Iterable[T]): Buffer.this.type

    Permalink

    Appends values from the given iterable at the end of the buffer and advances topIndex.

    Appends values from the given iterable at the end of the buffer and advances topIndex.

    Annotations
    @inline()
  10. final def appendSequence(values: IndexedSeq[T]): Buffer.this.type

    Permalink

    Appends values from the given sequence at the end of the buffer and advances topIndex.

    Appends values from the given sequence at the end of the buffer and advances topIndex.

    Annotations
    @inline()
  11. final def appendSlice(slice: Slice[T]): Buffer.this.type

    Permalink

    Appends values from the given slice at the end of the buffer and advances topIndex.

    Appends values from the given slice at the end of the buffer and advances topIndex.

    Annotations
    @inline()
  12. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  13. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. def compose[A](g: (A) ⇒ Int): (A) ⇒ T

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  15. final def contains(value: T): Boolean

    Permalink

    Returns true if buffer contains given value.

  16. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def exists(pred: (T) ⇒ Boolean): Boolean

    Permalink

    Returns true if buffer contains value fulfilling the predicate.

  19. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. final def forward(distance: Int): Buffer.this.type

    Permalink

    Moves topIndex value right by the distance.

  21. final def get(index: Int): Option[T]

    Permalink

    Returns Some value at the index, or None if index outside of range.

    Returns Some value at the index, or None if index outside of range.

    Annotations
    @inline()
  22. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def head: T

    Permalink

    Returns value at the topIndex.

    Returns value at the topIndex.

    Annotations
    @inline()
  25. final def headOption: Option[T]

    Permalink

    Returns Some value at the topIndex or None if empty buffer.

    Returns Some value at the topIndex or None if empty buffer.

    Annotations
    @inline()
  26. final def init: Buffer.this.type

    Permalink

    Returns this buffer without a first element.

    Returns this buffer without a first element.

    Annotations
    @inline()
  27. final def insert(index: Int, value: T): Buffer.this.type

    Permalink

    Shifts content in [index, length) one step to the right and updates value at index.

  28. final def insertFromIterator(index: Int, numberOfValues: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Shift current content to the right starting from indexat the min(iterator.length, insertLength) distance, and inserts iterated values into the gap.

    Shift current content to the right starting from indexat the min(iterator.length, insertLength) distance, and inserts iterated values into the gap. - Sets topIndex to be at least at the end of the new chunk of values.

  29. final def insertFromIterator(index: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Inserts iterated values into the gap made by shiftjng buffer right, starting from the index.

    Inserts iterated values into the gap made by shiftjng buffer right, starting from the index. - Sets topIndex to be at least at the end of the new chunk of values.

  30. final def insertFromIteratorReverse(index: Int, numberOfValues: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Shift current content to the right starting from indexat the min(iterator.length, insertLength) distance, and inserts iterated values into the gap in the reverse order.

    Shift current content to the right starting from indexat the min(iterator.length, insertLength) distance, and inserts iterated values into the gap in the reverse order. - Sets topIndex to be at least at the end of the new chunk of values.

  31. final def insertFromIteratorReverse(index: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Inserts iterated values, in the reverse order, into the gap made by shiftjng buffer right, starting from the index.

    Inserts iterated values, in the reverse order, into the gap made by shiftjng buffer right, starting from the index. - Sets topIndex to be at least at the end of the new chunk of values.

  32. final def insertValues(index: Int, sourceIndex: Int, numberOfValues: Int, source: (Int) ⇒ T): Buffer.this.type

    Permalink

    Shift current content to the right starting from indexat the insertLength distance, iterates over the source indexes and copies values into the gap.

    Shift current content to the right starting from indexat the insertLength distance, iterates over the source indexes and copies values into the gap. - Sets topIndex to be at least at the end of the new chunk of values.

  33. final def isEmpty: Boolean

    Permalink

    Is the accessible part of the buffer empty?

    Is the accessible part of the buffer empty?

    Annotations
    @inline()
  34. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  35. final def iterator: Iterator[T]

    Permalink

    Returns an iterator over actual buffer values, starting from the zero index up.

    Returns an iterator over actual buffer values, starting from the zero index up.

    Note

    does not copy buffer values,

  36. final def last: T

    Permalink

    Returns value at the zero index.

    Returns value at the zero index.

    Annotations
    @inline()
  37. final def lastOption: Option[T]

    Permalink

    Returns Some value at the zero index, or None if empty buffer.

    Returns Some value at the zero index, or None if empty buffer.

    Annotations
    @inline()
  38. final def length: Int

    Permalink

    Length of the accessible part of the buffer.

    Length of the accessible part of the buffer.

    Annotations
    @inline()
  39. final def map[K](f: (T) ⇒ K): Iterable[K]

    Permalink

    Iterable representing lazily mapped values of this buffer at the time of access.

    Iterable representing lazily mapped values of this buffer at the time of access.

    f

    map function

    Annotations
    @inline()
  40. final def mapInPlace(f: (T) ⇒ T): Buffer.this.type

    Permalink

    Updates in-place all values in the range [0,length) using the function.

    Updates in-place all values in the range [0,length) using the function.

    f

    map function

    Annotations
    @inline()
  41. final def modify(index: Int, map: (T) ⇒ T): Buffer.this.type

    Permalink

    Updates value at the provided index using the function.

    Updates value at the provided index using the function. Index must fall within range [0,length).

    index

    value's index

    map

    map function

    Exceptions thrown

    IndexOutOfBoundsException if index lower than zero.

  42. final def modifyAll(map: (T) ⇒ T): Buffer.this.type

    Permalink

    Updates all values in the range [0,length) using the function.

    Updates all values in the range [0,length) using the function.

    map

    map function

  43. final def modifyAllWhen(map: (T) ⇒ T, pred: (T) ⇒ Boolean): Buffer.this.type

    Permalink

    Updates all accepted values in the range [0,length) using the function.

    Updates all accepted values in the range [0,length) using the function.

    map

    map function

    pred

    filter function

  44. final def modifyRange(fromIndex: Int, toIndex: Int, map: (T) ⇒ T): Buffer.this.type

    Permalink

    Updates values in the range [startIndex,toIndex)^^[0,length) using the function. One of {startIndex,toIndex} must fall within range [0,length).

    Updates values in the range [startIndex,toIndex)^^[0,length) using the function. One of {startIndex,toIndex} must fall within range [0,length).

    fromIndex

    index of the first value inclusive

    toIndex

    index of the last value exclusive

    map

    map function

    Exceptions thrown

    IndexOutOfBoundsException if index lower than zero.

  45. final def modifyRangeWhen(fromIndex: Int, toIndex: Int, map: (T) ⇒ T, pred: (T) ⇒ Boolean): Buffer.this.type

    Permalink

    Updates values in the range [startIndex,toIndex)^^[0,length) using the function. One of {startIndex,toIndex} must fall within range [0,length).

    Updates values in the range [startIndex,toIndex)^^[0,length) using the function. One of {startIndex,toIndex} must fall within range [0,length).

    fromIndex

    index of the first value inclusive

    toIndex

    index of the last value exclusive

    map

    map function

    pred

    filter function

    Exceptions thrown

    IndexOutOfBoundsException if index lower than zero.

  46. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  47. final def nonEmpty: Boolean

    Permalink

    Is the accessible part of the buffer non empty?

    Is the accessible part of the buffer non empty?

    Annotations
    @inline()
  48. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  49. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  50. final def peek(offset: Int): T

    Permalink

    Returns value at the topIndex - offset.

    Returns value at the topIndex - offset.

    Annotations
    @inline()
  51. final def peek: T

    Permalink

    Returns value at the topIndex.

    Returns value at the topIndex.

    Annotations
    @inline()
  52. final def peekOption(offset: Int): Option[T]

    Permalink

    Returns value at the topIndex - offset.

    Returns value at the topIndex - offset.

    Annotations
    @inline()
  53. final def pop: T

    Permalink

    Returns value at the topIndex, and moves topIndex back.

  54. final def push(value: T): Buffer.this.type

    Permalink

    Appends value to the topIndex.

    Appends value to the topIndex. Same as append

    Annotations
    @inline()
  55. final def remove(index: Int): Buffer.this.type

    Permalink

    Removes value at index and shifts content in [index+1, length) to the left.

    Removes value at index and shifts content in [index+1, length) to the left.

    Annotations
    @inline()
  56. final def removeRange(fromIndex: Int, toIndex: Int): Buffer.this.type

    Permalink

    Removes values in the range [fromIndex, toIndex) and shifts content in [toIndex, length) to the left.

    Removes values in the range [fromIndex, toIndex) and shifts content in [toIndex, length) to the left.

    Annotations
    @inline()
  57. final def removeWhen(pred: (T) ⇒ Boolean): Buffer.this.type

    Permalink

    Removes values matching the predicate.

    Removes values matching the predicate.

    Annotations
    @inline()
  58. final def replaceFromIterator(index: Int, numberOfValues: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Replaces current values in the range [index, index + min(iterator.length, replaceLength) ) with values returned from the iterator.

  59. final def replaceFromIteratorReverse(index: Int, numberOfValues: Int, iterator: Iterator[T]): Buffer.this.type

    Permalink

    Replaces current values in the range [index, index + min(iterator.length, replaceLength)) with values returned from the iterator in the reverse order.

  60. final def replaceValues(index: Int, sourceIndex: Int, numberOfValues: Int, source: (Int) ⇒ T): Buffer.this.type

    Permalink

    Replaces current values in the range [index, index + replaceLength) with values returned by the function when iterating argument in the range [sourceIndex, sourceIndex + replaceLength).

  61. final def reset: Int

    Permalink

    Resets buffer, sets topIndex to -1.

    Resets buffer, sets topIndex to -1. - Does not clear existing values.

    returns

    previous topIndex

  62. final def reverseIterator: Iterator[T]

    Permalink

    Returns a reverse iterator over actual buffer values, starting from the topIndex down.

  63. final def rewind(distance: Int): Buffer.this.type

    Permalink

    Moves topIndex value left by the distance.

  64. final def set(index: Int): Buffer.this.type

    Permalink

    Sets topIndex value.

  65. final def store(value: T): Buffer.this.type

    Permalink

    Replace value at the topIndex.

  66. final def swap(first: Int, second: Int): Buffer.this.type

    Permalink

    Swap two values at the provided indexes.

    Swap two values at the provided indexes. Value at first becomes value at second, and vice versa. - Does nothing if any index falls outside [0,length) or if indexes are equal.

  67. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  68. final def tail: Buffer.this.type

    Permalink

    Returns this buffer after decrementing topIndex .

    Returns this buffer after decrementing topIndex .

    Annotations
    @inline()
  69. def toString(): String

    Permalink
    Definition Classes
    Function1 → AnyRef → Any
  70. final def top: Int

    Permalink

    Returns topIndex value.

    Returns topIndex value.

    Annotations
    @inline()
  71. final def touch(index: Int): Buffer.this.type

    Permalink

    Sets topIndex value if lower than index, otherwise keeps existing.

  72. final def trim(size: Int): Buffer.this.type

    Permalink

    Trims the buffer, if needed, to have at most the size.

  73. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  74. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  75. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from (Int) ⇒ T

Inherited from AnyRef

Inherited from Any

Abstract

Export

Internal

Properties

List-like

List like operations, head is the top element

Stack-like

Stack like operations, peek takes the top element

Slice

Append

Insert

Modify

Replace

Remove

Shift

Move

Swap

Limit

Manipulations of the topIndex

Read

Ungrouped