Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is there a fast method for doing this?

Is there a fast method for doing this?

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    chen
    wrote on last edited by
    #1

    Hi, I have a data structure as followings. I need that insert some data in order to make the data looks completely. In the data, the x[0], x[1], x[2] and x[3] are timecode: represents hour, minutes, second and frame (here 1 second = 30 frames), respectively. The other important data is x[5], when you insert some new timecode with contimuous frame, the x[5] should also be inserted with a Linear insert method. The rest data should be same with others. I found that it is slowly when the length of the data is large. So is there a fast method for doing this ? The data looks like this: ------------------------------------------------------------ x[0] x[1] x[2] x[3] x[4] x[5] x[6], ... x[13] 00 02 14 19 0 41 0 4 2 3 0 15 15 0 00 02 14 20 0 42 0 4 2 3 0 15 15 0 00 02 14 22 0 44 0 4 2 3 0 15 15 0 00 02 14 23 0 46 0 4 2 3 0 15 15 0 00 02 14 25 0 47 0 4 2 3 0 15 15 0 00 02 14 26 0 48 0 4 2 3 0 15 15 0 00 02 14 27 0 49 0 4 2 3 0 15 15 0 00 02 14 28 0 50 0 4 2 3 0 15 15 0 00 02 15 00 0 51 0 4 2 3 0 15 15 0 00 02 15 01 0 53 0 4 2 3 0 15 15 0 00 02 15 02 0 54 0 4 2 3 0 15 15 0 00 02 15 03 0 56 0 4 2 3 0 15 15 0 00 02 15 04 0 57 0 4 2 3 0 15 15 0 00 02 15 05 0 58 0 4 2 3 0 15 15 0 00 02 15 06 0 59 0 4 2 3 0 15 15 0 00 02 15 07 0 60 0 4 2 3 0 15 15 0 00 02 15 08 0 61 0 4 2 3 0 15 15 0 00 02 15 09 0 63 0 4 2 3 0 15 15 0 00 02 15 10 0 64 0 4 2 3 0 15 15 0 00 02 15 12 0 68 0 4 2 3 0 15 15 0 00 02 15 13 0 69 0 4 2 3 0 15 15 0 00 02 15 14 0 71 0 4 2 3 0 15 15 0 00 02 15 15 0 72 0 4 2 3 0 15 15 0 00 02 15 16 0 73 0 4 2 3 0 15 15 0 00 02 15 17 0 74 0 4 2 3 0 15 15 0 00 02 15 18 0 75 0 4 2 3 0 15 15 0 00 02 15 19 0 77 0 4 2 3 0 15 15 0 00 02 15 24 0 89 0 4 2 3 0 15 15 0 00 02 15 25 0 90 0 4 2 3 0 15 15 0 00 02 15 26 0 91 0 4 2 3 0 15 15 0 00 02 15 27 0 93 0 4 2 3 0 15 15 0 00 02 15 28 0 95 0 4 2 3 0 15 15 0 00 02 15 29 0 96 0 4 2 3 0 15 15 0 ............ --------------------------------------------------- For example, for the first three raws: it should be changed as follows: 00 02 14 19 0 41 0 4 2 3 0 15 15 0 00 02 14 20 0 42 0 4 2 3 0 15 15 0 00 02 14 21 0 43 0 4 2 3 0 15 15 0 ==> inserted line 00 02 14 22 0 44 0 4 2 3 0 15 15 0 ======================================= Thanks in advance!

    P C 2 Replies Last reply
    0
    • C chen

      Hi, I have a data structure as followings. I need that insert some data in order to make the data looks completely. In the data, the x[0], x[1], x[2] and x[3] are timecode: represents hour, minutes, second and frame (here 1 second = 30 frames), respectively. The other important data is x[5], when you insert some new timecode with contimuous frame, the x[5] should also be inserted with a Linear insert method. The rest data should be same with others. I found that it is slowly when the length of the data is large. So is there a fast method for doing this ? The data looks like this: ------------------------------------------------------------ x[0] x[1] x[2] x[3] x[4] x[5] x[6], ... x[13] 00 02 14 19 0 41 0 4 2 3 0 15 15 0 00 02 14 20 0 42 0 4 2 3 0 15 15 0 00 02 14 22 0 44 0 4 2 3 0 15 15 0 00 02 14 23 0 46 0 4 2 3 0 15 15 0 00 02 14 25 0 47 0 4 2 3 0 15 15 0 00 02 14 26 0 48 0 4 2 3 0 15 15 0 00 02 14 27 0 49 0 4 2 3 0 15 15 0 00 02 14 28 0 50 0 4 2 3 0 15 15 0 00 02 15 00 0 51 0 4 2 3 0 15 15 0 00 02 15 01 0 53 0 4 2 3 0 15 15 0 00 02 15 02 0 54 0 4 2 3 0 15 15 0 00 02 15 03 0 56 0 4 2 3 0 15 15 0 00 02 15 04 0 57 0 4 2 3 0 15 15 0 00 02 15 05 0 58 0 4 2 3 0 15 15 0 00 02 15 06 0 59 0 4 2 3 0 15 15 0 00 02 15 07 0 60 0 4 2 3 0 15 15 0 00 02 15 08 0 61 0 4 2 3 0 15 15 0 00 02 15 09 0 63 0 4 2 3 0 15 15 0 00 02 15 10 0 64 0 4 2 3 0 15 15 0 00 02 15 12 0 68 0 4 2 3 0 15 15 0 00 02 15 13 0 69 0 4 2 3 0 15 15 0 00 02 15 14 0 71 0 4 2 3 0 15 15 0 00 02 15 15 0 72 0 4 2 3 0 15 15 0 00 02 15 16 0 73 0 4 2 3 0 15 15 0 00 02 15 17 0 74 0 4 2 3 0 15 15 0 00 02 15 18 0 75 0 4 2 3 0 15 15 0 00 02 15 19 0 77 0 4 2 3 0 15 15 0 00 02 15 24 0 89 0 4 2 3 0 15 15 0 00 02 15 25 0 90 0 4 2 3 0 15 15 0 00 02 15 26 0 91 0 4 2 3 0 15 15 0 00 02 15 27 0 93 0 4 2 3 0 15 15 0 00 02 15 28 0 95 0 4 2 3 0 15 15 0 00 02 15 29 0 96 0 4 2 3 0 15 15 0 ............ --------------------------------------------------- For example, for the first three raws: it should be changed as follows: 00 02 14 19 0 41 0 4 2 3 0 15 15 0 00 02 14 20 0 42 0 4 2 3 0 15 15 0 00 02 14 21 0 43 0 4 2 3 0 15 15 0 ==> inserted line 00 02 14 22 0 44 0 4 2 3 0 15 15 0 ======================================= Thanks in advance!

      P Offline
      P Offline
      pepe 0
      wrote on last edited by
      #2

      If you have many data you could use a linked list structure. If you want to use arrays, use memmove.

      1 Reply Last reply
      0
      • C chen

        Hi, I have a data structure as followings. I need that insert some data in order to make the data looks completely. In the data, the x[0], x[1], x[2] and x[3] are timecode: represents hour, minutes, second and frame (here 1 second = 30 frames), respectively. The other important data is x[5], when you insert some new timecode with contimuous frame, the x[5] should also be inserted with a Linear insert method. The rest data should be same with others. I found that it is slowly when the length of the data is large. So is there a fast method for doing this ? The data looks like this: ------------------------------------------------------------ x[0] x[1] x[2] x[3] x[4] x[5] x[6], ... x[13] 00 02 14 19 0 41 0 4 2 3 0 15 15 0 00 02 14 20 0 42 0 4 2 3 0 15 15 0 00 02 14 22 0 44 0 4 2 3 0 15 15 0 00 02 14 23 0 46 0 4 2 3 0 15 15 0 00 02 14 25 0 47 0 4 2 3 0 15 15 0 00 02 14 26 0 48 0 4 2 3 0 15 15 0 00 02 14 27 0 49 0 4 2 3 0 15 15 0 00 02 14 28 0 50 0 4 2 3 0 15 15 0 00 02 15 00 0 51 0 4 2 3 0 15 15 0 00 02 15 01 0 53 0 4 2 3 0 15 15 0 00 02 15 02 0 54 0 4 2 3 0 15 15 0 00 02 15 03 0 56 0 4 2 3 0 15 15 0 00 02 15 04 0 57 0 4 2 3 0 15 15 0 00 02 15 05 0 58 0 4 2 3 0 15 15 0 00 02 15 06 0 59 0 4 2 3 0 15 15 0 00 02 15 07 0 60 0 4 2 3 0 15 15 0 00 02 15 08 0 61 0 4 2 3 0 15 15 0 00 02 15 09 0 63 0 4 2 3 0 15 15 0 00 02 15 10 0 64 0 4 2 3 0 15 15 0 00 02 15 12 0 68 0 4 2 3 0 15 15 0 00 02 15 13 0 69 0 4 2 3 0 15 15 0 00 02 15 14 0 71 0 4 2 3 0 15 15 0 00 02 15 15 0 72 0 4 2 3 0 15 15 0 00 02 15 16 0 73 0 4 2 3 0 15 15 0 00 02 15 17 0 74 0 4 2 3 0 15 15 0 00 02 15 18 0 75 0 4 2 3 0 15 15 0 00 02 15 19 0 77 0 4 2 3 0 15 15 0 00 02 15 24 0 89 0 4 2 3 0 15 15 0 00 02 15 25 0 90 0 4 2 3 0 15 15 0 00 02 15 26 0 91 0 4 2 3 0 15 15 0 00 02 15 27 0 93 0 4 2 3 0 15 15 0 00 02 15 28 0 95 0 4 2 3 0 15 15 0 00 02 15 29 0 96 0 4 2 3 0 15 15 0 ............ --------------------------------------------------- For example, for the first three raws: it should be changed as follows: 00 02 14 19 0 41 0 4 2 3 0 15 15 0 00 02 14 20 0 42 0 4 2 3 0 15 15 0 00 02 14 21 0 43 0 4 2 3 0 15 15 0 ==> inserted line 00 02 14 22 0 44 0 4 2 3 0 15 15 0 ======================================= Thanks in advance!

        C Offline
        C Offline
        chen
        wrote on last edited by
        #3

        Thanks! for example, how to do that? chen

        P 1 Reply Last reply
        0
        • C chen

          Thanks! for example, how to do that? chen

          P Offline
          P Offline
          pepe 0
          wrote on last edited by
          #4

          There are lots of implementation of linked lists, you could try STL containers, they are very fast if they are used in a good way. There must be examples & tutorials here at CodeProject. You could also implement it yourself. Basically it should look like this : struct myList { long somedata; struct myList *next; }; "640K ought to be enough for anybody." Bill Gates

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups