Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8204852

(bf) Add Buffer mismatch()

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 11
    • core-libs
    • None
    • source, binary
    • minimal
    • Java API
    • SE

    Description

      Summary

      A new method mismatch which would return the relative index of the first mismatch between a buffer and another. The method would be added for CharBuffer, IntBuffer, ShortBuffer, LongBuffer, FloatBuffer, DoubleBuffer and ByteBuffer classes.

      Problem

      The proposed method would return the relative index of the first mismatch starting from their current positions. The method would return -1 in case the buffers are equal.

      Solution

      A new method mismatch for CharBuffer, IntBuffer, ShortBuffer, LongBuffer, FloatBuffer, DoubleBuffer and ByteBuffer classes.

      Specification

      +    /**
      +     * Finds and returns the relative index of the first mismatch between this
      +     * buffer and a given buffer.  The index is relative to the
      +     * {@link #position() position} of each buffer and will be in the range of
      +     * 0 (inclusive) up to the smaller of the {@link #remaining() remaining}
      +     * elements in each buffer (exclusive).
      +     *
      +     * If the two buffers share a common prefix then the returned index is
      +     * the length of the common prefix and it follows that there is a mismatch
      +     * between the two buffers at that index within the respective buffers.
      +     * If one buffer is a proper prefix of the other then the returned index is
      +     * the smaller of the remaining elements in each buffer, and it follows that
      +     * the index is only valid for the buffer with the larger number of
      +     * remaining elements.
      +     * Otherwise, there is no mismatch.
      +     *
      +     * @param  that
      +     *         The byte buffer to be tested for a mismatch with this buffer
      +     *
      +     * @return  The relative index of the first mismatch between this and the
      +     *          given buffer, otherwise -1 if no mismatch.
      +     *
      +     * @since 11
      +     */
      +    public int mismatch($Type$Buffer that) {
      

      Attachments

        Issue Links

          Activity

            People

              vtheeyarath Vivek Theeyarath (Inactive)
              webbuggrp Webbug Group
              Paul Sandoz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: