Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Combine ¶
Combine computes a combined hash code from multiple values using the same algorithm as Composite comparer.
Parameters:
values - variadic list of values to combine into a single hash code
Returns:
A uint64 hash code computed by combining all input values
⚠️ Performance note: Time complexity is O(n) where n is the number of values.
func CombineHashes ¶
CombineHashes computes a combined hash code from multiple individual hash codes using a prime-based combination algorithm. This function provides a standardized way to combine multiple hash codes into a single hash value with good distribution properties, similar to HashCode.Combine() in C# or Guava's HashCode.combine().
Parameters:
values - variadic list of uint64 hash codes to combine
Returns:
A uint64 hash code computed by combining all input hash codes
⚠️ Performance note: Time complexity is O(n) where n is the number of values. This is a very fast operation involving only simple arithmetic operations. Memory allocation is zero - no additional memory is required.
func Compute ¶
Compute generates a hash code for any value using type-specific serialization and the FNV-1a 64-bit hash algorithm. This function provides a generic way to compute hash codes for values of any type without using reflection.
Parameters:
value - any value to compute hash code for (can be nil)
Returns:
A uint64 FNV-1a hash code for the provided value
⚠️ Performance note: Performance varies by type:
- Primitive types (int, float, string, bool): O(1) - very fast
- Byte slices: O(n) where n is slice length
- Complex types: O(m) where m is string representation length
- Uses FNV-1a which is fast but not cryptographically secure
⚠️ Memory note: Minimal allocations for primitive types. Byte slices are included directly. Complex types may allocate during fmt.Sprintf conversion.
Notes:
- Thread safe - can be called concurrently
- Consistent results for equal values within the same process
- Handles nil values gracefully with consistent hash codes
- Uses FNV-1a 64-bit hash algorithm for good distribution and speed
- Little-endian byte order for numeric types ensures consistency
- Common use cases include generic collections, caching, and debugging
Types ¶
This section is empty.