rder of iteration over a map or a set

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hendrik Schober

    rder of iteration over a map or a set

    Hi,

    if I iterate over a map or a set, is the order
    specified in which the elements are traversed?

    TIA,

    Schobi

    --
    SpamTrap@gmx.de is never read
    I'm Schobi at suespammers dot org

    "Sometimes compilers are so much more reasonable than people."
    Scott Meyers


  • John Harrison

    #2
    Re: rder of iteration over a map or a set


    "Hendrik Schober" <SpamTrap@gmx.d e> wrote in message
    news:c1fcbb$otj $1@news1.transm edia.de...[color=blue]
    > Hi,
    >
    > if I iterate over a map or a set, is the order
    > specified in which the elements are traversed?
    >
    > TIA,
    >
    > Schobi
    >[/color]

    Yes, the order will be in ascending order of keys.

    john


    Comment

    • Jeff Schwab

      #3
      Re: rder of iteration over a map or a set

      Hendrik Schober wrote:
      [color=blue]
      > if I iterate over a map or a set, is the order
      > specified in which the elements are traversed?[/color]

      Yes.

      Comment

      • Hendrik Schober

        #4
        Thanks

        Thanks Jeff and John!

        Schobi

        --
        SpamTrap@gmx.de is never read
        I'm Schobi at suespammers dot org

        "Sometimes compilers are so much more reasonable than people."
        Scott Meyers


        Comment

        • Chris Theis

          #5
          Re: rder of iteration over a map or a set


          "John Harrison" <john_andronicu s@hotmail.com> wrote in message
          news:c1fd85$1i2 e2q$1@ID-196037.news.uni-berlin.de...[color=blue]
          >
          > "Hendrik Schober" <SpamTrap@gmx.d e> wrote in message
          > news:c1fcbb$otj $1@news1.transm edia.de...[color=green]
          > > Hi,
          > >
          > > if I iterate over a map or a set, is the order
          > > specified in which the elements are traversed?
          > >
          > > TIA,
          > >
          > > Schobi
          > >[/color]
          >
          > Yes, the order will be in ascending order of keys.
          >[/color]

          An additional comment to the OP: What "ascending" means in this context
          depends on the sorting criterion, for which a default value (less) is
          supplied.

          Chris



          Comment

          • Hendrik Schober

            #6
            Re: rder of iteration over a map or a set

            Chris Theis <Christian.Thei s@nospam.cern.c h> wrote:[color=blue]
            > [...]
            > An additional comment to the OP: What "ascending" means in this context
            > depends on the sorting criterion, for which a default value (less) is
            > supplied.[/color]

            Thanks. I think I knew that. I was just
            wondering whether implementations are
            required to traverser their trees in
            this order.
            [color=blue]
            > Chris[/color]

            Schobi

            --
            SpamTrap@gmx.de is never read
            I'm Schobi at suespammers dot org

            "Sometimes compilers are so much more reasonable than people."
            Scott Meyers


            Comment

            Working...