Loop condition: why “not-equal” instead of “lower-than”

后端 未结 5 1975
攒了一身酷
攒了一身酷 2021-01-04 08:56

I was assigned to work on an Android-Java (real-time game) project with a considerable (partially legacy) code base.

Most of the loops I see are like this (where mjk

5条回答
  •  太阳男子
    2021-01-04 10:00

    I think the person who wrote the code may love Containers(maps, vector) a lot (!!)

    Because != is mostly used to iterate through elements of container. For an example to iterate through elements of any generic type != will work for both maps and vectors while < will be only worked for vector. So for iterating elements of generic time != is used. Rather than that I don't find any other advantages. ( hopeful about expert's sugestion/correction)

提交回复
热议问题