add_pointer Subroutine

private subroutine add_pointer(self, key, content, buckets_number)

Add a node pointer to the dictionary.

Arguments

Type IntentOptional AttributesName
class(dictionary), intent(inout) :: self

The dictionary.

class(*), intent(in) :: key

The key.

class(*), intent(in), pointer:: content

The content.

integer(kind=I4P), intent(in), optional :: buckets_number

Buckets number.

Calls

proc~~add_pointer~~CallsGraph proc~add_pointer add_pointer proc~is_key_allowed is_key_allowed proc~add_pointer->proc~is_key_allowed
Help

Source Code


Source Code

  subroutine add_pointer(self, key, content, buckets_number)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Add a node pointer to the dictionary.
  !<
  !< @note If a node with the same key is already in the dictionary, it is removed and the new one will replace it.
  !---------------------------------------------------------------------------------------------------------------------------------
  class(dictionary), intent(inout)        :: self           !< The dictionary.
  class(*),          intent(in)           :: key            !< The key.
  class(*), pointer, intent(in)           :: content        !< The content.
  integer(I4P),      intent(in), optional :: buckets_number !< Buckets number.
  type(dictionary_node), pointer          :: p              !< Pointer to scan the dictionary.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  if (.not.is_key_allowed(key)) error stop 'error: key type not supported'

  ! if the node is already there, then remove it
  p => self%node(key=key)
  if (associated(p)) call self%remove_by_pointer(p)

  ! update next/previous pointers
  if (associated(self%tail)) then ! insert new node at the end
    allocate(self%tail%next)
    p => self%tail%next
    p%previous => self%tail
  else
    allocate(self%head) ! insert new node as first node
    p => self%head
  end if
  self%tail => p

  call p%set_pointer(key=key, content=content, buckets_number=buckets_number) ! fill the new node with provided contents

  call self%add_id(id=p%key%id())

  self%nodes_number = self%nodes_number + 1
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine add_pointer


add_clone add_clone add_id add_pointer add_pointer allocate_members assert_close_r32 assert_close_r32_1 assert_close_r64 assert_close_r64_1 assert_equal_i16 assert_equal_i16_1 assert_equal_i32 assert_equal_i32_1 assert_equal_i64 assert_equal_i64_1 assert_equal_i8 assert_equal_i8_1 assert_equal_l assert_equal_l_1 assert_equal_r32 assert_equal_r32_1 assert_equal_r64 assert_equal_r64_1 assert_positive_i16 assert_positive_i16_1 assert_positive_i32 assert_positive_i32_1 assert_positive_i64 assert_positive_i64_1 assert_positive_i8 assert_positive_i8_1 assert_positive_r32 assert_positive_r32_1 assert_positive_r64 assert_positive_r64_1 bctoi_I1P bctoi_I2P bctoi_I4P bctoi_I8P bcton bctor_R16P bctor_R4P bctor_R8P bit_size bit_size bit_size_chr bit_size_R16P bit_size_R4P bit_size_R8P bstr bstr_I1P bstr_I2P bstr_I4P bstr_I8P bstr_R16P bstr_R4P bstr_R8P byte_size byte_size_chr byte_size_I1P byte_size_I2P byte_size_I4P byte_size_I8P byte_size_R16P byte_size_R4P byte_size_R8P check_endian check_type compact_real_string creator ctoi_I1P ctoi_I2P ctoi_I4P ctoi_I8P cton ctor_R16P ctor_R4P ctor_R8P destroy destroy destroy destroy destroy destroy_content destroy_dictionary_node destroy_key dictionary_len digit digit_I1 digit_I2 digit_I4 digit_I8 finalize finalize finalize find_next_prime get_bucket_image_indexes get_clone get_clone get_pointer get_pointer get_pointer has_key has_key has_key hash hash hash_string hash_table_finalize hash_table_len id ids ids init initialize initialize initialize is_equal is_equal is_filled is_homogeneous is_initialized is_key_allowed is_prime iterator_max iterator_max key_base len len loop node penf_init penf_print print print_content_iterator print_content_iterator print_keys print_keys remove remove remove_by_pointer remove_id set set_buckets_number set_caf_dimensions set_clone set_homogeneous set_pointer str str_a_I1P str_a_I2P str_a_I4P str_a_I8P str_a_R16P str_a_R4P str_a_R8P str_bol str_I1P str_I2P str_I4P str_I8P str_R16P str_R4P str_R8P strf_I1P strf_I2P strf_I4P strf_I8P strf_R16P strf_R4P strf_R8P stringify stringify strz strz_I1P strz_I2P strz_I4P strz_I8P synchronize_images test_assert_equal test_assert_equal test_assert_equal test_dictionary_finalize tests_non_captured tests_non_captured traverse traverse traverse_iterator