blob: a656dab3bbbfbf5d317e18b454d0a766d73d98e1 [file] [log] [blame]
Andreas Wundsam19dfc1e2014-04-24 19:00:27 -07001package org.projectfloodlight.openflow.types;
2
3import javax.annotation.concurrent.Immutable;
4
5/** a hash value that supports bit-wise combinations, mainly to calculate hash values for
6 * reconciliation operations.
7 *
8 * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
9 *
10 * @param <H> - this type, for return type safety.
11 */
12@Immutable
13public interface HashValue<H extends HashValue<H>> {
14 /** return the "numBits" highest-order bits of the hash.
15 * @param numBits number of higest-order bits to return [0-32].
16 * @return a numberic value of the 0-32 highest-order bits.
17 */
18 int prefixBits(int numBits);
19
Andreas Wundsamc2775202014-06-30 21:31:40 -070020 /** perform an arithmetic addition of this value and other. Wraps around on
21 * overflow of the defined word size.
22 *
23 * @param other
24 * @return this + other
25 */
26 H add(H other);
27
28 /**
29 * arithmetically substract the given 'other' value from this value.
30 * around on overflow.
31 *
32 * @param other
33 * @return this - other
34 */
35 H subtract(H other);
36
Andreas Wundsam19dfc1e2014-04-24 19:00:27 -070037 /** @return the bitwise inverse of this value */
38 H inverse();
39
40 /** or this value with another value value of the same type */
41 H or(H other);
42
43 /** and this value with another value value of the same type */
44 H and(H other);
45
46 /** xor this value with another value value of the same type */
47 H xor(H other);
Andreas Wundsam19dfc1e2014-04-24 19:00:27 -070048}