From 525ad4fcc26ee7b41fbb1d87d15a111b8e21505c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Babi=C4=8D?= Date: Wed, 23 Mar 2016 14:34:39 +0100 Subject: [PATCH] Introduce Queue --- .idea/workspace.xml | 230 +++++++++++++++++++++++-------------- src/Coffee/Queue.php | 30 +++++ tests/Coffee/QueueTest.php | 18 +++ 3 files changed, 194 insertions(+), 84 deletions(-) create mode 100644 src/Coffee/Queue.php create mode 100644 tests/Coffee/QueueTest.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7c326ae..973eaba 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,9 @@ + + - - - - - @@ -39,7 +36,7 @@ - + @@ -56,11 +53,11 @@ - + - - + + @@ -69,7 +66,7 @@ - + @@ -79,7 +76,7 @@ - + @@ -89,7 +86,7 @@ - + @@ -99,8 +96,28 @@ - - + + + + + + + + + + + + + + + + + + + + + + @@ -109,8 +126,8 @@ - - + + @@ -168,14 +185,18 @@ @@ -219,10 +240,8 @@ - @@ -326,6 +345,52 @@ - - - - - - @@ -813,9 +873,15 @@ + + + + + + - @@ -827,22 +893,22 @@ - + - - + + @@ -938,26 +1004,10 @@ - - - - - - - - - - - - - - - - @@ -980,7 +1030,6 @@ - @@ -996,7 +1045,6 @@ - @@ -1228,7 +1276,6 @@ - @@ -1239,33 +1286,17 @@ - - - - - - - - - + - - - - - - - - - + @@ -1275,13 +1306,12 @@ - - + @@ -1295,18 +1325,50 @@ + + + + + + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Coffee/Queue.php b/src/Coffee/Queue.php new file mode 100644 index 0000000..b83dca0 --- /dev/null +++ b/src/Coffee/Queue.php @@ -0,0 +1,30 @@ +queue[] = $element; + } + + /** + * @return mixed + */ + public function pop() { + return array_shift($this->queue); + } +} \ No newline at end of file diff --git a/tests/Coffee/QueueTest.php b/tests/Coffee/QueueTest.php new file mode 100644 index 0000000..9ee9e50 --- /dev/null +++ b/tests/Coffee/QueueTest.php @@ -0,0 +1,18 @@ +push('1'); + $queue->push('2'); + $queue->push('3'); + + $this->assertEquals('1', $queue->pop()); + } +}