Daniel
10/19/2020, 6:03 PMnanodeath
10/19/2020, 6:06 PMDaniel
10/19/2020, 6:06 PMDaniel
10/19/2020, 6:07 PMDaniel
10/19/2020, 6:07 PMnanodeath
10/19/2020, 6:14 PMDaniel
10/19/2020, 6:14 PMMarc Knaup
10/19/2020, 8:11 PMLong
.
Maybe this is of help, but I don’t know what the collision probability is:
https://lemire.me/blog/2018/08/15/fast-strongly-universal-64-bit-hashing-everywhere/Daniel
10/19/2020, 8:12 PMDaniel
10/19/2020, 8:12 PMMarc Knaup
10/19/2020, 8:16 PMHashSet
do you use? The default uses LinkedHashSet
which in turn uses HashMap
. That’s probably two allocations per insertion if I’m not mistaken: One for the new node and one for boxing the Int
.Daniel
10/19/2020, 8:16 PMMarc Knaup
10/19/2020, 8:16 PMDaniel
10/19/2020, 8:16 PMDaniel
10/19/2020, 8:17 PMDaniel
10/19/2020, 8:17 PMMarc Knaup
10/19/2020, 8:18 PMadd()
. If you follow it you’ll see at some point that it creates a new Node instance for each new entry.
• The knowledge that every primitive type like Int
etc. causes an allocation when using it in a generic context (e.g. putting it into a Map or List). There are some exceptions (values between -128 and +127).Marc Knaup
10/19/2020, 8:18 PMDaniel
10/19/2020, 8:52 PMMarc Knaup
10/19/2020, 8:53 PMDaniel
10/19/2020, 8:55 PMDaniel
10/19/2020, 8:55 PMMarc Knaup
10/19/2020, 8:57 PMDaniel
10/19/2020, 8:58 PMDaniel
10/19/2020, 8:59 PMHashMap<TileIdentifier, Tile>
, now I have a HashMap<Int, Tile>
Daniel
10/19/2020, 9:00 PMTileIdentifier(val a: String, val b: String)
(simplified example) I now compute a.hashCode() * 31 + b.hashCode()
Marc Knaup
10/19/2020, 9:00 PMMarc Knaup
10/19/2020, 9:00 PMhashCode
is probably too unreliable for thatMarc Knaup
10/19/2020, 9:01 PM0
and it’s still a valid implementation.