<commit_before><commit_msg>adds List<commit_after><?php

namespace Chevron\Containers;
/**
 * implementation of a list --  a hybrid of a queue and a stack using redis-like
 * methods of left/right push/pop
 *
 * @package Chevron\Container
 */
class List implements \Countable, \IteratorAggregate {

	/**
	 * hold our values internally
	 */
	protected $map = array();

	/**
	 * unshift values to our list
	 * @param mixed $value
	 */
	function lpush($value){
		array_unshift($this->map, $value);
	}

	/**
	 * push values to our list
	 * @param mixed $value
	 */
	function rpush($value){
		// array_push
		$this->map[] = $value;
	}

	/**
	 * shift values off our list
	 * @return mixed
	 */
	function lpop(){
		if($this->length() <= 0) return null;
		return array_shift($this->map);
	}

	/**
	 * pop values off our array
	 * @return mixed
	 */
	function rpop(){
		if($this->length() <= 0) return null;
		return array_pop($this->map);
	}

	/**
	 * \Countable -- how big is our list
	 * @return int
	 */
	function count(){
		return count($this->map);
	}

	/**
	 * spin off an iterator for our list
	 * @return \ArrayIterator
	 */
	function getIterator(){
		return new \ArrayIterator($this->map);
	}

	/**
	 * spin off a generator for our list
	 * @yield \Generator
	 */
	function range($rev = false){
		$map = $rev ? array_reverse($this->map) : $this->map;
		foreach($map as $value){
			yield $value;
		}
	}

}





{'fraction_non_alphanumeric': 0.1573352232459249, 'fraction_numerical': 0.001417434443656981, 'mean_word_length': 2.9441340782122905, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 13, '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': '1943082', 'n_tokens_mistral': 511, 'n_tokens_neox': 456, 'n_words': 138}