<commit_before>package sortedmap

import (
	"errors"
	"sort"
)

func (sm *SortedMap) delete(key interface{}) bool {
	if val, ok := sm.idx[key]; ok {

		smLen := len(sm.sorted)
		i := sort.Search(smLen, func(i int) bool {
			return sm.lessFn(val, sm.idx[sm.sorted[i]])
		})

		if i == smLen {
			i--
		} else if i < smLen-1 {
			i++
		}
		for sm.sorted[i] != key {
			i--
		}

		delete(sm.idx, key)
		sm.sorted = deleteInterface(sm.sorted, i)

		return true
	}
	return false
}

func (sm *SortedMap) boundedDelete(lowerBound, upperBound interface{}) error {
	iterBounds := sm.boundsIdxSearch(lowerBound, upperBound)
	if iterBounds == nil {
		return errors.New(noValuesErr)
	}
	for i := iterBounds[0]; i <= iterBounds[1]-i; i++ {
		delete(sm.idx, sm.sorted[i])
		sm.sorted = deleteInterface(sm.sorted, i)
	}<commit_msg>Fixed BoundedDelete counter<commit_after>package sortedmap

import (
	"errors"
	"sort"
)

func (sm *SortedMap) delete(key interface{}) bool {
	if val, ok := sm.idx[key]; ok {

		smLen := len(sm.sorted)
		i := sort.Search(smLen, func(i int) bool {
			return sm.lessFn(val, sm.idx[sm.sorted[i]])
		})

		if i == smLen {
			i--
		} else if i < smLen-1 {
			i++
		}
		for sm.sorted[i] != key {
			i--
		}

		delete(sm.idx, key)
		sm.sorted = deleteInterface(sm.sorted, i)

		return true
	}
	return false
}

func (sm *SortedMap) boundedDelete(lowerBound, upperBound interface{}) error {
	iterBounds := sm.boundsIdxSearch(lowerBound, upperBound)
	if iterBounds == nil {
		return errors.New(noValuesErr)
	}
	for i, deleted := iterBounds[0], 0; i <= iterBounds[1]-deleted; i++ {
		delete(sm.idx, sm.sorted[i])
		sm.sorted = deleteInterface(sm.sorted, i)
		deleted++
	}
{'fraction_non_alphanumeric': 0.1610978520286396, 'fraction_numerical': 0.004176610978520286, 'mean_word_length': 3.483957219251337, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6011162', 'n_tokens_mistral': 714, 'n_tokens_neox': 659, 'n_words': 153}