<commit_before>// Copyright 2014, The Project fn Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

#ifndef FUNC_RANGE_INL_H_
#define FUNC_RANGE_INL_H_

#include <algorithm>

namespace fn {

template <typename T>
Range<T>::Range(T from, T to, int step) : from_(from), to_(to), step_(step) {}

template <typename T>
typename Range<T>::Iterator Range<T>::begin() const {
  return Iterator(this, from_);
}

template <typename T>
typename Range<T>::Iterator Range<T>::end() const {
  if (empty()) {
    return Iterator(this, from_);
  }

  return Iterator(this, to_);
}

template <typename T>
bool Range<T>::empty() const {
  if (step_ > 0 && to_ < from_) {
    return true;
  }

  if (step_ < 0 && to_ > from_) {
    return true;
  }

  return from_ == to_;
}

template <typename T>
size_t Range<T>::size() const {
  if (step_ > 0 && to_ < from_) {
    return 0;
  }

  if (step_ < 0 && to_ > from_) {
    return 0;
  }

  return std::abs((from_ - to_) / step_);
}

template <typename T>
Range<T>::Iterator::Iterator(const Range<T>* range, T val)
    : range_(range), val_(val) {}

template <typename T>
typename Range<T>::Iterator& Range<T>::Iterator::operator++() {
  if (range_->step_ > 0) {
    val_ = std::min(range_->to_, val_ + range_->step_);
  } else {
    val_ = std::max(range_->to_, val_ + range_->step_);
  }
  return *this;
}

template <typename T><commit_msg>Fixes a compatablility bug with libc++.<commit_after>// Copyright 2014, The Project fn Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

#ifndef FUNC_RANGE_INL_H_
#define FUNC_RANGE_INL_H_

#include <algorithm>

namespace fn {

template <typename T>
Range<T>::Range(T from, T to, int step) : from_(from), to_(to), step_(step) {}

template <typename T>
typename Range<T>::Iterator Range<T>::begin() const {
  return Iterator(this, from_);
}

template <typename T>
typename Range<T>::Iterator Range<T>::end() const {
  if (empty()) {
    return Iterator(this, from_);
  }

  return Iterator(this, to_);
}

template <typename T>
bool Range<T>::empty() const {
  if (step_ > 0 && to_ < from_) {
    return true;
  }

  if (step_ < 0 && to_ > from_) {
    return true;
  }

  return from_ == to_;
}

template <typename T>
size_t Range<T>::size() const {
  if (step_ > 0 && to_ < from_) {
    return 0;
  }

  if (step_ < 0 && to_ > from_) {
    return 0;
  }

  auto s = (to_ - from_) / step_;
  return s >= 0 ? s : -s;
}

template <typename T>
Range<T>::Iterator::Iterator(const Range<T>* range, T val)
    : range_(range), val_(val) {}

template <typename T>
typename Range<T>::Iterator& Range<T>::Iterator::operator++() {
  if (range_->step_ > 0) {
    val_ = std::min(range_->to_, val_ + range_->step_);
  } else {
    val_ = std::max(range_->to_, val_ + range_->step_);
  }
  return *this;
}

template <typename T>
{'fraction_non_alphanumeric': 0.14389233954451347, 'fraction_numerical': 0.008022774327122154, 'mean_word_length': 3.6121718377088308, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6849864', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1243, 'n_words': 436}