@Test public void testRemove() { Mappings<Task, Resource> mappings = new Mappings<Task, Resource>(); Mapping<Task, Resource> mapping = new Mapping<Task, Resource>("m", new Task("t"), new Resource("r")); mappings.add(mapping); Assert.assertTrue(mappings.remove(mapping)); Assert.assertEquals(0, mappings.size()); Assert.assertFalse(mappings.remove(mapping)); }
public boolean remove(Mapping<T, R> mapping) { boolean exist = mappings.remove(mapping); if (exist) { T source = mapping.getSource(); R target = mapping.getTarget(); Set<Mapping<T, R>> s0 = taskMappings.get(source); Set<Mapping<T, R>> s1 = resourceMappings.get(target); s0.remove(mapping); s1.remove(mapping); Bag<R> ts = targets.get(source); Bag<T> ss = sources.get(target); ts.remove(target); ss.remove(source); } return exist; }
Mappings implements Iterable<Mapping<T, R>> { public boolean remove(Mapping<T, R> mapping) { boolean exist = mappings.remove(mapping); if (exist) { T source = mapping.getSource(); R target = mapping.getTarget(); Set<Mapping<T, R>> s0 = taskMappings.get(source); Set<Mapping<T, R>> s1 = resourceMappings.get(target); s0.remove(mapping); s1.remove(mapping); Bag<R> ts = targets.get(source); Bag<T> ss = sources.get(target); ts.remove(target); ss.remove(source); } return exist; } }
Mappings implements Iterable<Mapping<T, R>> { public boolean remove(Mapping<T, R> mapping) { boolean exist = mappings.remove(mapping); if (exist) { T source = mapping.getSource(); R target = mapping.getTarget(); Set<Mapping<T, R>> s0 = taskMappings.get(source); Set<Mapping<T, R>> s1 = resourceMappings.get(target); s0.remove(mapping); s1.remove(mapping); Bag<R> ts = targets.get(source); Bag<T> ss = sources.get(target); ts.remove(target); ss.remove(source); } return exist; }  }
Mappings implements Iterable<Mapping<T, R>> { public boolean remove(Mapping<T, R> mapping) { boolean exist = mappings.remove(mapping); if (exist) { T source = mapping.getSource(); R target = mapping.getTarget(); Set<Mapping<T, R>> s0 = taskMappings.get(source); Set<Mapping<T, R>> s1 = resourceMappings.get(target); s0.remove(mapping); s1.remove(mapping); Bag<R> ts = targets.get(source); Bag<T> ss = sources.get(target); ts.remove(target); ss.remove(source); } return exist; }  void add(Mapping<T, R> mapping); boolean remove(Mapping<T, R> mapping); boolean removeAll(Collection<Mapping<T,R>> mappings); @Override Iterator<Mapping<T, R>> iterator(); int size(); Set<Mapping<T, R>> get(T source); Set<R> getTargets(T source); Set<Mapping<T, R>> get(R target); Set<T> getSources(R target); Set<Mapping<T, R>> get(T source, R target); Set<Mapping<T, R>> getAll(); }
Mappings implements Iterable<Mapping<T, R>> { public boolean remove(Mapping<T, R> mapping) { boolean exist = mappings.remove(mapping); if (exist) { T source = mapping.getSource(); R target = mapping.getTarget(); Set<Mapping<T, R>> s0 = taskMappings.get(source); Set<Mapping<T, R>> s1 = resourceMappings.get(target); s0.remove(mapping); s1.remove(mapping); Bag<R> ts = targets.get(source); Bag<T> ss = sources.get(target); ts.remove(target); ss.remove(source); } return exist; }  void add(Mapping<T, R> mapping); boolean remove(Mapping<T, R> mapping); boolean removeAll(Collection<Mapping<T,R>> mappings); @Override Iterator<Mapping<T, R>> iterator(); int size(); Set<Mapping<T, R>> get(T source); Set<R> getTargets(T source); Set<Mapping<T, R>> get(R target); Set<T> getSources(R target); Set<Mapping<T, R>> get(T source, R target); Set<Mapping<T, R>> getAll();  }