Rules / Types, classes & roles / composite

IterationBuffer Reference

Low level storage of positional values

What it is #

class needs a lightweight way to store/transmit values.  It doesn't make

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method push #

method push(IterationBuffer:D: Mu \value)

Adds the given value at the end of the IterationBuffer and returns the given value.

method unshift #

method unshift(IterationBuffer:D: Mu \value)

Adds the given value at the beginning of the IterationBuffer and returns the given value. Available as of the 2021.12 release of the Rakudo compiler.

method append #

method append(IterationBuffer:D: IterationBuffer:D $other --> IterationBuffer:D)

Returns IterationBuffer:D.

Adds the contents of the other IterationBuffer at the end of the IterationBuffer, and returns the updated invocant.

method prepend #

method prepend(IterationBuffer:D: IterationBuffer:D $other --> IterationBuffer:D)

Returns IterationBuffer:D.

Adds the contents of the other IterationBuffer at the beginning of the IterationBuffer, and returns the updated invocant. Available as of the 2021.12 release of the Rakudo compiler.

method clear #

method clear(IterationBuffer:D: --> Nil)

Returns Nil.

Resets the number of elements in the IterationBuffer to zero, effectively removing all data from it, and returns Nil.

method elems #

method elems(IterationBuffer:D: --> Int:D)

Returns Int:D.

Returns the number of elements in the IterationBuffer.

method AT-POS #

multi method AT-POS(IterationBuffer:D: int   $pos)
multi method AT-POS(IterationBuffer:D: Int:D $pos)

Returns the value at the given element position, or Mu if the element position is beyond the length of the IterationBuffer, or an error will be thrown indicating the index is out of bounds (for negative position values).

method BIND-POS #

multi method BIND-POS(IterationBuffer:D: int   $pos, Mu \value)
multi method BIND-POS(IterationBuffer:D: Int:D $pos, Mu \value)

Binds the given value at the given element position and returns it. The IterationBuffer is automatically lengthened if the given element position is beyond the length of the IterationBuffer. An error indicating the index is out of bounds will be thrown for negative position values.

method Slip #

method Slip(IterationBuffer:D: --> Slip:D)

Returns Slip:D.

Coerces the IterationBuffer to a Slip.

method List #

method List(IterationBuffer:D: --> List:D)

Returns List:D.

Coerces the IterationBuffer to a List.

method Seq #

method Seq(IterationBuffer:D: --> Seq:D)

Returns Seq:D.

Coerces the IterationBuffer to a Seq.

method raku #

method raku(IterationBuffer:D: --> Str)

Returns Str.

Produces a representation of the IterationBuffer as a List postfixed with ".IterationBuffer" to make it different from an ordinary list. Does not roundtrip. Intended for debugging uses only, specifically for use with dd.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

1 no-output

my class IterationBuffer { }

Not executed: the documentation states no expected output for this example.