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. ATL / WTL / STL
  4. Cram std::map into std:vector

Cram std::map into std:vector

Scheduled Pinned Locked Moved ATL / WTL / STL
graphicshelpquestion
5 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.
  • J Offline
    J Offline
    Jnewg5
    wrote on last edited by
    #1

    I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?

    J S M 3 Replies Last reply
    0
    • J Jnewg5

      I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?

      J Offline
      J Offline
      Jnewg5
      wrote on last edited by
      #2

      For some reason, the original post parsed out the std:map of (std::string,uint) and std:vector of (byte).

      S 1 Reply Last reply
      0
      • J Jnewg5

        I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        I'm not sure what you mean but I quess perhaps something like this:

        typedef std::vector<std::map<..., ...> > VectorOfMaps_t;

        The "..."s should be filled in with the types you require in the map. I have used a typedef to avoid having to type the huge type name everywhere and for maintainability. "VectorOfMaps_t" is a bad name really because if I changed the type to a std::deque of std::map's it would become misleading.

        Steve

        1 Reply Last reply
        0
        • J Jnewg5

          For some reason, the original post parsed out the std:map of (std::string,uint) and std:vector of (byte).

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          That's a really bad idea. Are you sure this will really save you time?!?!

          Steve

          1 Reply Last reply
          0
          • J Jnewg5

            I have a situation (due to time constraints) that I need to cram a std::map into a std::vector. Can anyone help me?

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            What you're thinking of is called serialization. Look here on CP and MSDN, the topic has been widely covered.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.

            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