@Override
    public boolean contains(Object o) {
        synchronized (this) {

            synchronized (lock) {
                //First check the expedited buffer
                //Check if we wrap around the end of the array before iterating
                if (expeditedPutIndex > expeditedTakeIndex) {
                    for (int i = expeditedTakeIndex; i <= expeditedPutIndex; i++) {
                        if (o.equals(expeditedBuffer[i])) {
                            return true;
                        }
                    }
                } else {
                    //We wrap around the array. Loop through in two passes(upper and lower)
                    for (int i = expeditedTakeIndex; i < expeditedBuffer.length; i++) {
                        if (o.equals(expeditedBuffer[i])) {
                            return true;
                        }
                    }
                    for (int i = 0; i < expeditedPutIndex; i++) {
                        if (o.equals(expeditedBuffer[i])) {
                            return true;
                        }
                    }
                }

                //Next check the main buffer
                //Check if we wrap around the end of the array before iterating
                if (putIndex > takeIndex) {
                    for (int i = takeIndex; i <= putIndex; i++) {
                        if (o.equals(buffer[i])) {
                            return true;
                        }
                    }
                } else {
                    //We wrap around the array. Loop through in two passes(upper and lower)
                    for (int i = takeIndex; i < buffer.length; i++) {
                        if (o.equals(buffer[i])) {
                            return true;
                        }
                    }
                    for (int i = 0; i < putIndex; i++) {
                        if (o.equals(buffer[i])) {
                            return true;
                        }
                    }
                }
            }
        }

        return false;
    }
@ Override public boolean contains ( Object o ) { synchronized ( this ) { synchronized ( lock ) { if ( expeditedPutIndex > expeditedTakeIndex ) { for ( int i = expeditedTakeIndex ; i <= expeditedPutIndex ; i ++ ) { if ( o . equals ( expeditedBuffer [ i ] ) ) { return true ; } } } else { for ( int i = expeditedTakeIndex ; i < expeditedBuffer . length ; i ++ ) { if ( o . equals ( expeditedBuffer [ i ] ) ) { return true ; } } for ( int i = 0 ; i < expeditedPutIndex ; i ++ ) { if ( o . equals ( expeditedBuffer [ i ] ) ) { return true ; } } } if ( putIndex > takeIndex ) { for ( int i = takeIndex ; i <= putIndex ; i ++ ) { if ( o . equals ( buffer [ i ] ) ) { return true ; } } } else { for ( int i = takeIndex ; i < buffer . length ; i ++ ) { if ( o . equals ( buffer [ i ] ) ) { return true ; } } for ( int i = 0 ; i < putIndex ; i ++ ) { if ( o . equals ( buffer [ i ] ) ) { return true ; } } } } } return false ; }
/*
@awisniew - ADDED

(non-Javadoc)

@see java.util.concurrent.BlockingQueue#contains(java.lang.Object)