GithubHelp home page GithubHelp logo

lateralus138 / fortran_associative_array Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ysdtkm/fortran_associative_array

0.0 2.0 0.0 227 KB

An associative array (a.k.a. dictionary or hash table) implementation with Fortran

License: MIT License

Makefile 15.63% Fortran 65.41% C 1.79% C++ 4.30% Python 12.87%

fortran_associative_array's Introduction

Fortran associative array Build Status

A scalable associative array (known as hash table or dictionary) for Fortran

Specifications

  • Internal data structure is treap (randomized binary search tree)

  • Roughly corresponds to std::map (C++) or dict (Python)

    • A key can be characters (either fixed or arbitrary length), an integer, or a real
    • A value can be any fortran intrinsic data type (with fixed length or kind). A copy of the value is stored in the dict object
    • Does not affect Fortran's intrinsic random state
  • Implemented operations

    Operation Cost Implementation
    Insertion/assignment O(log n) Subroutine insert_or_assign(dict, key, val)
    Deletion O(log n) Subroutine remove(dict, key)
    (Error if not exist)
    Existence of a key O(log n) Logical function exists(dict, key)
    Reference O(log n) Valuetype function get_val(dict, key)
    (Error if not exist)
    Get max/min/k-th key O(log n) Keytype function get_kth_key(dict, k)
    (Error if out of bounds; 1-based)
    Count O(1) Integer function get_size(dict)
    Retrieve sorted array O(n) Subroutine get_keys_vals(dict, keys, vals, n)
    (Not for arbitrary length keys)
    Clear O(n) Implicitly called as a destructor
  • Other operations allowed by the data structure (not implemented)

    Operation Cost Note
    Merge/split O(log n) Destructive
    lower_bound/upper_bound O(log n)
    Range search O(log n + elements found)
    Deep copy O(n) Preorder DFS
  • Speed comparison with gfortran/g++, without compiler optimization

Usage

  • See sample.f90 for sample usage
  • Edit dtypes.h if using another data types
    • For string key (arbitrary length), keytype1 should be character(:),allocatable and keytype2 should be character(*)
    • For other key types, keytype1 and keytype2 are the same

References

fortran_associative_array's People

Contributors

ysdtkm avatar

Watchers

 avatar  avatar

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.