March 2019
Intermediate to advanced
336 pages
9h 9m
English
The weighted reference counting technique tallies the number of references to an object, and each reference is delegated a weight. This technique tracks the total weight of the references to an object. Weighted reference counting was invented by Bevan, Watson, and Watson in 1987. The following code snippet shows an implementation of the weighted reference counting technique:
//Reference Countertype ReferenceCounter struct { num *uint32 pool *sync.Pool removed *uint32 weight int}//WeightedReference methodfunc WeightedReference() int { var references []ReferenceCounter references = GetReferences(root) var reference ReferenceCounter var sum int for _, reference = range references { sum = sum + reference.weight }Read now
Unlock full access