<commit_before>﻿// Copyright (C) 2008, by <NAME>
// All Rights Reserved.

using System.Collections.Generic;
using System;

namespace Bend
{
    // ----- aggregate interface for scannable dictionaries 
    
    // TODO: consider how this will need to be reworked to efficiently handle 
    //   next/prev on prefix-compressed data

    public interface IScanner<K>
    {
        bool MatchTo(K candidate);
        IComparable<K> genLowestKeyTest();
        IComparable<K> genHighestKeyTest();
    }
    public interface IScannable<K, V>
    {
        KeyValuePair<K, V> FindNext(IComparable<K> keytest);
        KeyValuePair<K, V> FindPrev(IComparable<K> keytest);
        IEnumerable<KeyValuePair<K, V>> scanForward(IScanner<K> scanner);
        IEnumerable<KeyValuePair<K, V>> scanBackward(IScanner<K> scanner);
    }
    public interface IScannableDictionary<K, V> : IDictionary<K, V>, IScannable<K, V> { }

    class ScanRange<K> : IScanner<K> where K : IComparable<K>
    {
        K lowkey, highkey;
        IComparable<K> matchtest;
        bool scan_all = false;
        public ScanRange(K lowkey, K highkey, IComparable<K> matchtest) { // scan between low and high key
            this.lowkey = lowkey;
            this.highkey = highkey;
            this.matchtest = matchtest;
        }

        public ScanRange(IComparable<K> matchtest) { // scan all
            this.lowkey = default(K);
            this.highkey = default(K);
            scan_all = true;
        }
        public bool MatchTo(K value) {
            return true;
        }
        public class maxKey : IComparable<K>
        {
            public int CompareTo(K val) {
                return 1;
            }
        }
        public class minKey : IComparable<K>
        {
            public int CompareTo(K val) {
                return -1;
            }
        }<commit_msg>switch ScanRange to all IComparable<commit_after>﻿// Copyright (C) 2008, by <NAME>
// All Rights Reserved.

using System.Collections.Generic;
using System;

namespace Bend
{
    // ----- aggregate interface for scannable dictionaries 
    
    // TODO: consider how this will need to be reworked to efficiently handle 
    //   next/prev on prefix-compressed data

    public interface IScanner<K>
    {
        bool MatchTo(K candidate);
        IComparable<K> genLowestKeyTest();
        IComparable<K> genHighestKeyTest();
    }
    public interface IScannable<K, V>
    {
        KeyValuePair<K, V> FindNext(IComparable<K> keytest);
        KeyValuePair<K, V> FindPrev(IComparable<K> keytest);
        IEnumerable<KeyValuePair<K, V>> scanForward(IScanner<K> scanner);
        IEnumerable<KeyValuePair<K, V>> scanBackward(IScanner<K> scanner);
    }
    public interface IScannableDictionary<K, V> : IDictionary<K, V>, IScannable<K, V> { }

    class ScanRange<K> : IScanner<K> 
    {
        IComparable<K> lowkey, highkey;
        IComparable<K> matchtest;
        bool scan_all = false;
        public ScanRange(IComparable<K> lowkey, IComparable<K> highkey, IComparable<K> matchtest) { // scan between low and high key
            this.lowkey = lowkey;
            this.highkey = highkey;
            this.matchtest = matchtest;
        }

        public ScanRange(IComparable<K> matchtest) { // scan all
            this.lowkey = new minKey();
            this.highkey = new maxKey();
            scan_all = true;
        }
        public bool MatchTo(K value) {
            return true;
        }
        public class maxKey : IComparable<K>
        {
            public int CompareTo(K val) {
                return 1;
            }
        }
        public class minKey : IComparable<K>
        {
            public int CompareTo(K val) {
                return -1;
            }
        }
{'fraction_non_alphanumeric': 0.09922851822293163, 'fraction_numerical': 0.0031923383878691143, 'mean_word_length': 2.042071197411003, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, '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': '7619609', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1126, 'n_words': 291}