summaryrefslogtreecommitdiff
blob: 400ff583420c93d0fe00c3b6f4ba0cdd9ce3344d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.Map;
import java.util.HashMap;

public class Depths
{
   private static final Map<Integer, IDs> TO_ID;
   private static final OutputFile DEPTHS_OUTPUT;
   private static int highest_depth;

   static
   {
      highest_depth = -1;

      TO_ID = new HashMap<Integer, IDs>();

      /* TODO: filename as a param? */
      DEPTHS_OUTPUT = OutputFile.new_output_file("depths.mod");
   }

   private Depths () {} /* Utility class. */

   public static IDs get_id_from_depth
   (
      final String depth
   )
   {
      return get_id_from_depth(Integer.valueOf(depth));
   }

   public static IDs get_id_from_depth
   (
      final Integer depth
   )
   {
      IDs result;

      result = TO_ID.get(depth);

      if (result == null)
      {
         result = IDs.generate_new_id(DEPTHS_OUTPUT, "depth");

         TO_ID.put(depth, result);
      }

      if (depth.intValue() > highest_depth)
      {
         highest_depth = depth.intValue();
      }

      return result;
   }

   public static void generate_predicates ()
   {
      for
      (
         int current_depth = highest_depth;
         current_depth > 0;
         --current_depth
      )
      {
         for (int i = 0; i < current_depth; ++i)
         {
            Predicates.add_entry
            (
               DEPTHS_OUTPUT,
               "is_lower_than",
               get_id_from_depth(new Integer(i)),
               get_id_from_depth(new Integer(current_depth))
            );
         }
      }
   }
}