<commit_before>package triangulations;
/*
Queue.hx

A function to represent a queue ported to Haxe

Origitally created by <NAME> - http://code.stephenmorley.org/ - and released under
the terms of the CC0 1.0 Universal legal code:

http://creativecommons.org/publicdomain/zero/1.0/legalcode

*/

//Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -
//items are added to the end of the queue and removed from the front.
class Queue<T> {
    // initialise the queue and offset
    public var queue  = [];
    public var offset = 0;
    
    public function new(){
        queue = new Array<T>();
    }
    // Returns the length of the queue.
    function getLength():Int{
        return ( queue.length - offset );
    }

    // Returns true if the queue is empty, and false otherwise.
    public inline function isEmpty(): Bool {
        return ( queue.length == 0) ;
    }

    // Enqueues the specified item. The parameter is:
    // item - the item to enqueue
    public inline function enqueue( item: Null<T> ){
        queue.push( item );
    }

    // Dequeues an item and returns it. If the queue is empty, the value
    // null is returned.
    public inline function dequeue(): Null<T>{
        var item:T = null;
        // if the queue is empty, return immediately
        if( queue.length == 0 ) {
            item = null;
        } else {
            // store the item at the front of the queue
            item = queue[ offset ];
            // increment the offset and remove the free space if necessary
            if (++ offset * 2 >= queue.length){
               queue  = queue.slice( offset );
               offset = 0;
            }
        }
        // trace('dequeue item ' + item + ' offset ' + offset + ' queue ' + queue );
        // return the dequeued item
        return item;
    }

    // Returns the item at the front of the queue (without dequeuing it). If the
    // queue is empty then null is returned.
    public inline function peak(): Null<T> {
      return if( queue.length > 0 ) {
                  queue[ offset ]; 
              }else { 
                  null; 
              };
    }
}
<commit_msg>improve documentation<commit_after>package triangulations;
/**
 * Queue.hx
 * 
 * A function to represent a queue ported to Haxe
 * 
 * Origitally created by <NAME> - http://code.stephenmorley.org/ - and released under
 * the terms of the CC0 1.0 Universal legal code:
 * 
 * http://creativecommons.org/publicdomain/zero/1.0/legalcode
 *
 * Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -
 * items are added to the end of the queue and removed from the front.
 *
 **/
class Queue<T> {
    // initialise the queue and offset
    public var queue  = [];
    public var offset = 0;
    /**
     * constructor initialize the queue with empty array
     **/
    public function new(){
        queue = new Array<T>();
    }
    /**
     * @returns the length of the queue.
     **/
    function getLength():Int{
        return ( queue.length - offset );
    }
    /**
     * @returns true if the queue is empty, and false otherwise.
     **/
    public inline function isEmpty(): Bool {
        return ( queue.length == 0) ;
    }
    /**
     * Enqueues the specified item. The parameter is:
     * item - the item to enqueue
     *
     * @param item
     **/
    public inline function enqueue( item: Null<T> ){
        queue.push( item );
    }
    /**
     * Dequeues an item and returns it. If the queue is empty, the value
     * null is returned.
     **/
    public inline function dequeue(): Null<T>{
        var item:T = null;
        // if the queue is empty, return immediately
        if( queue.length == 0 ) {
            item = null;
        } else {
            // store the item at the front of the queue
            item = queue[ offset ];
            // increment the offset and remove the free space if necessary
            if (++ offset * 2 >= queue.length){
               queue  = queue.slice( offset );
               offset = 0;
            }
        }
        // trace('dequeue item ' + item + ' offset ' + offset + ' queue ' + queue );
        // return the dequeued item
        return item;
    }
    /**
     * Returns the item at the front of the queue (without dequeuing it). If the
     * queue is empty then null is returned.
     * 
     * @return T
     **/
    public inline function peak(): Null<T> {
      return if( queue.length > 0 ) {
                  queue[ offset ]; 
              }else { 
                  null; 
              };
    }
}

{'fraction_non_alphanumeric': 0.10332022717343818, 'fraction_numerical': 0.004805591961555264, 'mean_word_length': 1.758433734939759, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, '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': '3360105', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1253, 'n_words': 492}