title: Deque push_front() and push_back() without including <deque>
body: <p>I need to create a deque by myself to understand how it works with practice and also I don't need to use the  library, I'd like to write my own functions</p>
  
  <p>I created a class Deque, which has methods push_back(), push_front(), pop_back(), pop_front();</p>
  
  <p>At first I wrote such a code for push_front():</p>
  
  <pre><code>void Deque :: push_front( int data, int number ) {
  
   deque[head - 1] = data;
   head++;
  }
  </code></pre>
  
  <p>here is the constructor:</p>
  
  <pre><code>  Deque :: Deque( int number ) : head (1), tail (1), 
                                   go_straight (0), go_back (1), 
                                   deque (new int [number]) {
                                      for( int i = 0; i &lt; number; ++i) {
                                         deque[i] = 0;
                                      }
                                   };
  </code></pre>
  
  <p>but this push_front works in such a way:
  if I input 4(number of elements) and then 40(value)</p>
  
  <pre><code>   40 0 0 0
  </code></pre>
  
  <p>if I input 50(value) it will turn into:</p>
  
  <pre><code>  40 50 0 0
  </code></pre>
  
  <p>But I need to do it like this </p>
  
  <pre><code>  50 40 0 0
  </code></pre>
  
  <p>In other words I need to move the elements on +1, how can I do that?</p>
  
  <p>Thank you in advance!!!</p>