Double-Ended Queue Index
<p>So, I have been banging my head for about three days now trying to figure how to get this to work.</p>

<p>My assignment is to write a double-ended queue.  I have no issue with that part.</p>

<p>The issue that I have run into is the fact that we must have the bracket operators work when given one index.</p>

<p>So, if I put in 6, I want to get [2][2] back and such.  But, I have no idea what equation would work.</p>

<p>I have tried everything, I have googled it, I have asked for help from people who have been in the class, this has NEVER been done before in the class so no help there.  No one discusses this, and everyone just seems to use two-dimensions rather than messing with the one index.</p>

<p>I know the equation is probably really simple, but the due date is Friday morning, and I still have to debug it and run unit tests.</p>

<p>Here is the function that it will be used in:</p>

<pre><code>template&lt;typename generic&gt;
generic&amp; Deque&lt;generic&gt;::operator[](unsigned int p)
{
  return m_data[dq_index]-&gt;operator[](block_index);
}
</code></pre>

<p>Class:</p>

<pre><code>#include&lt;stdexcept&gt;
using std::out_of_range;
#include "block.h"

template&lt;typename generic&gt;
class Deque
{
 public:
  Deque();
  Deque(unsigned int n);
  Deque(Deque&amp; d);
  ~Deque();
  void push_front(generic x);
  void pop_front();
  void push_back(generic x);
  void pop_back();
  void clear();
  Deque&amp; operator=(const Deque&amp; d);
  generic&amp; operator[](unsigned int p);
  const generic&amp; operator[](unsigned int p) const;
  unsigned int size() const;
  unsigned int block_size() const;
  bool empty() const;

 private:
  Block&lt;generic&gt;** m_data;
  unsigned int m_size;
  unsigned int m_blocks;
  unsigned int m_block_size;
};
</code></pre>

<p>The assignment: <a href="http://web.mst.edu/~buechler/datastructures/dequeclass.htm" rel="nofollow">http://web.mst.edu/~buechler/datastructures/dequeclass.htm</a></p>
