NewDistinctValue with the given maximum data size and values limited. maxDataSize is calculated as the total length of the recorded strings. staleValueThreshold introduces a stop condition that is triggered when the number of found cache hits overcomes the limit For ease of use, maxDataSize=0 and m
(maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int)
| 30 | // For ease of use, maxDataSize=0 and maxValues are interpreted as unlimited. |
| 31 | // Use NewDistinctValueWithDiff to enable diff support, but that one is slightly slower. |
| 32 | func NewDistinctValue[T comparable](maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int) *DistinctValue[T] { |
| 33 | return &DistinctValue[T]{ |
| 34 | values: make(map[T]struct{}), |
| 35 | maxDataSize: maxDataSize, |
| 36 | diffEnabled: false, // disable diff to make it faster |
| 37 | len: len, |
| 38 | maxValues: maxValues, |
| 39 | maxCacheHits: staleValueThreshold, |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // NewDistinctValueWithDiff is like NewDistinctValue but with diff support enabled. |
| 44 | func NewDistinctValueWithDiff[T comparable](maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int) *DistinctValue[T] { |
no outgoing calls