Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6805675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:36:57+00:00 2026-05-26T19:36:57+00:00

i have an two arrays : char data1[length] where length is a multiple of

  • 0

i have an two arrays : char data1[length] where length is a multiple of 8 i.e length can be 8, 16,24 … The array contains binary data read from a file that is open in binary mode. I will keep reading from the file and everytime i read i will store the read value in a hash table. The disterbution of this binary data has a random distribution. I would like to hash each array and store them in a hash table in order to be able to look for the char with the specific data again. What would be a good hashing function to achive this task. Thanks

Please note that i am writing this in c++ and c so any language you choose to provide a solution for would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:36:57+00:00Added an answer on May 26, 2026 at 7:36 pm

    If the data that you read is 8 bytes long and really distributed randomly, and your hashcode needs to be 32 bits, what about this:

    uint32_t hashcode(const unsigned char *data) {
      uint32_t hash = 0;
      hash ^= get_uint32_le(data + 0);
      hash ^= get_uint32_le(data + 4);
      return hash;
    }
    
    uint32_t get_uint32_le(const unsigned char *data) {
      uint32_t value = 0;
      value |= data[0] << 0;
      value |= data[1] << 8;
      value |= data[2] << 16;
      value |= data[3] << 24;
      return value;
    }
    

    If you need more speed, this code can probably made a lot faster if you can guarantee that data is always properly aligned to be interpreted as an const uint32_t *.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays built while parsing a text file. The first contains the
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two arrays. One contains id=>count and the other contains id=>name . I'm
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids
I have two arrays: Array ( [2005] => 0 [2006] => 0 [2007] =>
If I have two char arrays like so: char one[200]; char two[200]; And I
I have a two-dimensional char array declared with four strings. private static string string1
I'm having a little problem modifying an array in C. I have two arrays,
I am trying to read in data from a text file (the time). and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.