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. I’m trying to figure out a way to store my data in an clever way

I’m trying to figure out a way to store my data in an clever way

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
3 Posts 3 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.
  • T Offline
    T Offline
    t bast
    wrote on last edited by
    #1

    The objects to store contains a regular integer and a pointer. Each integer value is unique and received in a sequential order (the value is increased by one or more for each time). - I want to find an object with a particular integer value as fast as possible. - I don’t know the number of objects at load time, so I cant load all at once and use binary search. I believe using a tree structure is not the most clever idea, since the data is in order from start. Maybe a skip list is the best idea?.

    S B 2 Replies Last reply
    0
    • T t bast

      The objects to store contains a regular integer and a pointer. Each integer value is unique and received in a sequential order (the value is increased by one or more for each time). - I want to find an object with a particular integer value as fast as possible. - I don’t know the number of objects at load time, so I cant load all at once and use binary search. I believe using a tree structure is not the most clever idea, since the data is in order from start. Maybe a skip list is the best idea?.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      How about some associative data structure, like a hash table or a map? You'd get constant lookup time (average) instead of the log n lookup time you'll get with a tree. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      • T t bast

        The objects to store contains a regular integer and a pointer. Each integer value is unique and received in a sequential order (the value is increased by one or more for each time). - I want to find an object with a particular integer value as fast as possible. - I don’t know the number of objects at load time, so I cant load all at once and use binary search. I believe using a tree structure is not the most clever idea, since the data is in order from start. Maybe a skip list is the best idea?.

        B Offline
        B Offline
        Blake V Miller
        wrote on last edited by
        #3

        Store where? It seems to me that if the integer ALWAYS increases by exactly one each time, you can use binary search. Just keep redcuing the index into the list by one-half until you home in on the value. I would htink this shoudl work because our data is of constant size and you know the index value is always increasing.

        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