/** * Returns a set view of the keys contained in this map. The set is * backed by the map, so changes to the map are reflected in the set, and * vice-versa. If the map is modified while an iteration over the set is * in progress, the results of the iteration are undefined. The set * supports element removal, which removes the corresponding mapping from * the map, via the <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, * <tt>removeAll</tt> <tt>retainAll</tt>, and <tt>clear</tt> operations. * It does not support the add or <tt>addAll</tt> operations. * <p> * This implementation returns a <code>CompositeSet</code> which * composites the key sets from all of the composited maps. * * @return a set view of the keys contained in this map. */ public java.util.Set <Object> keySet() { CompositeSet keys = new CompositeSet(); for (int i = this.composite.Length - 1; i >= 0; --i) { keys.addComposited(this.composite[i].keySet()); } return((java.util.Set <Object>)keys); }
/** * Returns a set view of the mappings contained in this map. Each element * in the returned set is a <code>Map.Entry</code>. The set is backed by the * map, so changes to the map are reflected in the set, and vice-versa. * If the map is modified while an iteration over the set is in progress, * the results of the iteration are undefined. The set supports element * removal, which removes the corresponding mapping from the map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt> and <tt>clear</tt> operations. It does not support * the <tt>add</tt> or <tt>addAll</tt> operations. * <p> * This implementation returns a <code>CompositeSet</code> which * composites the entry sets from all of the composited maps. * * @see CompositeSet * @return a set view of the mappings contained in this map. */ public java.util.Set <java.util.MapNS.Entry <Object, Object> > entrySet() { CompositeSet entries = new CompositeSet(); for (int i = this.composite.Length - 1; i >= 0; --i) { java.util.Set <java.util.MapNS.Entry <Object, Object> > e = this.composite[i].entrySet(); entries.addComposited((java.util.Set <Object>)e); } return((java.util.Set <java.util.MapNS.Entry <Object, Object> >)entries); //! ??? no error at call ??? }
public void AnEmptySetIsEmpty() { var a = new CompositeSourceSet <int> { }; var b = new CompositeSourceSet <int> { }; var c = new CompositeSourceSet <int> { }; var x = new CompositeSet <int>(a, b); var y = new CompositeSet <int>(x, c); using (var s = y.Subscribe()) { a.Source = a.Source.Add(1); s.Items.ShouldBeEquivalentTo(new[] { 1 }); b.Source = b.Source.Add(1); s.Items.Should().BeEquivalentTo(new[] { 1 }); b.Source = b.Source.Add(3); s.Items.Should().BeEquivalentTo(new[] { 1, 3 }); c.Source = c.Source.Union(new [] { 5, 6, 8 }); s.Items.Should().BeEquivalentTo(new[] { 1, 3, 5, 6, 8 }); } }