diff options
author | OszkarSemerath <semerath@mit.bme.hu> | 2021-08-01 23:15:14 +0200 |
---|---|---|
committer | OszkarSemerath <semerath@mit.bme.hu> | 2021-08-01 23:15:14 +0200 |
commit | 5fcfaa77cb53a4516444bd43ce7c303c8f96020e (patch) | |
tree | e854882aa2eb0883aa649b7a525d1af70823d93d /model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java | |
parent | Model representation is outdated. (diff) | |
download | refinery-5fcfaa77cb53a4516444bd43ce7c303c8f96020e.tar.gz refinery-5fcfaa77cb53a4516444bd43ce7c303c8f96020e.tar.zst refinery-5fcfaa77cb53a4516444bd43ce7c303c8f96020e.zip |
Sonar fixes
Diffstat (limited to 'model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java')
-rw-r--r-- | model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java index f1efaa76..acf7a463 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java | |||
@@ -5,11 +5,11 @@ import java.util.Map; | |||
5 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | 5 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; |
6 | 6 | ||
7 | public abstract class Node<K,V>{ | 7 | public abstract class Node<K,V>{ |
8 | public static final int branchingFactorBit = 5; | 8 | public static final int BRANCHING_FACTOR_BITS = 5; |
9 | public static final int factor = 1<<branchingFactorBit; | 9 | public static final int FACTOR = 1<<BRANCHING_FACTOR_BITS; |
10 | protected static final int numberOfFactors = Integer.SIZE / branchingFactorBit; | 10 | protected static final int NUMBER_OF_FACTORS = Integer.SIZE / BRANCHING_FACTOR_BITS; |
11 | protected static final int factorMask = factor-1; | 11 | protected static final int FACTOR_MASK = FACTOR-1; |
12 | public static final int effectiveBits = branchingFactorBit * numberOfFactors; | 12 | public static final int EFFECTIVE_BITS = BRANCHING_FACTOR_BITS * NUMBER_OF_FACTORS; |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Calculates the index for the continuous hash. | 15 | * Calculates the index for the continuous hash. |
@@ -17,7 +17,7 @@ public abstract class Node<K,V>{ | |||
17 | * @return The index of the continuous hash. | 17 | * @return The index of the continuous hash. |
18 | */ | 18 | */ |
19 | protected static int hashDepth(int depth) { | 19 | protected static int hashDepth(int depth) { |
20 | return depth/numberOfFactors; | 20 | return depth/NUMBER_OF_FACTORS; |
21 | } | 21 | } |
22 | 22 | ||
23 | /** | 23 | /** |
@@ -26,7 +26,7 @@ public abstract class Node<K,V>{ | |||
26 | * @return The segment of a hash code. | 26 | * @return The segment of a hash code. |
27 | */ | 27 | */ |
28 | protected static int shiftDepth(int depth) { | 28 | protected static int shiftDepth(int depth) { |
29 | return depth%numberOfFactors; | 29 | return depth%NUMBER_OF_FACTORS; |
30 | } | 30 | } |
31 | /** | 31 | /** |
32 | * Selects a segments from a complete hash for a given depth. | 32 | * Selects a segments from a complete hash for a given depth. |
@@ -35,8 +35,8 @@ public abstract class Node<K,V>{ | |||
35 | * @return The segment as an integer. | 35 | * @return The segment as an integer. |
36 | */ | 36 | */ |
37 | protected static int hashFragment(int hash, int shiftDepth) { | 37 | protected static int hashFragment(int hash, int shiftDepth) { |
38 | if(shiftDepth<0 || Node.numberOfFactors<shiftDepth) throw new IllegalArgumentException("Invalid shift depth! valid intervall=[0;5], input="+shiftDepth); | 38 | if(shiftDepth<0 || Node.NUMBER_OF_FACTORS<shiftDepth) throw new IllegalArgumentException("Invalid shift depth! valid intervall=[0;5], input="+shiftDepth); |
39 | return (hash >>> shiftDepth*branchingFactorBit) & factorMask; | 39 | return (hash >>> shiftDepth*BRANCHING_FACTOR_BITS) & FACTOR_MASK; |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
@@ -51,15 +51,15 @@ public abstract class Node<K,V>{ | |||
51 | if(hashDepth>=ContinousHashProvider.MAX_PRACTICAL_DEPTH) { | 51 | if(hashDepth>=ContinousHashProvider.MAX_PRACTICAL_DEPTH) { |
52 | throw new IllegalArgumentException("Key "+key+" have the clashing hashcode over the practical depth limitation ("+ContinousHashProvider.MAX_PRACTICAL_DEPTH+")!"); | 52 | throw new IllegalArgumentException("Key "+key+" have the clashing hashcode over the practical depth limitation ("+ContinousHashProvider.MAX_PRACTICAL_DEPTH+")!"); |
53 | } | 53 | } |
54 | return depth%numberOfFactors == 0? | 54 | return depth%NUMBER_OF_FACTORS == 0? |
55 | hashProvider.getHash(key, hashDepth) : | 55 | hashProvider.getHash(key, hashDepth) : |
56 | hash; | 56 | hash; |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | abstract public V getValue(K key, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth); | 60 | public abstract V getValue(K key, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth); |
61 | abstract public Node<K,V> putValue(K key, V value, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth); | 61 | public abstract Node<K,V> putValue(K key, V value, ContinousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth); |
62 | abstract public long getSize(); | 62 | public abstract long getSize(); |
63 | 63 | ||
64 | abstract MutableNode<K, V> toMutable(); | 64 | abstract MutableNode<K, V> toMutable(); |
65 | public abstract ImmutableNode<K, V> toImmutable( | 65 | public abstract ImmutableNode<K, V> toImmutable( |
@@ -73,7 +73,7 @@ public abstract class Node<K,V>{ | |||
73 | abstract boolean moveToNext(MapCursor<K,V> cursor); | 73 | abstract boolean moveToNext(MapCursor<K,V> cursor); |
74 | 74 | ||
75 | ///////// FOR printing | 75 | ///////// FOR printing |
76 | abstract public void prettyPrint(StringBuilder builder, int depth, int code); | 76 | public abstract void prettyPrint(StringBuilder builder, int depth, int code); |
77 | @Override | 77 | @Override |
78 | public String toString() { | 78 | public String toString() { |
79 | StringBuilder stringBuilder = new StringBuilder(); | 79 | StringBuilder stringBuilder = new StringBuilder(); |