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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:00:49+00:00 2026-06-04T22:00:49+00:00

Is there a commonly accepted way of how to compare immutable objects that might

  • 0

Is there a commonly accepted way of how to compare immutable objects that might contain long lists of values?

So far, my interfaces are as follows:

interface Formula : IEquatable<Formula> {
   IList<Symbol> Symbols {get;}
}

interface Symbol : IEquatable<Symbol> {
   String Value {get;}
}

Here, the immutable datatype Formula represents a sequence of Symbol‘s. So in a formula:

x -> y

symbols would be x,->,y.

I want to compare two Formulas based on their content (e.g. a list of symbols). So new Formula(symbols) would equal new Formula(symbols) for some arbitrary list of symbols.

However, I don’t want to iteratively compare two lists all the time.

I was thinking, in implementation, of creating some kind of calculated value during the initialization of the Formula – and using that for comparison. However, that will require me to add a method of some sort to my interface. What would I call that method?

I am not sure if it is appropriate to use hash code for this, as it seems to be limited to integers.

Any help appreciated – and if something is not clear I will revise my question.
Thank you!

  • 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-06-04T22:00:50+00:00Added an answer on June 4, 2026 at 10:00 pm

    You could definitely use a hash code for this. Don’t forget that a hash code doesn’t have to be unique – it just helps if it doesn’t give collisions (two unequal sequences with the same hash code) terribly often. (At least, try to come up with an approach which avoids equal hash codes for obvious situations.)

    So you could compute the hash code once on construction (by combining the hash codes of each symbol in turn), then return that from GetHashCode without recomputing it each time. That would mean that you’d only ever need to compare sequences with equal hash codes – which would rarely happen for non-equal sequences.

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

Sidebar

Related Questions

Is there a commonly-accepted practice for designing java objects that are frequently loaded and
Is there a built in method, function, API, commonly accepted way, etc. to dump
Is there a standardized (or commonly accepted way) to tackle the issue of not
What is the commonly accepted method for converting arbitrary objects to and from their
It seems that the commonly accepted approach to implement a paid premium key application
Is there a commonly accepted practice on how to propagate a revert from trunk
Is there a easy to use (from .net) and commonly accepted file format for
Is there a standard library or commonly used library that can be used for
There are a set of questions that seem to be commonly-used in interviews and
Is there any cheat sheet available for Android programming. Most commonly used classes with

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.