Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import tlc2.value.BoolValue;
  2. import tlc2.value.FcnRcdValue;
  3. import tlc2.value.IntValue;
  4. import tlc2.value.IntervalValue;
  5. import tlc2.value.ModelValue;
  6. import tlc2.value.Value;
  7.  
  8. public class OpenAddressing {
  9.  
  10. private static final int minT = 1;
  11.  
  12. public static IntValue shiftR(final IntValue n, final IntValue pos) {
  13. return IntValue.gen(n.val >>> pos.val);
  14. }
  15.  
  16. // rescale(k,maxF,minF,fp,p)
  17. public static IntValue rescale(final IntValue k, final IntValue maxF, final IntValue minF, final IntValue fp,
  18. final IntValue p) {
  19. return IntValue.gen(rescale(k.val, maxF.val, minF.val, fp.val, p.val));
  20. }
  21.  
  22. static int rescale(final int maxT, final int maxF, final int minF, final int fp) {
  23. return rescale(maxT, maxF, minF, fp, 0);
  24. }
  25.  
  26. static int rescale(final int maxT, final int maxF, final int minF, final int fp, final int probe) {
  27. final float factor = (maxT - minT) / ((maxF - minF) * 1f);
  28. int idx = Math.round(factor * (fp - minF) + minT) + probe;
  29. // Modulo might return an index of maxT.
  30. while (idx > maxT) {
  31. idx = idx % (maxT + 1) + 1;
  32. }
  33. return idx;
  34. }
  35.  
  36. public static Value noDupes(final IntervalValue fps, final FcnRcdValue frv, final ModelValue exclude) {
  37. final boolean[] arr = new boolean[fps.size()];
  38. for (final Value value : frv.values) {
  39. if (value != exclude) {
  40. final int val = Math.abs(((IntValue) value).val);
  41. if (arr[val - fps.low] == true) {
  42. return BoolValue.ValFalse;
  43. }
  44. arr[val - fps.low] = true;
  45. }
  46. }
  47. return BoolValue.ValTrue;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement