<commit_before>#pragma once

#include <asyncio/common.hpp>
#include <deque>
#include <queue>

BEGIN_ASYNCIO_NAMESPACE;
template <class T> class ExtendedQueue : public std::queue<T> {
public:
  template <class V> bool erase(V &&elem) {
    for (auto i = this->c.begin(); i != this->c.end(); i++) {
      if (*i == elem) {
        this->c.erase(i);
        return true;
      }
    }
    return false;
  }
};
END_ASYNCIO_NAMESPACE;<commit_msg>using a set to avoid O(N^2) complexity in UVAsyncTimerService::processTimer()<commit_after>#pragma once

#include <asyncio/common.hpp>
#include <deque>
#include <exception>
#include <queue>
#include <unordered_set>

BEGIN_ASYNCIO_NAMESPACE;
template <class T> class ExtendedQueue : public std::queue<T> {
public: // optimized me when needed
  template <class V> bool erase(V &&elem) {
    if (_set.erase(elem) == 0) {
      return false;
    }
    for (auto i = this->c.begin(); i != this->c.end(); i++) {
      if (*i == elem) {
        this->c.erase(i);
        break;
      }
    }
    return true;
  }

  template <class V> void push(V &&v) {
    auto pair = _set.insert(v);
    if (pair.second) {
      std::queue<T>::push(v);
    } else {
      throw std::logic_error("duplicate elements detected!");
    }
  }

  void pop() {
    _set.erase(this->front());
    std::queue<T>::pop();
  }

private:
  std::unordered_set<T> _set;
};
END_ASYNCIO_NAMESPACE;
{'fraction_non_alphanumeric': 0.16642857142857143, 'fraction_numerical': 0.0014285714285714286, 'mean_word_length': 3.169642857142857, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 28, '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': '101640', 'n_tokens_mistral': 512, 'n_tokens_neox': 507, 'n_words': 121}