Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Which tag loop is faster?

    Scheduled Pinned Locked Moved SDK Help
    7 Posts 0 Posters 506 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 20/09/2006 at 01:23, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.102 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Which of these loops to get a particular type of tag on an object is faster (if there's any difference)?

      for (pt = obj->GetFirstTag(); pt; pt = pt->GetNext())  
      {  
           if (!pt->IsInstanceOf(ID_IPPDIALTAG))     continue;
      

      - OR -

      for (LONG nr = 0; pt = obj->GetTag(ID_IPPDIALTAG, nr); nr++)  
      {
      

      Thanks,

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 24/09/2006 at 01:31, xxxxxxxx wrote:

        The second one is kind of misused. The GetTag command will loop internally until it finds a tag of this type, so there´s no need for a loop.

        It should therefore also be faster than the first one.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 24/09/2006 at 02:01, xxxxxxxx wrote:

          Well, there is a need for a loop if you are getting 'all' of the similar tags on an object. 🙂 That's why I ask since the most expedience in traversing a set of particular tags is required.

          In this case, do you think that the first or second is more expedient?

          Thanks,

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 24/09/2006 at 13:02, xxxxxxxx wrote:

            I'd guess that the first is O(n) and the second O(n^2). So the first one should win.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 24/09/2006 at 14:03, xxxxxxxx wrote:

              Is this because GetTag() initiates its own loop to traverse up to the next valid tag? If so, then time for some updating. 🙂

              Thanks!

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 26/09/2006 at 21:55, xxxxxxxx wrote:

                That seems to settle it. There were something like 90+ of the GetTag() loops and all were replaced with the other type. The results definitely showed an improvement in speed.

                Thank you very much - sometimes purile, but it is easier to ask and take advice than to change large areas of code blindly. 🙂

                Robert

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 29/09/2006 at 07:02, xxxxxxxx wrote:

                  IT would be great if GetTag() would return the location of the found tag. That way one could go on from this position+1 to get the next tag in the row of the same type.

                  Take this as a suggestion Mikael 😉

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post