Home / Function/ hashCode() — netty Function Reference

hashCode() — netty Function Reference

Architecture documentation for the hashCode() function in ByteBufUtil.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9cc4e575_38a7_bd57_0694_10c13faacf9f["hashCode()"]
  920454f6_25f6_4a9b_3d32_9684c3e11f6c["ByteBufUtil"]
  9cc4e575_38a7_bd57_0694_10c13faacf9f -->|defined in| 920454f6_25f6_4a9b_3d32_9684c3e11f6c
  e706d61d_492d_8474_9658_d45c088fc7ca["swapInt()"]
  9cc4e575_38a7_bd57_0694_10c13faacf9f -->|calls| e706d61d_492d_8474_9658_d45c088fc7ca
  style 9cc4e575_38a7_bd57_0694_10c13faacf9f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/ByteBufUtil.java lines 207–235

    public static int hashCode(ByteBuf buffer) {
        final int aLen = buffer.readableBytes();
        final int intCount = aLen >>> 2;
        final int byteCount = aLen & 3;

        int hashCode = EmptyByteBuf.EMPTY_BYTE_BUF_HASH_CODE;
        int arrayIndex = buffer.readerIndex();
        if (buffer.order() == ByteOrder.BIG_ENDIAN) {
            for (int i = intCount; i > 0; i --) {
                hashCode = 31 * hashCode + buffer.getInt(arrayIndex);
                arrayIndex += 4;
            }
        } else {
            for (int i = intCount; i > 0; i --) {
                hashCode = 31 * hashCode + swapInt(buffer.getInt(arrayIndex));
                arrayIndex += 4;
            }
        }

        for (int i = byteCount; i > 0; i --) {
            hashCode = 31 * hashCode + buffer.getByte(arrayIndex ++);
        }

        if (hashCode == 0) {
            hashCode = 1;
        }

        return hashCode;
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does hashCode() do?
hashCode() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java.
Where is hashCode() defined?
hashCode() is defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java at line 207.
What does hashCode() call?
hashCode() calls 1 function(s): swapInt.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free