Skip to content

Commit 71a51b5

Browse files
committed
Added Set.iterate.
1 parent 903b703 commit 71a51b5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

v3/src/structs/Set.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Set.prototype = {
5151
}
5252
},
5353

54+
// For when you know this Set will be modified during the iteration
5455
each: function (callback)
5556
{
56-
// Because it's highly likely the callback may modify the Set
5757
var temp = this.values.slice();
5858

5959
for (var i = 0; i < temp.length; i++)
@@ -65,6 +65,18 @@ Set.prototype = {
6565
}
6666
},
6767

68+
// For when you absolutely know this Set won't be modified during the iteration
69+
iterate: function (callback)
70+
{
71+
for (var i = 0; i < this.values.length; i++)
72+
{
73+
if (callback(this.values[i]) === false)
74+
{
75+
break;
76+
}
77+
}
78+
},
79+
6880
clear: function ()
6981
{
7082
this.values.length = 0;

0 commit comments

Comments
 (0)