func (l *list) IndexOf(v interface{}) (int, bool) {
	i := 0
	for n := l.first; n != nil; n = n.next {
		if n.value == v {
			return i, true
		}
		i++
	}
	return -1, false
}
IndexOf returns the first index of the given value and true, or false if it does not exists
package doublylinkedlist
import (
	"errors"
	List "github.com/zimmski/container/list"
)
type node struct {
	next     *node        
	previous *node        
	value    interface{}  
}
type iterator struct {
	current *node  
}
func (iter *iterator) Next() List.Iterator {
	if iter.current != nil {
		iter.current = iter.current.next
	}
	if iter.current == nil {
		return nil
	}
	return iter
}
func (iter *iterator) Previous() List.Iterator {
	if iter.current != nil {
		iter.current = iter.current.previous
	}
	if iter.current == nil {
		return nil
	}
	return iter
}
func (iter *iterator) Get() interface{} {
	return iter.current.value
}
func (iter *iterator) Set(v interface{}) {
	iter.current.value = v
}
type list struct {
	first *node  
	last  *node  
	len   int    
}
func New() *list {
	l := new(list)
	l.Clear()
	return l
}
func (l *list) Clear() {
	i := l.first
	for i != nil {
		j := i.next
		i.next = nil
		i.previous = nil
		i = j
	}
	l.first = nil
	l.last = nil
	l.len = 0
}
func (l *list) Len() int {
	return l.len
}
func (l *list) Empty() bool {
	return l.len == 0
}
func (l *list) newNode(v interface{}) *node {
	return &node{
		value: v,
	}
}
func (l *list) getNode(i int) (*node, error) {
	if i > -1 && i < l.len {
		j := 0
		for n := l.first; n != nil; n = n.next {
			if i == j {
				return n, nil
			}
			j++
		}
	}
	return nil, errors.New("index bounds out of range")
}
func (l *list) insertNodeBefore(v interface{}, p *node) *node {
	n := l.newNode(v)
	if l.len == 0 {
		l.first = n
		l.last = n
	} else {
		if p == l.first {
			l.first = n
		} else {
			if p.previous != nil {
				p.previous.next = n
				n.previous = p.previous
			}
		}
		n.next = p
		p.previous = n
	}
	l.len++
	return n
}
func (l *list) removeNode(c *node) interface{} {
	if c == nil || l.len == 0 {
		return nil
	}
	if c == l.first {
		l.first = c.next
		if c.next != nil {
			c.next.previous = nil
		}
		if c == l.last {
			l.last = nil
		}
	} else {
		if c.previous != nil {
			c.previous.next = c.next
			if c.next != nil {
				c.next.previous = c.previous
			} else if c == l.last {
				l.last = c.previous
			}
		}
	}
	c.next = nil
	c.previous = nil
	l.len--
	return c.value
}
func (l *list) newIterator(current *node) *iterator {
	return &iterator{
		current: current,
	}
}
func (l *list) Chan(n int) <-chan interface{} {
	ch := make(chan interface{})
	go func() {
		for iter := l.Iter(); iter != nil; iter = iter.Next() {
			ch <- iter.Get()
		}
		close(ch)
	}()
	return ch
}
func (l *list) ChanBack(n int) <-chan interface{} {
	ch := make(chan interface{})
	go func() {
		for iter := l.IterBack(); iter != nil; iter = iter.Previous() {
			ch <- iter.Get()
		}
		close(ch)
	}()
	return ch
}
func (l *list) Iter() List.Iterator {
	if l.len == 0 {
		return nil
	}
	return l.newIterator(l.first)
}
func (l *list) IterBack() List.Iterator {
	if l.len == 0 {
		return nil
	}
	return l.newIterator(l.last)
}
func (l *list) First() (interface{}, bool) {
	if l.len == 0 {
		return nil, false
	}
	return l.first.value, true
}
func (l *list) Last() (interface{}, bool) {
	if l.len == 0 {
		return nil, false
	}
	return l.last.value, true
}
func (l *list) Get(i int) (interface{}, error) {
	n, err := l.getNode(i)
	if err != nil {
		return nil, err
	}
	return n.value, nil
}
func (l *list) GetFunc(m func(v interface{}) bool) (interface{}, bool) {
	for n := l.first; n != nil; n = n.next {
		if m(n.value) {
			return n.value, true
		}
	}
	return nil, false
}
func (l *list) Set(i int, v interface{}) error {
	n, err := l.getNode(i)
	if err != nil {
		return err
	}
	n.value = v
	return nil
}
func (l *list) SetFunc(m func(v interface{}) bool, v interface{}) bool {
	for n := l.first; n != nil; n = n.next {
		if m(n.value) {
			n.value = v
			return true
		}
	}
	return false
}
func (l *list) Swap(i, j int) {
	ni, erri := l.getNode(i)
	nj, errj := l.getNode(j)
	if erri == nil && errj == nil {
		ni.value, nj.value = nj.value, ni.value
	}
}
func (l *list) Contains(v interface{}) bool {
	_, ok := l.IndexOf(v)
	return ok
}