ListNode [Src] [A: A]

A node in a list.

class ref ListNode[A: A]

Constructors

create [Src]

new ref create(
  item: (A | None val) = seq)
: ListNode[A] ref^

Parameters

  • item: (A | None val) = seq

Returns


Public Functions

apply [Src]

Return the item, if we have one, otherwise raise an error.

fun box apply()
: this->A ?

Returns

  • this->A ?

update [Src]

Replace the item and return the previous one. Raise an error if we have no previous value.

fun ref update(
  value: (A | None val))
: A^ ?

Parameters

  • value: (A | None val)

Returns

  • A^ ?

pop [Src]

Remove the item from the node, if we have one, otherwise raise an error.

fun ref pop()
: A^ ?

Returns

  • A^ ?

prepend [Src]

Prepend a node to this one. If that is already in a list, it is removed before it is prepended. Returns true if that was removed from another list.

fun ref prepend(
  that: ListNode[A] ref)
: Bool val

Parameters

Returns


append [Src]

Append a node to this one. If that is already in a list, it is removed before it is appended. Returns true if that was removed from another list.

fun ref append(
  that: ListNode[A] ref)
: Bool val

Parameters

Returns


remove [Src]

Remove a node from a list.

fun ref remove()
: None val

Returns


has_prev [Src]

Return true if there is a previous node.

fun box has_prev()
: Bool val

Returns


has_next [Src]

Return true if there is a next node.

fun box has_next()
: Bool val

Returns


prev [Src]

Return the previous node.

fun box prev()
: (this->ListNode[A] ref | None val)

Returns


next [Src]

Return the next node.

fun box next()
: (this->ListNode[A] ref | None val)

Returns