// The front of the list has prev = nil, and the back has next = nil.
next, prev *Element
- // Thie list to which this element belongs.
+ // The list to which this element belongs.
list *List
// The contents of this list element.
}
// New returns an initialized list.
-func New() *List { return new(List).Init() }
+func New() *List { return new(List) }
// Front returns the first element in the list.
func (l *List) Front() *Element { return l.front }
// PushFront inserts the value at the front of the list and returns a new Element containing the value.
func (l *List) PushFront(value interface{}) *Element {
- if l == nil {
- l.Init()
- }
e := &Element{nil, nil, l, value}
l.insertFront(e)
return e
// PushBack inserts the value at the back of the list and returns a new Element containing the value.
func (l *List) PushBack(value interface{}) *Element {
- if l == nil {
- l.Init()
- }
e := &Element{nil, nil, l, value}
l.insertBack(e)
return e