<commit_before>package basiclist

import (
	"fmt"
	"errors"
)

type DoubleBasicList struct {
	head *DoubleBasicNode
}

//NewBasicList : Init structure for basic Sorted Doubly Linked List.
func NewDoubleBasicList() *DoubleBasicList {
	var empty interface{}
	return &DoubleBasicList{head: NewDoubleBasicNode(0, empty)}
}

func (b *DoubleBasicList) Head() *DoubleBasicNode {
	return b.head
}

func (b *DoubleBasicList) Tail() *DoubleBasicNode {
	return b.Head().Previous()
}

func (b *DoubleBasicList) Insert(key uint, value interface{}) error {

	newNode := NewDoubleBasicNode(key, value)

	if b.head == nil {
		return errors.New("insert failed due to unexpected state")
	} else if b.Tail() == nil { /* First Inserted Node */
		newNode.prev = b.Head()
		b.Head().next = newNode
		b.Head().prev = newNode
	} else if newNode.Key() >= b.Tail().Key() { /* Largest new tail    */
		newNode.prev = b.Tail()
		// order of operations matters here
		b.Tail().next = newNode
		b.Head().prev = newNode
	} else {
		current := b.Head()
		previous := b.Tail()

		for {
			if newNode.Key() < current.Key() {
				newNode.next = current
				newNode.prev = previous
				previous.next = newNode
				current.prev = newNode
				break
			} else {
				if current.HasNext() {
					previous = current
					current = current.Next()
				} else {
					return errors.New("insert failed due to unexpected state")
				}
			}
		}
	}

	return nil
}

func (b *DoubleBasicList) Index(index int) (interface{}, error) {
	currentNode := b.head

	for i := 0; i < index; i++ {
		if !currentNode.HasNext() {
			return nil, errors.New("index not found")
		}

		currentNode = currentNode.Next()
	}

	return currentNode, nil

}

func (b *DoubleBasicList) Search(key uint) (interface{}, error) {
	currentNode := b.head
	for {
		if currentNode.key == key {
			return currentNode.val, nil
		}

		if !currentNode.HasNext() {
			break<commit_msg>return node type<commit_after>package basiclist

import (
	"fmt"
	"errors"
)

type DoubleBasicList struct {
	head *DoubleBasicNode
}

//NewBasicList : Init structure for basic Sorted Doubly Linked List.
func NewDoubleBasicList() *DoubleBasicList {
	var empty interface{}
	return &DoubleBasicList{head: NewDoubleBasicNode(0, empty)}
}

func (b *DoubleBasicList) Head() *DoubleBasicNode {
	return b.head
}

func (b *DoubleBasicList) Tail() *DoubleBasicNode {
	return b.Head().Previous()
}

func (b *DoubleBasicList) Insert(key uint, value interface{}) error {

	newNode := NewDoubleBasicNode(key, value)

	if b.head == nil {
		return errors.New("insert failed due to unexpected state")
	} else if b.Tail() == nil { /* First Inserted Node */
		newNode.prev = b.Head()
		b.Head().next = newNode
		b.Head().prev = newNode
	} else if newNode.Key() >= b.Tail().Key() { /* Largest new tail    */
		newNode.prev = b.Tail()
		// order of operations matters here
		b.Tail().next = newNode
		b.Head().prev = newNode
	} else {
		current := b.Head()
		previous := b.Tail()

		for {
			if newNode.Key() < current.Key() {
				newNode.next = current
				newNode.prev = previous
				previous.next = newNode
				current.prev = newNode
				break
			} else {
				if current.HasNext() {
					previous = current
					current = current.Next()
				} else {
					return errors.New("insert failed due to unexpected state")
				}
			}
		}
	}

	return nil
}

func (b *DoubleBasicList) Index(index int) (*DoubleBasicNode, error) {
	currentNode := b.head

	for i := 0; i < index; i++ {
		if !currentNode.HasNext() {
			return nil, errors.New("index not found")
		}

		currentNode = currentNode.Next()
	}

	return currentNode, nil

}

func (b *DoubleBasicList) Search(key uint) (interface{}, error) {
	currentNode := b.head
	for {
		if currentNode.key == key {
			return currentNode.val, nil
		}

		if !currentNode.HasNext() {
			break
{'fraction_non_alphanumeric': 0.1345444971037388, 'fraction_numerical': 0.00105318588730911, 'mean_word_length': 3.3318129988597494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2531866', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1266, 'n_words': 353}