1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.numbers.examples.jmh.arrays;
18
19 /**
20 * Storage for pivot indices used for partitioning an array into multiple regions.
21 *
22 * <p>A pivot is an index position that contains a value equal to the value in a fully
23 * sorted array.
24 *
25 * <p>For a pivot {@code p}:
26 *
27 * <pre>{@code
28 * i < p < j
29 * data[i] <= data[p] <= data[j]
30 * }</pre>
31 *
32 * <p>Implementations may assume indices are positive. Implementations are not required to
33 * store all indices, and may discard previously stored indices during operation. Behaviour
34 * should be documented.
35 *
36 * <p>This interface is used by methods that create pivots. Methods that use pivots should
37 * use the {@link PivotCache} interface.
38 *
39 * @since 1.2
40 */
41 interface PivotStore {
42 /**
43 * Add the pivot index to the store.
44 *
45 * @param index Index.
46 */
47 void add(int index);
48
49 /**
50 * Add a range of pivot indices to the store.
51 *
52 * <p>If {@code fromIndex == toIndex} this is equivalent to {@link #add(int)}.
53 *
54 * <p><em>If {@code fromIndex > toIndex} the behavior is not defined.</em></p>
55 *
56 * @param fromIndex Start index of the range (inclusive).
57 * @param toIndex End index of the range (inclusive).
58 */
59 void add(int fromIndex, int toIndex);
60 }