CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: map type issue

  1. #1
    Join Date
    Dec 2002
    Posts
    2

    map type issue

    i whant to know if i can load to a map(STL) type
    1000000 recordes and work with it fine.

    did this will damege the performence?
    if i will run process with this type and work with it it will be ok?

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    It depends on what you will do with this map, but it can be slow. Consider at least putting pointers to the records inside the map as opposed to the real objects.

    You might also consider using hash_map instead, it's quite a bit faster on big data provided that your hash function is good and fast.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  3. #3
    Join Date
    Feb 2002
    Posts
    5,757
    Yes, a map is one solution. There is minimal performance loss if the content of the map is sortable. Thus, the map sorts the contents in a binary tree, making it at most n - 1 height. There will experience performance loss if the contents are 1, 1, 1, 1, 1, 1, etc. such that the tree is of height n - 1.

    Kuphryn

  4. #4
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    Hum, well I think that most implementations use Red-Black trees to implement maps, so it will balance itself "automagically".
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  5. #5
    Join Date
    Feb 2002
    Posts
    5,757
    Yeah, the STL is magical!

    Kuphryn

  6. #6
    Join Date
    Dec 2002
    Posts
    2
    thanks.


    what about the memory?

    shoud i allocate memory on the stack? ( local var )
    or on the heap? ( whit dynamic allocation )

  7. #7
    Join Date
    Feb 2002
    Posts
    5,757
    Program design greatly impacts memory allocation. Consider where and when you will access the map.

    Kuphryn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured