Skip to content

Commit

Permalink
Merge pull request #263 from domeengine/collectionAddAll
Browse files Browse the repository at this point in the history
Collections sometimes support addall now
  • Loading branch information
avivbeeri authored Sep 21, 2023
2 parents 49f85d5 + 2999be5 commit 977fc3f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/modules/collections.wren
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class Stack is Sequence {
clear() { _list.clear() }

add(v) { push(v) }
addAll(other) {
for (item in other) {
push(item)
}
}

remove() { pop() }
get() { peek() }

Expand Down Expand Up @@ -114,6 +120,11 @@ class Set is Sequence {
var hash = hashValue(value)
_map[hash] = value
}
addAll(other) {
for (item in other) {
add(item)
}
}
clear() { _map.clear() }

hashValue(v) {
Expand Down Expand Up @@ -142,6 +153,7 @@ class Queue is Sequence {
_list = []
}
add(item) { _list.add(item) }
addAll(other) { _list.addAll(other) }
remove() {
if (_list.isEmpty) {
return null
Expand Down

0 comments on commit 977fc3f

Please sign in to comment.