Java large datastructure for storing a matrix

后端 未结 9 1958
北恋
北恋 2021-01-13 02:17

I need to store a 2d matrix containing zip codes and the distance in km between each one of them. My client has an application that calculates the distances which are then s

9条回答
  •  一整个雨季
    2021-01-13 02:59

    Create a new class with 2 slots for location names. Have it always put the alphabetically first name in the first slot. Give it a proper equals and hashcode method. Give it a compareTo (e.g. order alphabetically by names). Throw them all in an array. Sort it.

    Also, hash1 = hash2 does not imply object1 = object2. Don't ever do this. It's a hack.

提交回复
热议问题