code: public int remainingCapacity() {
  
          int readLocation = this.readLocation;
          int writeLocation = this.writeLocation;
  
          if (writeLocation < readLocation)
              writeLocation += capacity;
  
  
          return (capacity - 1) - (writeLocation - readLocation);
      }
docs: Returns the number of additional elements that this queue can ideally
  (in the absence of memory or resource constraints) accept without
  blocking, or <tt>Integer.MAX_VALUE</tt> if there is no intrinsic
  limit.
  <p>
  <p>Note that you <em>cannot</em> always tell if an attempt to insert
  an element will succeed by inspecting <tt>remainingCapacity</tt>
  because it may be the case that another thread is about to
  insert or remove an element.
  
  @return the remaining capacity