...

Source file src/cmd/compile/internal/ssa/testdata/pushback.go

Documentation: cmd/compile/internal/ssa/testdata

     1  package main
     2  
     3  type Node struct {
     4  	Circular bool
     5  }
     6  
     7  type ExtNode[V any] struct {
     8  	v V
     9  	Node
    10  }
    11  
    12  type List[V any] struct {
    13  	root *ExtNode[V]
    14  	len  int
    15  }
    16  
    17  func (list *List[V]) PushBack(arg V) {
    18  	if list.len == 0 {
    19  		list.root = &ExtNode[V]{v: arg}
    20  		list.root.Circular = true
    21  		list.len++
    22  		return
    23  	}
    24  	list.len++
    25  }
    26  
    27  func main() {
    28  	var v List[int]
    29  	v.PushBack(1)
    30  }
    31  

View as plain text