Andreas Wundsam | 19dfc1e | 2014-04-24 19:00:27 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.types; |
| 2 | |
| 3 | import 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 |
| 13 | public 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 Wundsam | c277520 | 2014-06-30 21:31:40 -0700 | [diff] [blame^] | 20 | /** 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 Wundsam | 19dfc1e | 2014-04-24 19:00:27 -0700 | [diff] [blame] | 37 | /** @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 Wundsam | 19dfc1e | 2014-04-24 19:00:27 -0700 | [diff] [blame] | 48 | } |