text: /**
   * Initialize your data structure here. Set the size of the deque to be k.
   * @param {number} k
   */
  var MyCircularDeque = function(k) {
    this._queue = new Array(k);
    this._max = k;
    this._head = 0;
    this._tail = 0;
    this._size = 0;
  };
  
  /**
   * Adds an item at the front of Deque. Return true if the operation is successful. 
   * @param {number} value
   * @return {boolean}
   */
  MyCircularDeque.prototype.insertFront = function(value) {
    if (this.isFull()) {
      return false;
    };
    this._head = (this._head - 1 + this._max) % this._max;
    this._size++;
    this._queue[this._head] = value;
    return true;
  };
  
  /**
   * Adds an item at the rear of Deque. Return true if the operation is successful. 
   * @param {number} value
   * @return {boolean}
   */
  MyCircularDeque.prototype.insertLast = function(value) {
    if (this.isFull()) {
      return false;
    };
    this._queue[this._tail] = value;
    this._tail = (this._tail + 1) % this._max;
    this._size++;
    return true;
  };
  
  /**
   * Deletes an item from the front of Deque. Return true if the operation is successful.
   * @return {boolean}
   */
  MyCircularDeque.prototype.deleteFront = function() {
    if (this.isEmpty()) {
      return false;
    }
    this._haed = (this._haed + 1) % this._max;
    this._size--;
    return true;
  };
  
  /**
   * Deletes an item from the rear of Deque. Return true if the operation is successful.
   * @return {boolean}
   */
  MyCircularDeque.prototype.deleteLast = function() {
    if (this.isEmpty()) {
      return false;
    }
    this._tail = (this._tail -1 + this._max) % this._max;
    this._size--;
    return true;
  };
  
  /**
   * Get the front item from the deque.
   * @return {number}
   */
  MyCircularDeque.prototype.getFront = function() {
    if (this.isEmpty()) {
      return -1;
    }
    return this._queue[this._head];
  };
  
  /**
   * Get the last item from the deque.
   * @return {number}
   */
  MyCircularDeque.prototype.getRear = function() {
    if (this.isEmpty()) {
      return -1;
    }
    return this._queue[(this._tail - 1 + this._max) % this._max];
  };
  
  /**
   * Checks whether the circular deque is empty or not.
   * @return {boolean}
   */
  MyCircularDeque.prototype.isEmpty = function() {
    return this._size <= 0;
  };
  
  /**
   * Checks whether the circular deque is full or not.
   * @return {boolean}
   */
  MyCircularDeque.prototype.isFull = function() {
    return this._size >= this._max;
  };
  
  /**
   * Your MyCircularDeque object will be instantiated and called as such:
   * var obj = new MyCircularDeque(k)
   * var param_1 = obj.insertFront(value)
   * var param_2 = obj.insertLast(value)
   * var param_3 = obj.deleteFront()
   * var param_4 = obj.deleteLast()
   * var param_5 = obj.getFront()
   * var param_6 = obj.getRear()
   * var param_7 = obj.isEmpty()
   * var param_8 = obj.isFull()
   */