Giter Club home page Giter Club logo

fortran_hash_table's Introduction

Fortran hash table {#mainpage}

The module dictionary_m implements a "<string,string>" hash table based on the djb2 hash function.

program example_from_readme
  use dictionary_m
  implicit none

  type(dictionary_t) :: d

  call d%init(1024)

  call d%set('one', 'one')
  call d%set('pi', '3.14159')

  write(*,*) 'one', ' = ', d%get('one')
  write(*,*) 'pi', ' = ', d%get('pi')

end program example_from_readme

Author: Pierre de Buyl

License: BSD

Code repository: https://github.com/pdebuyl/fortran_hash_table/

Project goals

  • Demonstrate a hash table in Fortran.
  • Use standard Fortran 2008.
  • Single file implementation.
  • No dependency.
  • No preprocessing.
  • Not design a generic container, dictionary_m just stores strings. It is of course possible to replace the "value" entry in the type entry_t for a single-datatype dictionary.

The hash table is based on plain allocatable arrays and the base data is stored in (len=:), allocatable character variables. Buckets are extended arbitrarily by reallocation, thus collisions will slow down this implementation with respect to others using better data structures.

The goal is not to beat other implementations performance-wise but to provide the convenience for Fortran programmers to store configuration settings, or other auxiliary data easily.

Installation

dictionary_m consists of a single Fortran file. You can just drop src/dictionary_m.f90 in your Fortran project.

The code requires Fortran 2008 support. For gfortran, I have tested version 6.3 and 7.2. For Intel Fortran, I have tested version 16.0.3.

Documentation and coverage

If you read this page from the "GitHub pages" doxygen-generated documentation, you can access:

See also

I am neither the first or the only person having implemented a hash table in Fortran. While the implementations below did not fit my design goals, they might suit you just fine.

  • HASTY by Stefano Zaghi: HASh Table fortran container exploting coarraY.
  • In FLIBS by Arjen Markus, dictionaries is a Generic source code for implementing a mapping of strings to data.
  • The Fortran Wiki has a page on hash tables.

fortran_hash_table's People

Contributors

pdebuyl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

youngmchoi cratza

fortran_hash_table's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.