Documentation
¶
Overview ¶
パッケージlistは双方向連結リストを実装します。
リストを反復するには(l は *List):
for e := l.Front(); e != nil; e = e.Next() {
// e.Value を使って何らかの処理を行う
}
Example ¶
package main
import (
"github.com/shogo82148/std/container/list"
"github.com/shogo82148/std/fmt"
)
func main() {
// 新しいリストを作成し、いくつかの数値を入れます。
l := list.New()
e4 := l.PushBack(4)
e1 := l.PushFront(1)
l.InsertBefore(3, e4)
l.InsertAfter(2, e1)
// リストを走査して内容を出力します。
for e := l.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value)
}
}
Output: 1 2 3 4
Index ¶
- type Element
- type List
- func (l *List) Back() *Element
- func (l *List) Front() *Element
- func (l *List) Init() *List
- func (l *List) InsertAfter(v any, mark *Element) *Element
- func (l *List) InsertBefore(v any, mark *Element) *Element
- func (l *List) Len() int
- func (l *List) MoveAfter(e, mark *Element)
- func (l *List) MoveBefore(e, mark *Element)
- func (l *List) MoveToBack(e *Element)
- func (l *List) MoveToFront(e *Element)
- func (l *List) PushBack(v any) *Element
- func (l *List) PushBackList(other *List)
- func (l *List) PushFront(v any) *Element
- func (l *List) PushFrontList(other *List)
- func (l *List) Remove(e *Element) any
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct {
// この要素に格納される値です。
Value any
// contains filtered or unexported fields
}
Elementは連結リストの要素です。
type List ¶
type List struct {
// contains filtered or unexported fields
}
Listは双方向連結リストを表します。 Listのゼロ値は、すぐに使用可能な空のリストです。
func (*List) InsertAfter ¶
InsertAfterは値vを持つ新しい要素eを mark の直後に挿入し、eを返します。 markが l の要素でない場合、リストは変更されません。 markはnilであってはなりません。
func (*List) InsertBefore ¶
InsertBeforeは値vを持つ新しい要素eを mark の直前に挿入し、eを返します。 markが l の要素でない場合、リストは変更されません。 markはnilであってはなりません。
func (*List) MoveAfter ¶ added in v1.2.0
MoveAfterは要素eを mark の後の新しい位置へ移動します。 e または mark が l の要素でない場合、または e == mark の場合、 リストは変更されません。 要素と mark はnilであってはなりません。
func (*List) MoveBefore ¶ added in v1.2.0
MoveBeforeは要素eを mark の前の新しい位置へ移動します。 e または mark が l の要素でない場合、または e == mark の場合、 リストは変更されません。 要素と mark はnilであってはなりません。
func (*List) MoveToBack ¶
MoveToBackは要素eをリストlの末尾へ移動します。 eが l の要素でない場合、リストは変更されません。 要素はnilであってはなりません。
func (*List) MoveToFront ¶
MoveToFrontは要素eをリストlの先頭へ移動します。 eが l の要素でない場合、リストは変更されません。 要素はnilであってはなりません。
func (*List) PushBackList ¶
PushBackListは別のリストのコピーをリストlの末尾に挿入します。 リスト l と other は同一でも構いません。nilであってはなりません。
func (*List) PushFrontList ¶
PushFrontListは別のリストのコピーをリストlの先頭に挿入します。 リスト l と other は同一でも構いません。nilであってはなりません。