added add: and addAll: to OrderedCollection

This commit is contained in:
hyunghwan.chung 2018-06-19 17:13:20 +00:00
parent d8c0453ddd
commit 913f5f6918

View File

@ -35,17 +35,6 @@ class Collection(Object)
^self subclassResponsibility: #do ^self subclassResponsibility: #do
} }
method detect: block
{
self detect: block ifNone: [ ^self error: 'not found' ].
}
method detect: block ifNone: exception_block
{
self do: [ :el | if (block value: el) { ^el } ].
^exception_block value.
}
method collect: block method collect: block
{ {
| coll | | coll |
@ -54,6 +43,18 @@ class Collection(Object)
^coll ^coll
} }
method detect: block
{
^self detect: block ifNone: [ ^self error: 'not found' ].
}
method detect: block ifNone: exception_block
{
## returns the first element for which the block evaluates to true.
self do: [ :el | if (block value: el) { ^el } ].
^exception_block value.
}
method select: condition_block method select: condition_block
{ {
| coll | | coll |
@ -457,6 +458,17 @@ class OrderedCollection(SequenceableCollection)
^obj. ^obj.
} }
method add: obj
{
^self addLast: obj.
}
method addAll: coll
{
coll do: [:el | self addLast: el ].
^coll.
}
method removeFirst method removeFirst
{ {
| obj | | obj |