public int size ( ) { int read = readLocation ; int write = writeLocation ; if ( write < read ) write += capacity ; return write - read ; }
This method is not thread safe it therefore only provides and approximation of the size the size will be corrected if nothing was added or removed from the queue at the time it was called