added add: and addAll: to OrderedCollection
This commit is contained in:
		| @ -35,17 +35,6 @@ class Collection(Object) | ||||
| 		^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 | ||||
| 	{ | ||||
| 		| coll | | ||||
| @ -54,6 +43,18 @@ class Collection(Object) | ||||
| 		^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 | ||||
| 	{ | ||||
| 		| coll | | ||||
| @ -457,6 +458,17 @@ class OrderedCollection(SequenceableCollection) | ||||
| 		^obj. | ||||
| 	} | ||||
|  | ||||
| 	method add: obj | ||||
| 	{ | ||||
| 		^self addLast: obj. | ||||
| 	} | ||||
|  | ||||
| 	method addAll: coll | ||||
| 	{ | ||||
| 		coll do: [:el | self addLast: el ]. | ||||
| 		^coll. | ||||
| 	} | ||||
|  | ||||
| 	method removeFirst | ||||
| 	{ | ||||
| 		| obj | | ||||
|  | ||||
		Reference in New Issue
	
	Block a user