<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using JetBrains.Annotations;
using Verse;

namespace PrepareLanding
{
    public class ThreeStateItem : INotifyPropertyChanged
    {
        private MultiCheckboxState _state;

        public ThreeStateItem(MultiCheckboxState defaultSate = MultiCheckboxState.Off)
        {
            _state = defaultSate;
            DefaultState = defaultSate;
        }

        public MultiCheckboxState DefaultState { get; }

        public MultiCheckboxState State
        {
            get { return _state; }
            set
            {
                if (value == _state)
                    return;

                _state = value;
                OnPropertyChanged(nameof(State));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }


    public class UsableMinMaxNumericItem<T> : INotifyPropertyChanged where T : struct
    {
        private T _max;
        private string _maxString;
        private T _min;
        private string _minString;
        private bool _use;

        public bool AllowOnPropertyChangedOnStrings { get; set; }

        public T Min
        {
            get { return _min; }
            set
            {
                if (EqualityComparer<T>.Default.Equals(_min, value))
                    return;

                _min = value;
                OnPropertyChanged(nameof(Min));
            }
        }

        public T Max
        {
            get { return _max; }
            set
            {
                if (EqualityComparer<T>.Default.Equals(_max, value))
                    return;

                _max = value;
                OnPropertyChanged(nameof(Max));
            }
        }

        public bool Use
        {
            get { return _use; }
            set
            {
                if (value == _use)
                    return;

                _use = value;
                OnPropertyChanged(nameof(Use));
            }
        }

        public string MinString
        {
            get { return _minString; }
            set
            {
                if (value == _minString)
                    return;

                _minString = value;

                if (AllowOnPropertyChangedOnStrings)
                    OnPropertyChanged(nameof(MinString));
            }
        }

        public string MaxString
        {
            get { return _maxString; }
            set
            {
                if (value == _maxString)
                    return;

                _maxString = value;

                if (AllowOnPropertyChangedOnStrings)
                    OnPropertyChanged(nameof(MaxString));
            }
        }

        public bool InRange(T value)
        {
            if (!_use)
                return false;

            var lte = Comparer<T>.Default.Compare(_min, value);
            var gte = Comparer<T>.Default.Compare(_max, value);

            return (lte >= 0 && gte <= 0);
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public class MinMaxFromRestrictedListItem<T> : INotifyPropertyChanged where T : struct
    {
        private T _min;
        private T _max;
        private readonly List<T> _options;
        private bool _use;

        public MinMaxFromRestrictedListItem(List<T> options, T min = default(T), T max = default(T))
        {
            _options = options;
            _min = min;<commit_msg>correct comparer (which was wrong)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using JetBrains.Annotations;
using Verse;

namespace PrepareLanding
{
    public class ThreeStateItem : INotifyPropertyChanged
    {
        private MultiCheckboxState _state;

        public ThreeStateItem(MultiCheckboxState defaultSate = MultiCheckboxState.Off)
        {
            _state = defaultSate;
            DefaultState = defaultSate;
        }

        public MultiCheckboxState DefaultState { get; }

        public MultiCheckboxState State
        {
            get { return _state; }
            set
            {
                if (value == _state)
                    return;

                _state = value;
                OnPropertyChanged(nameof(State));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }


    public class UsableMinMaxNumericItem<T> : INotifyPropertyChanged where T : struct
    {
        private T _max;
        private string _maxString;
        private T _min;
        private string _minString;
        private bool _use;

        public bool AllowOnPropertyChangedOnStrings { get; set; }

        public T Min
        {
            get { return _min; }
            set
            {
                if (EqualityComparer<T>.Default.Equals(_min, value))
                    return;

                _min = value;
                OnPropertyChanged(nameof(Min));
            }
        }

        public T Max
        {
            get { return _max; }
            set
            {
                if (EqualityComparer<T>.Default.Equals(_max, value))
                    return;

                _max = value;
                OnPropertyChanged(nameof(Max));
            }
        }

        public bool Use
        {
            get { return _use; }
            set
            {
                if (value == _use)
                    return;

                _use = value;
                OnPropertyChanged(nameof(Use));
            }
        }

        public string MinString
        {
            get { return _minString; }
            set
            {
                if (value == _minString)
                    return;

                _minString = value;

                if (AllowOnPropertyChangedOnStrings)
                    OnPropertyChanged(nameof(MinString));
            }
        }

        public string MaxString
        {
            get { return _maxString; }
            set
            {
                if (value == _maxString)
                    return;

                _maxString = value;

                if (AllowOnPropertyChangedOnStrings)
                    OnPropertyChanged(nameof(MaxString));
            }
        }

        public bool InRange(T value)
        {
            if (!_use)
                return false;

            var lte = Comparer<T>.Default.Compare(value, _min);
            var gte = Comparer<T>.Default.Compare(value, _max);

            return (lte >= 0 && gte <= 0);
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public class MinMaxFromRestrictedListItem<T> : INotifyPropertyChanged where T : struct
    {
        private T _min;
        private T _max;
        private readonly List<T> _options;
        private bool _use;

        public MinMaxFromRestrictedListItem(List<T> options, T min = default(T), T max = default(T))
        {
            _options = options;
            _min = min;
{'fraction_non_alphanumeric': 0.06816752609734625, 'fraction_numerical': 0.0005030813734121495, 'mean_word_length': 1.416286842904892, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '3257389', 'n_tokens_mistral': 2006, 'n_tokens_neox': 1899, 'n_words': 459}