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 6726923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:59:13+00:00 2026-05-26T09:59:13+00:00

I have a large amount of strings that need to be stored in a

  • 0

I have a large amount of strings that need to be stored in a very compact fashion. Currently I am storing the strings (32 characters a-f/0-9) in HashSet<byte[]>. I am simply calling .getBytes() to get this.

My question is, is there a better way to store this data in a hashset?

  • 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-26T09:59:13+00:00Added an answer on May 26, 2026 at 9:59 am

    A HashSet<byte[]> is broken anyway, as byte[] doesn’t override equals() or hashCode(). Calling getBytes() without specifying a character encoding is generally a bad idea – it’s probably okay if you’ve only got hex digits, but I would still avoid it where possible.

    If your strings are always 32 hex digits, that’s basically 16 bytes – have you considered either writing a custom collection for this, or possibly just encapsulating them in an object? Given that for any “normal” collection you’ve got to have an object of some description to represent the element, the object overhead is hard to get around – although with a custom collection you could just have two arrays of longs which you kept in sync. That would be about as compact a representation as you could probably find, but just an object with two long fields or four int fields would be my starting point. Then you can override hashCode and equals and actually get HashSet to work with value equality, instead of just reference identity… and you’ll still be using less data per element than a byte array of 32 bytes.

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

Sidebar

Related Questions

I have a large amount of Word documents that I need to parse. As
I need some help in solving this problem. We have a large amount of
I have a rather large amount of data (100 MB or so), that I
I have a WCF service that can return large amount of data depending on
I have a windows service that receives a large amount of data that needs
We have a large amount of demo code that uses sprintf and cstrings to
I have a large amount of unique strings for which I want to compute
I have a perl script that performs operations on a large amount of data
I have a large amout of objects that all have a filename stored inside.
I have a large amount of data in a database. When I attempt to

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.