@Test public void one_super_type_with_itself() throws Exception { TestDataType t_x = new TestDataType("x"); TestDataType t_y = new TestDataType("y", t_x); Set<DataType> r = AllSuperTypes.run(t_y, true); assertEquals(2, r.size()); assertTrue(r.contains(t_x)); assertTrue(r.contains(t_y)); }
public static Set<DataType> run(DataType t, boolean itself) { Ensure.not_null(t); Set<DataType> pending = new HashSet<>(); pending.add(t); Set<DataType> result = new HashSet<>(); if (itself) { result.add(t); } while (pending.size() > 0) { DataType dt = pending.iterator().next(); pending.remove(dt); Set<DataType> pending_super = dt.super_types(); result.addAll(pending_super); pending.addAll(pending_super); } return result; }
AllSuperTypes { public static Set<DataType> run(DataType t, boolean itself) { Ensure.not_null(t); Set<DataType> pending = new HashSet<>(); pending.add(t); Set<DataType> result = new HashSet<>(); if (itself) { result.add(t); } while (pending.size() > 0) { DataType dt = pending.iterator().next(); pending.remove(dt); Set<DataType> pending_super = dt.super_types(); result.addAll(pending_super); pending.addAll(pending_super); } return result; } }
AllSuperTypes { public static Set<DataType> run(DataType t, boolean itself) { Ensure.not_null(t); Set<DataType> pending = new HashSet<>(); pending.add(t); Set<DataType> result = new HashSet<>(); if (itself) { result.add(t); } while (pending.size() > 0) { DataType dt = pending.iterator().next(); pending.remove(dt); Set<DataType> pending_super = dt.super_types(); result.addAll(pending_super); pending.addAll(pending_super); } return result; } private  AllSuperTypes(); }
AllSuperTypes { public static Set<DataType> run(DataType t, boolean itself) { Ensure.not_null(t); Set<DataType> pending = new HashSet<>(); pending.add(t); Set<DataType> result = new HashSet<>(); if (itself) { result.add(t); } while (pending.size() > 0) { DataType dt = pending.iterator().next(); pending.remove(dt); Set<DataType> pending_super = dt.super_types(); result.addAll(pending_super); pending.addAll(pending_super); } return result; } private  AllSuperTypes(); static Set<DataType> run(DataType t, boolean itself); }
AllSuperTypes { public static Set<DataType> run(DataType t, boolean itself) { Ensure.not_null(t); Set<DataType> pending = new HashSet<>(); pending.add(t); Set<DataType> result = new HashSet<>(); if (itself) { result.add(t); } while (pending.size() > 0) { DataType dt = pending.iterator().next(); pending.remove(dt); Set<DataType> pending_super = dt.super_types(); result.addAll(pending_super); pending.addAll(pending_super); } return result; } private  AllSuperTypes(); static Set<DataType> run(DataType t, boolean itself);  }