array_hash_t Derived Type

type, public :: array_hash_t

A streaming 32-bit FNV-1a accumulator over array state.

A freshly declared array_hash_t is already seeded with ARRAY_HASH_OFFSET_BASIS, so no explicit initialisation call is needed. Feed it with update, read it with digest, and start over with reset.


Components

Type Visibility Attributes Name Initial
integer(kind=int64), private :: nbytes = 0_int64

Number of encoded bytes consumed so far. Fixed-width int64 so that hashing more than 2 GiB of state cannot overflow the counter in a default_int == int32 build.

integer(kind=int32), private :: state = ARRAY_HASH_OFFSET_BASIS

Running hash. Fixed-width int32, because FNV-1a is defined modulo 2**32.


Type-Bound Procedures

procedure, public :: bytes_hashed => array_hash_bytes_hashed

  • private pure function array_hash_bytes_hashed(this) result(nbytes)

    Number of encoded bytes consumed so far.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(in) :: this

    Return Value integer(kind=int64)

procedure, public :: digest => array_hash_digest

  • private pure function array_hash_digest(this) result(hash_value)

    The digest of everything fed in so far.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(in) :: this

    Return Value integer(kind=int32)

procedure, public :: reset => array_hash_reset

  • private pure subroutine array_hash_reset(this, seed)

    Return the accumulator to its initial state.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in), optional :: seed

    Starting hash value; defaults to ARRAY_HASH_OFFSET_BASIS.

  • private pure subroutine update_int8_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key
  • private pure subroutine update_int8_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key(:)
  • private pure subroutine update_int8_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key(:,:)
  • private pure subroutine update_int8_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key(:,:,:)
  • private pure subroutine update_int16_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key
  • private pure subroutine update_int16_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key(:)
  • private pure subroutine update_int16_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key(:,:)
  • private pure subroutine update_int16_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key(:,:,:)
  • private pure subroutine update_int32_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key
  • private pure subroutine update_int32_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key(:)
  • private pure subroutine update_int32_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key(:,:)
  • private pure subroutine update_int32_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key(:,:,:)
  • private pure subroutine update_int64_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key
  • private pure subroutine update_int64_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key(:)
  • private pure subroutine update_int64_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key(:,:)
  • private pure subroutine update_int64_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key(:,:,:)
  • private pure subroutine update_rsp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key
  • private pure subroutine update_rsp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key(:)
  • private pure subroutine update_rsp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key(:,:)
  • private pure subroutine update_rsp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key(:,:,:)
  • private pure subroutine update_rdp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key
  • private pure subroutine update_rdp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key(:)
  • private pure subroutine update_rdp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key(:,:)
  • private pure subroutine update_rdp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key(:,:,:)
  • private pure subroutine update_csp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key
  • private pure subroutine update_csp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key(:)
  • private pure subroutine update_csp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key(:,:)
  • private pure subroutine update_csp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key(:,:,:)
  • private pure subroutine update_cdp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key
  • private pure subroutine update_cdp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key(:)
  • private pure subroutine update_cdp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key(:,:)
  • private pure subroutine update_cdp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key(:,:,:)
  • private pure subroutine update_logical_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key
  • private pure subroutine update_logical_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key(:)
  • private pure subroutine update_logical_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key(:,:)
  • private pure subroutine update_logical_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key(:,:,:)
  • private pure subroutine update_char_0(this, key)

    Feed a character string, one iachar byte per character.

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    character(len=*), intent(in) :: key
  • private pure subroutine update_char_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    character(len=*), intent(in) :: key(:)

procedure, private :: update_cdp_0

  • private pure subroutine update_cdp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key

procedure, private :: update_cdp_1

  • private pure subroutine update_cdp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key(:)

procedure, private :: update_cdp_2

  • private pure subroutine update_cdp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key(:,:)

procedure, private :: update_cdp_3

  • private pure subroutine update_cdp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=dp), intent(in) :: key(:,:,:)

procedure, private :: update_char_0

  • private pure subroutine update_char_0(this, key)

    Feed a character string, one iachar byte per character.

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    character(len=*), intent(in) :: key

procedure, private :: update_char_1

  • private pure subroutine update_char_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    character(len=*), intent(in) :: key(:)

procedure, private :: update_csp_0

  • private pure subroutine update_csp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key

procedure, private :: update_csp_1

  • private pure subroutine update_csp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key(:)

procedure, private :: update_csp_2

  • private pure subroutine update_csp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key(:,:)

procedure, private :: update_csp_3

  • private pure subroutine update_csp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    complex(kind=sp), intent(in) :: key(:,:,:)

procedure, private :: update_int16_0

  • private pure subroutine update_int16_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key

procedure, private :: update_int16_1

  • private pure subroutine update_int16_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key(:)

procedure, private :: update_int16_2

  • private pure subroutine update_int16_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key(:,:)

procedure, private :: update_int16_3

  • private pure subroutine update_int16_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int16), intent(in) :: key(:,:,:)

procedure, private :: update_int32_0

  • private pure subroutine update_int32_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key

procedure, private :: update_int32_1

  • private pure subroutine update_int32_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key(:)

procedure, private :: update_int32_2

  • private pure subroutine update_int32_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key(:,:)

procedure, private :: update_int32_3

  • private pure subroutine update_int32_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int32), intent(in) :: key(:,:,:)

procedure, private :: update_int64_0

  • private pure subroutine update_int64_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key

