2
lorentz
253d

The iteration order of some hashmap or some such keeps changing when I add or remove log lines. For a given source code the order is static, but I can't bisect errors by logging because when I add a probe arbitrary symptoms vanish or previously correct probes start printing bullshit.

Comments
  • 0
    depending on the implementation of the hashmap the keyword is:

    cryptographically safe, and undefined ordering

    if you want to have an ordered structure with similar functionality you want to look at something like a BinaryTree.
  • 1
    @thebiochemic I specifically chose a fast, hashdos-vulnerable hash function, and for all other purposes I'm quite happy with this setup, it's just print-based debugging that really doesn't work.
  • 0
    @lorentz i guess you have to live with it then. Hasmaps usually don't guarantee consistant ordering. I remember dealing with that problem a while back, and just changed the underlying data structure into a BTree, and was fine with it. But yeah i guess it depends on your use case.

    If it is really for debugging, you could also just map it onto some linear structure and sort it, then output it. It's inefficient, but shouldn't matter for debugging i guess..
Add Comment