11d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/*
21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2011 The Guava Authors
31d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
41d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
51d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * in compliance with the License. You may obtain a copy of the License at
61d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
71d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0
81d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
91d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Unless required by applicable law or agreed to in writing, software distributed under the
101d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
111d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * express or implied. See the License for the specific language governing permissions and
121d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * limitations under the License.
131d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */
141d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
151d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertpackage com.google.common.collect;
161d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
171d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport com.google.common.annotations.GwtCompatible;
181d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
191d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport javax.annotation.Nullable;
201d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
211d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/**
221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * An integer-valued function on binary search tree nodes that adds between nodes.
231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * <p>The value of individual entries must fit into an {@code int}, but the value of an entire
251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * tree can require a {@code long}.
261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @author Louis Wasserman
281d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */
291d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert@GwtCompatible
301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertinterface BstAggregate<N extends BstNode<?, N>> {
311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  /**
321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * The total value on an entire subtree. Must be equal to the sum of the {@link #entryValue
331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * entryValue} of this node and all its descendants.
341d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   */
351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  long treeValue(@Nullable N tree);
361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  /**
381d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * The value on a single entry, ignoring its descendants.
391d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   */
401d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  int entryValue(N entry);
411d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert}
42