procedure, private :: update_int64_1

  • private pure subroutine update_int64_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key(:)

procedure, private :: update_int64_2

  • private pure subroutine update_int64_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key(:,:)

procedure, private :: update_int64_3

  • private pure subroutine update_int64_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int64), intent(in) :: key(:,:,:)

procedure, private :: update_int8_0

  • private pure subroutine update_int8_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key

procedure, private :: update_int8_1

  • private pure subroutine update_int8_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key(:)

procedure, private :: update_int8_2

  • private pure subroutine update_int8_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key(:,:)

procedure, private :: update_int8_3

  • private pure subroutine update_int8_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    integer(kind=int8), intent(in) :: key(:,:,:)

procedure, private :: update_logical_0

  • private pure subroutine update_logical_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key

procedure, private :: update_logical_1

  • private pure subroutine update_logical_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key(:)

procedure, private :: update_logical_2

  • private pure subroutine update_logical_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key(:,:)

procedure, private :: update_logical_3

  • private pure subroutine update_logical_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    logical, intent(in) :: key(:,:,:)

procedure, private :: update_rdp_0

  • private pure subroutine update_rdp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key

procedure, private :: update_rdp_1

  • private pure subroutine update_rdp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key(:)

procedure, private :: update_rdp_2

  • private pure subroutine update_rdp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key(:,:)

procedure, private :: update_rdp_3

  • private pure subroutine update_rdp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=dp), intent(in) :: key(:,:,:)

procedure, private :: update_rsp_0

  • private pure subroutine update_rsp_0(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key

procedure, private :: update_rsp_1

  • private pure subroutine update_rsp_1(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key(:)

procedure, private :: update_rsp_2

  • private pure subroutine update_rsp_2(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key(:,:)

procedure, private :: update_rsp_3

  • private pure subroutine update_rsp_3(this, key)

    Arguments

    Type IntentOptional Attributes Name
    class(array_hash_t), intent(inout) :: this
    real(kind=sp), intent(in) :: key(:,:,:)

Source Code

   type :: array_hash_t
      !! A streaming 32-bit FNV-1a accumulator over array state.
      !!
      !! A freshly declared `array_hash_t` is already seeded with
      !! `ARRAY_HASH_OFFSET_BASIS`, so no explicit initialisation call is
      !! needed. Feed it with `update`, read it with `digest`, and start over
      !! with `reset`.
      private
      integer(int32) :: state = ARRAY_HASH_OFFSET_BASIS
         !! Running hash. Fixed-width `int32`, because FNV-1a is defined
         !! modulo 2**32.
      integer(int64) :: nbytes = 0_int64
         !! Number of encoded bytes consumed so far. Fixed-width `int64` so
         !! that hashing more than 2 GiB of state cannot overflow the counter
         !! in a `default_int` == `int32` build.
   contains
      procedure :: reset => array_hash_reset
      procedure :: digest => array_hash_digest
      procedure :: bytes_hashed => array_hash_bytes_hashed
      generic :: update => &
         update_int8_0, &
         update_int8_1, &
         update_int8_2, &
         update_int8_3, &
         update_int16_0, &
         update_int16_1, &
         update_int16_2, &
         update_int16_3, &
         update_int32_0, &
         update_int32_1, &
         update_int32_2, &
         update_int32_3, &
         update_int64_0, &
         update_int64_1, &
         update_int64_2, &
         update_int64_3, &
         update_rsp_0, &
         update_rsp_1, &
         update_rsp_2, &
         update_rsp_3, &
         update_rdp_0, &
         update_rdp_1, &
         update_rdp_2, &
         update_rdp_3, &
         update_csp_0, &
         update_csp_1, &
         update_csp_2, &
         update_csp_3, &
         update_cdp_0, &
         update_cdp_1, &
         update_cdp_2, &
         update_cdp_3, &
         update_logical_0, &
         update_logical_1, &
         update_logical_2, &
         update_logical_3, &
         update_char_0, &
         update_char_1

      procedure, private :: update_int8_0
      procedure, private :: update_int8_1
      procedure, private :: update_int8_2
      procedure, private :: update_int8_3
      procedure, private :: update_int16_0
      procedure, private :: update_int16_1
      procedure, private :: update_int16_2
      procedure, private :: update_int16_3
      procedure, private :: update_int32_0
      procedure, private :: update_int32_1
      procedure, private :: update_int32_2
      procedure, private :: update_int32_3
      procedure, private :: update_int64_0
      procedure, private :: update_int64_1
      procedure, private :: update_int64_2
      procedure, private :: update_int64_3
      procedure, private :: update_rsp_0
      procedure, private :: update_rsp_1
      procedure, private :: update_rsp_2
      procedure, private :: update_rsp_3
      procedure, private :: update_rdp_0
      procedure, private :: update_rdp_1
      procedure, private :: update_rdp_2
      procedure, private :: update_rdp_3
      procedure, private :: update_csp_0
      procedure, private :: update_csp_1
      procedure, private :: update_csp_2
      procedure, private :: update_csp_3
      procedure, private :: update_cdp_0
      procedure, private :: update_cdp_1
      procedure, private :: update_cdp_2
      procedure, private :: update_cdp_3
      procedure, private :: update_logical_0
      procedure, private :: update_logical_1
      procedure, private :: update_logical_2
      procedure, private :: update_logical_3
      procedure, private :: update_char_0
      procedure, private :: update_char_1
   end type array_hash_t