@Override
    public boolean equals(Object other) {
        if (!(other instanceof BufferImpl)) {
            return false;
        }
        BufferImpl o = (BufferImpl) other;

        // TODO optimize
        if (limit() != o.limit()) {
            return false;
        }
        int i = offset;
        int io = o.offset;
        while (i < filled) {
            if (array[i] != o.array[io]) {
                return false;
            }
            i++;
            io++;
        }
        return true;
    }
@Test
    public void testEquals() throws Exception {
        byte[] bytes = new byte[] { 1, 2, 3, 2, 3 };
        Buffer b1 = BufferImpl.wrap(bytes, 0, 2);  // [1, 2]
        Buffer b2 = BufferImpl.wrap(bytes, 1, 2);  // [2, 3]
        Buffer b3 = BufferImpl.wrap(bytes, 3, 2);  // [2, 3]

        assertFalse(b1.equals(b2));
        assertTrue(b2.equals(b3));

        assertFalse(b1.hashCode() == b2.hashCode());
        assertTrue(b2.hashCode() == b3.hashCode());
    }