Domain representation

Hi there!

EDIT: I am trying to provide a type/structure overview, so please be patient if you want/need more details about my question

I am writing a solver where I have to represent the domain of each variable. I was wondering what would be the best ways to store the domain information, knowing that a (discrete) domain is a set (ordered or not) of

  1. integers (1 byte)
  2. an interval with unit steps (2 bytes)
  3. an interval with arbitrary steps (3 bytes)

I can possibly convert intervals into a vector of integers, exchanging space for speed and simplicity.
Eventually, I would like to consider continuous domains too, but it is easy to represent intervals.

My question is, what would be the best way to represent such discrete domains considering time efficiency. Is it better to make a union of the three types (each with different size) or artificially make all of them either 1. or 3. ?

As it is for the general case, I don’t have specific use case of how the domains are.

It’s tough to say what’ll be the most time-efficient without knowing what operations you’ll be performing, but small unions are generally fine from a performance standpoint:

1 Like

I smell something similar to: ?