getting unique identifier out of two variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JArgyle

    getting unique identifier out of two variables

    Hi,

    given a set of pairs

    P = {(x1,y1), (x2,y2), ... (xn,yn)}

    where each pair is unique, is there a way to get

    Q = {z1, z2, ..., zn}

    that is to map each pair of values to another unique one? Is hashing the
    only way to achieve this?

    Regards

    Josè
  • JArgyle

    #2
    Re: getting unique identifier out of two variables

    Stefan Ram wrote:
    »That is« is used to join two wordings with the same meaning.
    This is not the case here. Moreover, your question only
    mentions mathematical concepts, but shows no relation to C++.
    >
    Yes, for every set P of pairs, there exists a set Q, so that
    there exists a mapping f: P -Q, so that f is injective and
    f(x) != x. Proof: Map each x to the set {x}.
    >
    You must have had a very difficult childhood.

    Kind Regards

    Comment

    • JArgyle

      #3
      Re: getting unique identifier out of two variables

      Alf P. Steinbach wrote:
      >
      Or for example, if they're unsigned char and sizeof(unsigned int)>=2,
      then let z = (unsigned(x)<<C HAR_BIT) | unsigned(y).
      >
      Hi Alf, thanks. In my case they are two unsigned int (I'm evaluating if
      two size_t are better though). I was indeed considering to gather them
      into a struct and overloading the < operator (as you also suggest), but
      I was interested in a more low-level approach, such as the one you
      describe over here. Could you expand a bit on this? Supposing I have two
      uint32_t would it still possible to do something like this?

      Regards

      J.

      Comment

      Working...