@@ -39,17 +39,17 @@ library LogarithmicBuckets {
3939
4040 if (value == 0 ) {
4141 if (_newValue == 0 ) revert ZeroValue ();
42- _insert (_buckets, _id, _computeBucket (_newValue), _head);
42+ _insert (_buckets, _id, computeBucket (_newValue), _head);
4343 return ;
4444 }
4545
46- uint256 currentBucket = _computeBucket (value);
46+ uint256 currentBucket = computeBucket (value);
4747 if (_newValue == 0 ) {
4848 _remove (_buckets, _id, currentBucket);
4949 return ;
5050 }
5151
52- uint256 newBucket = _computeBucket (_newValue);
52+ uint256 newBucket = computeBucket (_newValue);
5353 if (newBucket != currentBucket) {
5454 _remove (_buckets, _id, currentBucket);
5555 _insert (_buckets, _id, newBucket, _head);
@@ -71,7 +71,7 @@ library LogarithmicBuckets {
7171 view
7272 returns (BucketDLL.List storage )
7373 {
74- uint256 bucket = _computeBucket (_value);
74+ uint256 bucket = computeBucket (_value);
7575 return _buckets.lists[bucket];
7676 }
7777
@@ -82,13 +82,13 @@ library LogarithmicBuckets {
8282 function getMatch (BucketList storage _buckets , uint256 _value ) internal view returns (address ) {
8383 uint256 bucketsMask = _buckets.bucketsMask;
8484 if (bucketsMask == 0 ) return address (0 );
85- uint256 lowerMask = _setLowerBits (_value);
85+ uint256 lowerMask = setLowerBits (_value);
8686
87- uint256 next = _nextBucket (lowerMask, bucketsMask);
87+ uint256 next = nextBucket (lowerMask, bucketsMask);
8888
8989 if (next != 0 ) return _buckets.lists[next].getHead ();
9090
91- uint256 prev = _prevBucket (lowerMask, bucketsMask);
91+ uint256 prev = prevBucket (lowerMask, bucketsMask);
9292
9393 return _buckets.lists[prev].getHead ();
9494 }
@@ -126,14 +126,14 @@ library LogarithmicBuckets {
126126 }
127127
128128 /// @notice Returns the bucket in which the given value would fall.
129- function _computeBucket (uint256 _value ) private pure returns (uint256 ) {
130- uint256 lowerMask = _setLowerBits (_value);
129+ function computeBucket (uint256 _value ) internal pure returns (uint256 ) {
130+ uint256 lowerMask = setLowerBits (_value);
131131 return lowerMask ^ (lowerMask >> 1 );
132132 }
133133
134134 /// @notice Sets all the bits lower than (or equal to) the highest bit in the input.
135135 /// @dev This is the same as rounding the input the nearest upper value of the form `2 ** n - 1`.
136- function _setLowerBits (uint256 x ) private pure returns (uint256 y ) {
136+ function setLowerBits (uint256 x ) internal pure returns (uint256 y ) {
137137 assembly {
138138 x := or (x, shr (1 , x))
139139 x := or (x, shr (2 , x))
@@ -148,8 +148,8 @@ library LogarithmicBuckets {
148148
149149 /// @notice Returns the following bucket which contains greater values.
150150 /// @dev The bucket returned is the lowest that is in `bucketsMask` and not in `lowerMask`.
151- function _nextBucket (uint256 lowerMask , uint256 bucketsMask )
152- private
151+ function nextBucket (uint256 lowerMask , uint256 bucketsMask )
152+ internal
153153 pure
154154 returns (uint256 bucket )
155155 {
@@ -161,8 +161,8 @@ library LogarithmicBuckets {
161161
162162 /// @notice Returns the preceding bucket which contains smaller values.
163163 /// @dev The bucket returned is the highest that is in both `bucketsMask` and `lowerMask`.
164- function _prevBucket (uint256 lowerMask , uint256 bucketsMask ) private pure returns (uint256 ) {
165- uint256 lowerBucketsMask = _setLowerBits (lowerMask & bucketsMask);
164+ function prevBucket (uint256 lowerMask , uint256 bucketsMask ) internal pure returns (uint256 ) {
165+ uint256 lowerBucketsMask = setLowerBits (lowerMask & bucketsMask);
166166 return lowerBucketsMask ^ (lowerBucketsMask >> 1 );
167167 }
168168}
0 commit comments