epoxy-adapter / com.airbnb.epoxy / IdUtils

IdUtils

class IdUtils

Utilities for generating 64-bit long IDs from types such as CharSequence.

Functions

hashLong64Bit

static fun hashLong64Bit(value: Long): Long

Hash a long into 64 bits instead of the normal 32. This uses a xor shift implementation to attempt psuedo randomness so object ids have an even spread for less chance of collisions.

hashString64Bit

static fun hashString64Bit(str: CharSequence?): Long

Hash a string into 64 bits instead of the normal 32. This allows us to better use strings as a model id with less chance of collisions. This uses the FNV-1a algorithm for a good mix of speed and distribution.