michael@0: // Removing a Set entry already visited by an iterator does not cause any michael@0: // entries to be skipped. michael@0: michael@0: var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; michael@0: var set = Set(str); michael@0: michael@0: var log = ''; michael@0: var i = 0; michael@0: for (var x of set) { michael@0: log += x; michael@0: if (i++ % 5 === 0) { michael@0: // Delete all entries preceding this one. michael@0: for (let y of set) { michael@0: if (y === x) michael@0: break; michael@0: set.delete(y); michael@0: } michael@0: } michael@0: } michael@0: assertEq(log, str); michael@0: assertEq(set.size, 1); // Elements 0 to 24 are removed, leaving only 25 (Z). michael@0: assertEq(set.has('Z'), true);