View Javadoc
1   /*
2    * Copyright (C) 2010, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.diff;
12  
13  /**
14   * Wraps a {@link org.eclipse.jgit.diff.Sequence} to assign hash codes to
15   * elements.
16   * <p>
17   * This sequence acts as a proxy for the real sequence, caching element hash
18   * codes so they don't need to be recomputed each time. Sequences of this type
19   * must be used with a {@link org.eclipse.jgit.diff.HashedSequenceComparator}.
20   * <p>
21   * To construct an instance of this type use
22   * {@link org.eclipse.jgit.diff.HashedSequencePair}.
23   *
24   * @param <S>
25   *            the base sequence type.
26   */
27  public final class HashedSequence<S extends Sequence> extends Sequence {
28  	final S base;
29  
30  	final int[] hashes;
31  
32  	HashedSequence(S base, int[] hashes) {
33  		this.base = base;
34  		this.hashes = hashes;
35  	}
36  
37  	/** {@inheritDoc} */
38  	@Override
39  	public int size() {
40  		return base.size();
41  	}
42  }