0 points

How to do basic hash in swift


dashboard

Fri Jan 03 2020 19:00:00 GMT+0000 (UTC)

Posted by @goblindoom95 #ios #swift #apps #hash #security

#include <iostream>
using namespace std;

struct hashing
{
    int value;
    int key;
};


void put(int value, hashing hash[],int n) {
    hash[value % n].value = value;
    hash[value % n].key = (value % n);
}

int get(int key, hashing hash[]) {
    return hash[key].value;
}

int main()
{
    int n;
    
    struct hashing hash[n];
    cin >> n;
    for (int t=0;t<n;t++) {
        put(t+1,hash,n);
        cout << "Inserted : " << (t+1) << endl;
    }
    int temp;
    cin >> temp;
    cout << get(temp,hash) << endl;
}
content_copy Copy

https://github.com/manosriram/Data-Structures/blob/master/Hashing/basicHash.cpp