<commit_before>//========================================================================
// EventQueue.cc
//========================================================================

#include "EventQueue.h"
#include <queue>

typedef void (*FuncPtr)( void );

std::queue < FuncPtr > q;

void init()
{
  // http://stackoverflow.com/a/709161
  std::queue < FuncPtr > empty;
  std::swap( q, empty );
}

void enq( FuncPtr func_ptr )
{
  q.push( func_ptr );
}

FuncPtr deq( void )
{
  FuncPtr item = q.front();
  q.pop();
  return item;
}

int len( void )
{
  return q.size();
}<commit_msg>[new_pymtl] impl C++ queue with prealloc'd vector + ptrs<commit_after>//========================================================================
// EventQueue.cc
//========================================================================

#include "EventQueue.h"
#include <vector>
#include <assert.h>
#include <stdio.h>

typedef void (*FuncPtr)( void );

const unsigned int MAX = 1000;

std::vector < FuncPtr > q ( MAX, NULL );
unsigned int head  = 0;
unsigned int tail  = 0;
unsigned int count = 0;

void init()
{
  // http://stackoverflow.com/a/709161
  std::vector < FuncPtr > empty ( MAX, NULL );
  std::swap( q, empty );
  head  = 0;
  tail  = 0;
  count = 0;
}

void enq( FuncPtr func_ptr )
{
  assert( count < MAX );
  q[tail] = func_ptr;
  tail = (tail + 1) % MAX;
  count++;
}

FuncPtr deq( void )
{
  assert( count > 0 );
  FuncPtr item = q[head];
  head = (head + 1) % MAX;
  count--;
  return item;
}

int len( void )
{
  return count;
}
{'fraction_non_alphanumeric': 0.3276762402088773, 'fraction_numerical': 0.016318537859007835, 'mean_word_length': 3.993485342019544, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '6683218', 'n_tokens_mistral': 543, 'n_tokens_neox': 499, 'n_words': 137}