difference between sets

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

    #1

    difference between sets

    I am writing a method that will send a message to another object, based
    on changes (if any) bewtween two sets of data.

    I anticipate that this method will be called about 50k-100k times - i.e.
    it needs to check if there has been any change in a set of data a very
    large number of times.

    The way I am currently thinking of implementing this is to store a local
    copy of the set, and then check for a difference between the local copy
    and the newly received set - and then send the appropriate message based
    on the difference.

    Because of the large number of times this function will be executed - I
    thuink it is likely to be a bottleneck - since I'm not too familiar with
    std::set, I thought it best to ask in here for advice - i.e. :

    1). Are there any gotchas I need to be aware of when using std::set in
    the manner described above ?
    2). Is there a more elegant (and faster?) way of recognising if the
    contents of a set has changed?
  • =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=

    #2
    Re: difference between sets

    On 2007-10-25 21:23, Anonymous wrote:
    I am writing a method that will send a message to another object, based
    on changes (if any) bewtween two sets of data.
    Who owns these two sets?
    The way I am currently thinking of implementing this is to store a local
    copy of the set, and then check for a difference between the local copy
    and the newly received set - and then send the appropriate message based
    on the difference.
    Can you not just watch for changes to either of those sets?
    Because of the large number of times this function will be executed - I
    thuink it is likely to be a bottleneck - since I'm not too familiar with
    std::set, I thought it best to ask in here for advice - i.e. :
    >
    1). Are there any gotchas I need to be aware of when using std::set in
    the manner described above ?
    I am not sure in what manner you are planning on using the sets. If you
    just want to compare two sets then there is nothing to worry about.
    2). Is there a more elegant (and faster?) way of recognising if the
    contents of a set has changed?
    As I said earlier, watching for changes instead of checking for them
    would be more efficient.

    --
    Erik Wikström

    Comment

    • zhang

      #3
      Re: difference between sets

      On Oct 26, 3:23 am, Anonymous <no.re...@here. comwrote:
      I am writing a method that will send a message to another object, based
      on changes (if any) bewtween two sets of data.
      >
      I anticipate that this method will be called about 50k-100k times - i.e.
      it needs to check if there has been any change in a set of data a very
      large number of times.
      >
      The way I am currently thinking of implementing this is to store a local
      copy of the set, and then check for a difference between the local copy
      and the newly received set - and then send the appropriate message based
      on the difference.
      >
      Because of the large number of times this function will be executed - I
      thuink it is likely to be a bottleneck - since I'm not too familiar with
      std::set, I thought it best to ask in here for advice - i.e. :
      >
      1). Are there any gotchas I need to be aware of when using std::set in
      the manner described above ?
      2). Is there a more elegant (and faster?) way of recognising if the
      contents of a set has changed?
      The scenario looks very much like what Observer design pattern should
      be
      applied to. You could try this out using Observer pattern.

      Cheers,

      Comment

      • James.Yu.Tin@gmail.com

        #4
        Re: difference between sets

        hashing it or fingerprint it....

        good luck.




        Anonymous wrote:
        I am writing a method that will send a message to another object, based
        on changes (if any) bewtween two sets of data.
        >
        I anticipate that this method will be called about 50k-100k times - i.e.
        it needs to check if there has been any change in a set of data a very
        large number of times.
        >
        The way I am currently thinking of implementing this is to store a local
        copy of the set, and then check for a difference between the local copy
        and the newly received set - and then send the appropriate message based
        on the difference.
        >
        Because of the large number of times this function will be executed - I
        thuink it is likely to be a bottleneck - since I'm not too familiar with
        std::set, I thought it best to ask in here for advice - i.e. :
        >
        1). Are there any gotchas I need to be aware of when using std::set in
        the manner described above ?
        2). Is there a more elegant (and faster?) way of recognising if the
        contents of a set has changed?

        Comment

        • James.Yu.Tin@gmail.com

          #5
          Re: difference between sets

          try fingerprinting the snapshot set and the live set, compare them
          and ...

          Comment

          Working...