(Comparator<? super E> comparator, @Nullable E e, int count, int[] result)
| 597 | } |
| 598 | |
| 599 | AvlNode<E> add(Comparator<? super E> comparator, @Nullable E e, int count, int[] result) { |
| 600 | /* |
| 601 | * It speeds things up considerably to unconditionally add count to totalCount here, |
| 602 | * but that destroys failure atomicity in the case of count overflow. =( |
| 603 | */ |
| 604 | int cmp = comparator.compare(e, elem); |
| 605 | if (cmp < 0) { |
| 606 | AvlNode<E> initLeft = left; |
| 607 | if (initLeft == null) { |
| 608 | result[0] = 0; |
| 609 | return addLeftChild(e, count); |
| 610 | } |
| 611 | int initHeight = initLeft.height; |
| 612 | left = initLeft.add(comparator, e, count, result); |
| 613 | if (result[0] == 0) { |
| 614 | distinctElements++; |
| 615 | } |
| 616 | this.totalCount += count; |
| 617 | return (left.height == initHeight) ? this : rebalance(); |
| 618 | } |
| 619 | else if (cmp > 0) { |
| 620 | AvlNode<E> initRight = right; |
| 621 | if (initRight == null) { |
| 622 | result[0] = 0; |
| 623 | return addRightChild(e, count); |
| 624 | } |
| 625 | int initHeight = initRight.height; |
| 626 | right = initRight.add(comparator, e, count, result); |
| 627 | if (result[0] == 0) { |
| 628 | distinctElements++; |
| 629 | } |
| 630 | this.totalCount += count; |
| 631 | return (right.height == initHeight) ? this : rebalance(); |
| 632 | } |
| 633 | |
| 634 | // adding count to me! No rebalance possible. |
| 635 | result[0] = elemCount; |
| 636 | long resultCount = (long) elemCount + count; |
| 637 | checkArgument(resultCount <= Integer.MAX_VALUE); |
| 638 | this.elemCount += count; |
| 639 | this.totalCount += count; |
| 640 | return this; |
| 641 | } |
| 642 | |
| 643 | AvlNode<E> remove(Comparator<? super E> comparator, @Nullable E e, int count, int[] result) { |
| 644 | int cmp = comparator.compare(e, elem); |
nothing calls this directly
no test coverage detected